@@ -20,79 +20,73 @@ ALTER DEFAULT PRIVILEGES FOR ROLE regress_selinto_user
20
20
REVOKE INSERT ON TABLES FROM regress_selinto_user;
21
21
GRANT ALL ON SCHEMA selinto_schema TO public;
22
22
SET SESSION AUTHORIZATION regress_selinto_user;
23
- SELECT * INTO TABLE selinto_schema.tmp1
24
- FROM pg_class WHERE relname like '%a%';
25
- ERROR: permission denied for table tmp1
26
- SELECT oid AS clsoid, relname, relnatts + 10 AS x
27
- INTO selinto_schema.tmp2
28
- FROM pg_class WHERE relname like '%b%';
29
- ERROR: permission denied for table tmp2
30
- -- WITH DATA, fails
31
- CREATE TABLE selinto_schema.tbl_withdata (a,b,c)
32
- AS SELECT oid,relname,relacl FROM pg_class
33
- WHERE relname like '%c%' WITH DATA;
34
- ERROR: permission denied for table tbl_withdata
23
+ -- WITH DATA, passes.
24
+ CREATE TABLE selinto_schema.tbl_withdata1 (a)
25
+ AS SELECT generate_series(1,3) WITH DATA;
26
+ INSERT INTO selinto_schema.tbl_withdata1 VALUES (4);
27
+ ERROR: permission denied for table tbl_withdata1
35
28
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
36
- CREATE TABLE selinto_schema.tbl_withdata (a,b,c)
37
- AS SELECT oid,relname,relacl FROM pg_class
38
- WHERE relname like '%c%' WITH DATA;
39
- ERROR: permission denied for table tbl_withdata
29
+ CREATE TABLE selinto_schema.tbl_withdata2 (a) AS
30
+ SELECT generate_series(1,3) WITH DATA;
31
+ QUERY PLAN
32
+ --------------------------------------
33
+ ProjectSet (actual rows=3 loops=1)
34
+ -> Result (actual rows=1 loops=1)
35
+ (2 rows)
36
+
40
37
-- WITH NO DATA, passes.
41
38
CREATE TABLE selinto_schema.tbl_nodata1 (a) AS
42
- SELECT oid FROM pg_class WHERE relname like '%c%' WITH NO DATA;
39
+ SELECT generate_series(1,3) WITH NO DATA;
43
40
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
44
41
CREATE TABLE selinto_schema.tbl_nodata2 (a) AS
45
- SELECT oid FROM pg_class WHERE relname like '%c%' WITH NO DATA;
46
- QUERY PLAN
47
- ---------------------------------------
48
- Seq Scan on pg_class (never executed)
49
- Filter: (relname ~~ '%c%'::text )
42
+ SELECT generate_series(1,3) WITH NO DATA;
43
+ QUERY PLAN
44
+ -------------------------------
45
+ ProjectSet (never executed)
46
+ -> Result (never executed )
50
47
(2 rows)
51
48
52
- -- EXECUTE and WITH DATA, fails.
53
- PREPARE data_sel AS
54
- SELECT oid FROM pg_class WHERE relname like '%c%';
55
- CREATE TABLE selinto_schema.tbl_withdata (a) AS
49
+ -- EXECUTE and WITH DATA, passes.
50
+ PREPARE data_sel AS SELECT generate_series(1,3);
51
+ CREATE TABLE selinto_schema.tbl_withdata3 (a) AS
56
52
EXECUTE data_sel WITH DATA;
57
- ERROR: permission denied for table tbl_withdata
58
53
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
59
- CREATE TABLE selinto_schema.tbl_withdata (a) AS
54
+ CREATE TABLE selinto_schema.tbl_withdata4 (a) AS
60
55
EXECUTE data_sel WITH DATA;
61
- ERROR: permission denied for table tbl_withdata
56
+ QUERY PLAN
57
+ --------------------------------------
58
+ ProjectSet (actual rows=3 loops=1)
59
+ -> Result (actual rows=1 loops=1)
60
+ (2 rows)
61
+
62
62
-- EXECUTE and WITH NO DATA, passes.
63
63
CREATE TABLE selinto_schema.tbl_nodata3 (a) AS
64
64
EXECUTE data_sel WITH NO DATA;
65
65
EXPLAIN (ANALYZE, COSTS OFF, SUMMARY OFF, TIMING OFF)
66
66
CREATE TABLE selinto_schema.tbl_nodata4 (a) AS
67
67
EXECUTE data_sel WITH NO DATA;
68
- QUERY PLAN
69
- ---------------------------------------
70
- Seq Scan on pg_class (never executed)
71
- Filter: (relname ~~ '%c%'::text )
68
+ QUERY PLAN
69
+ -------------------------------
70
+ ProjectSet (never executed)
71
+ -> Result (never executed )
72
72
(2 rows)
73
73
74
74
RESET SESSION AUTHORIZATION;
75
75
ALTER DEFAULT PRIVILEGES FOR ROLE regress_selinto_user
76
76
GRANT INSERT ON TABLES TO regress_selinto_user;
77
77
SET SESSION AUTHORIZATION regress_selinto_user;
78
- SELECT * INTO TABLE selinto_schema.tmp1
79
- FROM pg_class WHERE relname like '%a%'; -- OK
80
- SELECT oid AS clsoid, relname, relnatts + 10 AS x
81
- INTO selinto_schema.tmp2
82
- FROM pg_class WHERE relname like '%b%'; -- OK
83
- CREATE TABLE selinto_schema.tmp3 (a,b,c)
84
- AS SELECT oid,relname,relacl FROM pg_class
85
- WHERE relname like '%c%'; -- OK
86
78
RESET SESSION AUTHORIZATION;
79
+ DEALLOCATE data_sel;
87
80
DROP SCHEMA selinto_schema CASCADE;
88
- NOTICE: drop cascades to 7 other objects
89
- DETAIL: drop cascades to table selinto_schema.tbl_nodata1
81
+ NOTICE: drop cascades to 8 other objects
82
+ DETAIL: drop cascades to table selinto_schema.tbl_withdata1
83
+ drop cascades to table selinto_schema.tbl_withdata2
84
+ drop cascades to table selinto_schema.tbl_nodata1
90
85
drop cascades to table selinto_schema.tbl_nodata2
86
+ drop cascades to table selinto_schema.tbl_withdata3
87
+ drop cascades to table selinto_schema.tbl_withdata4
91
88
drop cascades to table selinto_schema.tbl_nodata3
92
89
drop cascades to table selinto_schema.tbl_nodata4
93
- drop cascades to table selinto_schema.tmp1
94
- drop cascades to table selinto_schema.tmp2
95
- drop cascades to table selinto_schema.tmp3
96
90
DROP USER regress_selinto_user;
97
91
-- Tests for WITH NO DATA and column name consistency
98
92
CREATE TABLE ctas_base (i int, j int);
0 commit comments