Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c236ea1

Browse files
committed
[test] [refer #PGPRO-2887] Some tests for global temp tables and prepared transactions.
1 parent b85fa20 commit c236ea1

File tree

3 files changed

+442
-0
lines changed

3 files changed

+442
-0
lines changed

src/test/regress/expected/global_temp.out

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ SELECT * FROM global_temptest2;
5555
-----
5656
(0 rows)
5757

58+
DROP TABLE global_temptest2;
59+
DROP TABLE global_temptest1;
60+
-- Unsupported ON COMMIT and foreign key combination
5861
BEGIN;
5962
CREATE GLOBAL TEMP TABLE global_temptest3(col int PRIMARY KEY) ON COMMIT DELETE ROWS;
6063
CREATE GLOBAL TEMP TABLE global_temptest4(col int REFERENCES global_temptest3);
@@ -245,3 +248,76 @@ SELECT NEXTVAL( 'test_sequence' );
245248

246249
DROP TABLE global_temp_table;
247250
DROP SEQUENCE test_sequence;
251+
-- Test two phase commit
252+
CREATE TABLE global_temptest_persistent(col int);
253+
CREATE GLOBAL TEMP TABLE global_temptest(col int);
254+
INSERT INTO global_temptest VALUES (1);
255+
BEGIN;
256+
INSERT INTO global_temptest VALUES (2);
257+
SELECT * FROM global_temptest;
258+
col
259+
-----
260+
1
261+
2
262+
(2 rows)
263+
264+
PREPARE TRANSACTION 'global_temp1';
265+
-- We can't see anything from an uncommitted transaction
266+
SELECT * FROM global_temptest;
267+
col
268+
-----
269+
1
270+
(1 row)
271+
272+
BEGIN;
273+
INSERT INTO global_temptest VALUES (3);
274+
INSERT INTO global_temptest_persistent SELECT * FROM global_temptest;
275+
PREPARE TRANSACTION 'global_temp2';
276+
COMMIT PREPARED 'global_temp1';
277+
-- 1, 2
278+
SELECT * FROM global_temptest;
279+
col
280+
-----
281+
1
282+
2
283+
(2 rows)
284+
285+
-- Nothing
286+
SELECT * FROM global_temptest_persistent;
287+
col
288+
-----
289+
(0 rows)
290+
291+
\c
292+
-- The temp table is empty now.
293+
SELECT * FROM global_temptest;
294+
col
295+
-----
296+
(0 rows)
297+
298+
-- Still nothing in global_temptest_persistent table;
299+
SELECT * FROM global_temptest_persistent;
300+
col
301+
-----
302+
(0 rows)
303+
304+
INSERT INTO global_temptest VALUES (4);
305+
COMMIT PREPARED 'global_temp2';
306+
-- Only 4
307+
SELECT * FROM global_temptest;
308+
col
309+
-----
310+
4
311+
(1 row)
312+
313+
-- 1, 3
314+
SELECT * FROM global_temptest_persistent;
315+
col
316+
-----
317+
1
318+
3
319+
(2 rows)
320+
321+
\c
322+
DROP TABLE global_temptest;
323+
DROP TABLE global_temptest_persistent;

0 commit comments

Comments
 (0)