3
3
-- Test global temp relations
4
4
--
5
5
-- 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;
7
7
BEGIN;
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 ;
11
11
col
12
12
-----
13
13
1
14
14
2
15
15
(2 rows)
16
16
17
17
COMMIT;
18
- SELECT * FROM temptest ;
18
+ SELECT * FROM global_temptest ;
19
19
col
20
20
-----
21
21
(0 rows)
22
22
23
- DROP TABLE temptest ;
23
+ DROP TABLE global_temptest ;
24
24
BEGIN;
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 ;
27
27
col
28
28
-----
29
29
1
30
30
(1 row)
31
31
32
32
COMMIT;
33
- SELECT * FROM temptest ;
33
+ SELECT * FROM global_temptest ;
34
34
col
35
35
-----
36
36
(0 rows)
37
37
38
- DROP TABLE temptest ;
38
+ DROP TABLE global_temptest ;
39
39
-- Test foreign keys
40
40
BEGIN;
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 )
43
43
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);
46
46
COMMIT;
47
- SELECT * FROM temptest1 ;
47
+ SELECT * FROM global_temptest1 ;
48
48
col
49
49
-----
50
50
1
51
51
(1 row)
52
52
53
- SELECT * FROM temptest2 ;
53
+ SELECT * FROM global_temptest2 ;
54
54
col
55
55
-----
56
56
(0 rows)
57
57
58
58
BEGIN;
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 );
61
61
COMMIT;
62
62
ERROR: 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.
64
64
-- For partitioned temp tables, ON COMMIT actions ignore storage-less
65
65
-- partitioned tables.
66
66
BEGIN;
@@ -81,55 +81,55 @@ DROP TABLE temp_parted_oncommit;
81
81
-- Using ON COMMIT DELETE on a partitioned table does not remove
82
82
-- all rows if partitions preserve their data.
83
83
BEGIN;
84
- CREATE GLOBAL TEMP TABLE temp_parted_oncommit_test (a int)
84
+ CREATE GLOBAL TEMP TABLE global_temp_parted_oncommit_test (a int)
85
85
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
88
88
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);
90
90
COMMIT;
91
91
-- Data from the remaining partition is still here as its rows are
92
92
-- preserved.
93
- SELECT * FROM temp_parted_oncommit_test ;
93
+ SELECT * FROM global_temp_parted_oncommit_test ;
94
94
a
95
95
---
96
96
1
97
97
(1 row)
98
98
99
99
-- 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
105
105
(2 rows)
106
106
107
- DROP TABLE temp_parted_oncommit_test ;
107
+ DROP TABLE global_temp_parted_oncommit_test ;
108
108
-- Check dependencies between ON COMMIT actions with inheritance trees.
109
109
-- Data on the parent is removed, and the child goes away.
110
110
BEGIN;
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);
116
116
COMMIT;
117
- SELECT * FROM temp_inh_oncommit_test ;
117
+ SELECT * FROM global_temp_inh_oncommit_test ;
118
118
a
119
119
---
120
120
1
121
121
(1 row)
122
122
123
123
-- 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
129
129
(2 rows)
130
130
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 ;
133
133
-- Global temp table cannot inherit from temporary relation
134
134
BEGIN;
135
135
CREATE TEMP TABLE global_temp_table (a int) ON COMMIT DELETE ROWS;
0 commit comments