33-- Test global temp relations
44--
55-- Test ON COMMIT DELETE ROWS
6- CREATE GLOBAL TEMP TABLE temptest (col int) ON COMMIT DELETE ROWS;
6+ CREATE GLOBAL TEMP TABLE global_temptest (col int) ON COMMIT DELETE ROWS;
77BEGIN;
8- INSERT INTO temptest VALUES (1);
9- INSERT INTO temptest VALUES (2);
10- SELECT * FROM temptest ;
8+ INSERT INTO global_temptest VALUES (1);
9+ INSERT INTO global_temptest VALUES (2);
10+ SELECT * FROM global_temptest ;
1111 col
1212-----
1313 1
1414 2
1515(2 rows)
1616
1717COMMIT;
18- SELECT * FROM temptest ;
18+ SELECT * FROM global_temptest ;
1919 col
2020-----
2121(0 rows)
2222
23- DROP TABLE temptest ;
23+ DROP TABLE global_temptest ;
2424BEGIN;
25- CREATE GLOBAL TEMP TABLE temptest (col) ON COMMIT DELETE ROWS AS SELECT 1;
26- SELECT * FROM temptest ;
25+ CREATE GLOBAL TEMP TABLE global_temptest (col) ON COMMIT DELETE ROWS AS SELECT 1;
26+ SELECT * FROM global_temptest ;
2727 col
2828-----
2929 1
3030(1 row)
3131
3232COMMIT;
33- SELECT * FROM temptest ;
33+ SELECT * FROM global_temptest ;
3434 col
3535-----
3636(0 rows)
3737
38- DROP TABLE temptest ;
38+ DROP TABLE global_temptest ;
3939-- Test foreign keys
4040BEGIN;
41- CREATE GLOBAL TEMP TABLE temptest1 (col int PRIMARY KEY);
42- CREATE GLOBAL TEMP TABLE temptest2 (col int REFERENCES temptest1 )
41+ CREATE GLOBAL TEMP TABLE global_temptest1 (col int PRIMARY KEY);
42+ CREATE GLOBAL TEMP TABLE global_temptest2 (col int REFERENCES global_temptest1 )
4343 ON COMMIT DELETE ROWS;
44- INSERT INTO temptest1 VALUES (1);
45- INSERT INTO temptest2 VALUES (1);
44+ INSERT INTO global_temptest1 VALUES (1);
45+ INSERT INTO global_temptest2 VALUES (1);
4646COMMIT;
47- SELECT * FROM temptest1 ;
47+ SELECT * FROM global_temptest1 ;
4848 col
4949-----
5050 1
5151(1 row)
5252
53- SELECT * FROM temptest2 ;
53+ SELECT * FROM global_temptest2 ;
5454 col
5555-----
5656(0 rows)
5757
5858BEGIN;
59- CREATE GLOBAL TEMP TABLE temptest3 (col int PRIMARY KEY) ON COMMIT DELETE ROWS;
60- CREATE GLOBAL TEMP TABLE temptest4 (col int REFERENCES temptest3 );
59+ CREATE GLOBAL TEMP TABLE global_temptest3 (col int PRIMARY KEY) ON COMMIT DELETE ROWS;
60+ CREATE GLOBAL TEMP TABLE global_temptest4 (col int REFERENCES global_temptest3 );
6161COMMIT;
6262ERROR: unsupported ON COMMIT and foreign key combination
63- DETAIL: Table "temptest4 " references "temptest3 ", but they do not have the same ON COMMIT setting.
63+ DETAIL: Table "global_temptest4 " references "global_temptest3 ", but they do not have the same ON COMMIT setting.
6464-- For partitioned temp tables, ON COMMIT actions ignore storage-less
6565-- partitioned tables.
6666BEGIN;
@@ -81,55 +81,55 @@ DROP TABLE temp_parted_oncommit;
8181-- Using ON COMMIT DELETE on a partitioned table does not remove
8282-- all rows if partitions preserve their data.
8383BEGIN;
84- CREATE GLOBAL TEMP TABLE temp_parted_oncommit_test (a int)
84+ CREATE GLOBAL TEMP TABLE global_temp_parted_oncommit_test (a int)
8585 PARTITION BY LIST (a) ON COMMIT DELETE ROWS;
86- CREATE GLOBAL TEMP TABLE temp_parted_oncommit_test1
87- PARTITION OF temp_parted_oncommit_test
86+ CREATE GLOBAL TEMP TABLE global_temp_parted_oncommit_test1
87+ PARTITION OF global_temp_parted_oncommit_test
8888 FOR VALUES IN (1) ON COMMIT PRESERVE ROWS;
89- INSERT INTO temp_parted_oncommit_test VALUES (1);
89+ INSERT INTO global_temp_parted_oncommit_test VALUES (1);
9090COMMIT;
9191-- Data from the remaining partition is still here as its rows are
9292-- preserved.
93- SELECT * FROM temp_parted_oncommit_test ;
93+ SELECT * FROM global_temp_parted_oncommit_test ;
9494 a
9595---
9696 1
9797(1 row)
9898
9999-- two relations remain in this case.
100- SELECT relname FROM pg_class WHERE relname LIKE 'temp_parted_oncommit_test %';
101- relname
102- ----------------------------
103- temp_parted_oncommit_test
104- temp_parted_oncommit_test1
100+ SELECT relname FROM pg_class WHERE relname LIKE 'global_temp_parted_oncommit_test %';
101+ relname
102+ -----------------------------------
103+ global_temp_parted_oncommit_test
104+ global_temp_parted_oncommit_test1
105105(2 rows)
106106
107- DROP TABLE temp_parted_oncommit_test ;
107+ DROP TABLE global_temp_parted_oncommit_test ;
108108-- Check dependencies between ON COMMIT actions with inheritance trees.
109109-- Data on the parent is removed, and the child goes away.
110110BEGIN;
111- CREATE GLOBAL TEMP TABLE temp_inh_oncommit_test (a int) ON COMMIT DELETE ROWS;
112- CREATE GLOBAL TEMP TABLE temp_inh_oncommit_test1 ()
113- INHERITS(temp_inh_oncommit_test ) ON COMMIT PRESERVE ROWS;
114- INSERT INTO temp_inh_oncommit_test1 VALUES (1);
115- INSERT INTO temp_inh_oncommit_test VALUES (1);
111+ CREATE GLOBAL TEMP TABLE global_temp_inh_oncommit_test (a int) ON COMMIT DELETE ROWS;
112+ CREATE GLOBAL TEMP TABLE global_temp_inh_oncommit_test1 ()
113+ INHERITS(global_temp_inh_oncommit_test ) ON COMMIT PRESERVE ROWS;
114+ INSERT INTO global_temp_inh_oncommit_test1 VALUES (1);
115+ INSERT INTO global_temp_inh_oncommit_test VALUES (1);
116116COMMIT;
117- SELECT * FROM temp_inh_oncommit_test ;
117+ SELECT * FROM global_temp_inh_oncommit_test ;
118118 a
119119---
120120 1
121121(1 row)
122122
123123-- two relations remain
124- SELECT relname FROM pg_class WHERE relname LIKE 'temp_inh_oncommit_test %';
125- relname
126- -------------------------
127- temp_inh_oncommit_test
128- temp_inh_oncommit_test1
124+ SELECT relname FROM pg_class WHERE relname LIKE 'global_temp_inh_oncommit_test %';
125+ relname
126+ --------------------------------
127+ global_temp_inh_oncommit_test
128+ global_temp_inh_oncommit_test1
129129(2 rows)
130130
131- DROP TABLE temp_inh_oncommit_test1 ;
132- DROP TABLE temp_inh_oncommit_test ;
131+ DROP TABLE global_temp_inh_oncommit_test1 ;
132+ DROP TABLE global_temp_inh_oncommit_test ;
133133-- Global temp table cannot inherit from temporary relation
134134BEGIN;
135135CREATE TEMP TABLE global_temp_table (a int) ON COMMIT DELETE ROWS;
0 commit comments