Skip to content

Commit 3a64dbc

Browse files
committed
Adapt cloudberry regression suite for regression changes
1 parent b70df45 commit 3a64dbc

3 files changed

Lines changed: 138 additions & 7 deletions

File tree

src/test/regress/expected/minirepro.out

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -305,10 +305,10 @@ SET
305305
SET
306306
SET
307307
SET
308-
psql:data/minirepro.sql:48: ERROR: only shared relations can be placed in pg_global tablespace
309-
psql:data/minirepro.sql:50: ERROR: permission denied: "pg_tablespace" is a system catalog
310-
psql:data/minirepro.sql:58: ERROR: permission denied: "pg_tablespace" is a system catalog
311-
psql:data/minirepro.sql:66: ERROR: permission denied: "pg_tablespace" is a system catalog
308+
psql:data/minirepro.sql:50: ERROR: only shared relations can be placed in pg_global tablespace
309+
psql:data/minirepro.sql:52: ERROR: permission denied: "pg_tablespace" is a system catalog
310+
psql:data/minirepro.sql:60: ERROR: permission denied: "pg_tablespace" is a system catalog
311+
psql:data/minirepro.sql:68: ERROR: permission denied: "pg_tablespace" is a system catalog
312312
SET
313313
UPDATE 1
314314
DELETE 1

src/test/regress/expected/rowsecurity_optimizer.out

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5185,7 +5185,7 @@ RESET SESSION AUTHORIZATION;
51855185
DROP VIEW rls_view;
51865186
DROP TABLE rls_tbl;
51875187
DROP TABLE ref_tbl;
5188-
-- Leaky operator test
5188+
-- Leaky operator tests
51895189
CREATE TABLE rls_tbl (a int);
51905190
NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'a' as the Greenplum Database data distribution key for this table.
51915191
HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are the optimal data distribution key to minimize skew.
@@ -5204,9 +5204,84 @@ SELECT * FROM rls_tbl WHERE a <<< 1000;
52045204
---
52055205
(0 rows)
52065206

5207+
RESET SESSION AUTHORIZATION;
5208+
CREATE TABLE rls_child_tbl () INHERITS (rls_tbl);
5209+
INSERT INTO rls_child_tbl SELECT x/10 FROM generate_series(1, 100) x;
5210+
ANALYZE rls_child_tbl;
5211+
CREATE TABLE rls_ptbl (a int) PARTITION BY RANGE (a);
5212+
CREATE TABLE rls_part PARTITION OF rls_ptbl FOR VALUES FROM (-100) TO (100);
5213+
INSERT INTO rls_ptbl SELECT x/10 FROM generate_series(1, 100) x;
5214+
ANALYZE rls_ptbl, rls_part;
5215+
ALTER TABLE rls_ptbl ENABLE ROW LEVEL SECURITY;
5216+
ALTER TABLE rls_part ENABLE ROW LEVEL SECURITY;
5217+
GRANT SELECT ON rls_ptbl TO regress_rls_alice;
5218+
GRANT SELECT ON rls_part TO regress_rls_alice;
5219+
CREATE POLICY p1 ON rls_tbl USING (a < 0);
5220+
CREATE POLICY p2 ON rls_ptbl USING (a < 0);
5221+
CREATE POLICY p3 ON rls_part USING (a < 0);
5222+
SET SESSION AUTHORIZATION regress_rls_alice;
5223+
SELECT * FROM rls_tbl WHERE a <<< 1000;
5224+
INFO: GPORCA failed to produce a plan, falling back to Postgres-based planner
5225+
DETAIL: Falling back to Postgres-based planner because GPORCA does not support the following feature: Inherited tables
5226+
a
5227+
---
5228+
(0 rows)
5229+
5230+
SELECT * FROM rls_child_tbl WHERE a <<< 1000;
5231+
ERROR: permission denied for table rls_child_tbl
5232+
SELECT * FROM rls_ptbl WHERE a <<< 1000;
5233+
a
5234+
---
5235+
(0 rows)
5236+
5237+
SELECT * FROM rls_part WHERE a <<< 1000;
5238+
a
5239+
---
5240+
(0 rows)
5241+
5242+
SELECT * FROM (SELECT * FROM rls_tbl UNION ALL
5243+
SELECT * FROM rls_tbl) t WHERE a <<< 1000;
5244+
INFO: GPORCA failed to produce a plan, falling back to Postgres-based planner
5245+
DETAIL: Falling back to Postgres-based planner because GPORCA does not support the following feature: Inherited tables
5246+
a
5247+
---
5248+
(0 rows)
5249+
5250+
SELECT * FROM (SELECT * FROM rls_child_tbl UNION ALL
5251+
SELECT * FROM rls_child_tbl) t WHERE a <<< 1000;
5252+
ERROR: permission denied for table rls_child_tbl
5253+
RESET SESSION AUTHORIZATION;
5254+
REVOKE SELECT ON rls_tbl FROM regress_rls_alice;
5255+
CREATE VIEW rls_tbl_view AS SELECT * FROM rls_tbl;
5256+
ALTER TABLE rls_child_tbl ENABLE ROW LEVEL SECURITY;
5257+
GRANT SELECT ON rls_child_tbl TO regress_rls_alice;
5258+
CREATE POLICY p4 ON rls_child_tbl USING (a < 0);
5259+
SET SESSION AUTHORIZATION regress_rls_alice;
5260+
SELECT * FROM rls_tbl WHERE a <<< 1000;
5261+
ERROR: permission denied for table rls_tbl
5262+
SELECT * FROM rls_tbl_view WHERE a <<< 1000;
5263+
ERROR: permission denied for view rls_tbl_view
5264+
SELECT * FROM rls_child_tbl WHERE a <<< 1000;
5265+
a
5266+
---
5267+
(0 rows)
5268+
5269+
SELECT * FROM (SELECT * FROM rls_tbl UNION ALL
5270+
SELECT * FROM rls_tbl) t WHERE a <<< 1000;
5271+
ERROR: permission denied for table rls_tbl
5272+
SELECT * FROM (SELECT * FROM rls_child_tbl UNION ALL
5273+
SELECT * FROM rls_child_tbl) t WHERE a <<< 1000;
5274+
a
5275+
---
5276+
(0 rows)
5277+
52075278
DROP OPERATOR <<< (int, int);
52085279
DROP FUNCTION op_leak(int, int);
52095280
RESET SESSION AUTHORIZATION;
5281+
DROP TABLE rls_part;
5282+
DROP TABLE rls_ptbl;
5283+
DROP TABLE rls_child_tbl;
5284+
DROP VIEW rls_tbl_view;
52105285
DROP TABLE rls_tbl;
52115286
-- Bug #16006: whole-row Vars in a policy don't play nice with sub-selects
52125287
SET SESSION AUTHORIZATION regress_rls_alice;

src/test/regress/expected/stats_ext_optimizer.out

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3300,8 +3300,16 @@ CREATE FUNCTION op_leak(int, int) RETURNS bool
33003300
LANGUAGE plpgsql;
33013301
CREATE OPERATOR <<< (procedure = op_leak, leftarg = int, rightarg = int,
33023302
restrict = scalarltsel);
3303+
CREATE FUNCTION op_leak(record, record) RETURNS bool
3304+
AS 'BEGIN RAISE NOTICE ''op_leak => %, %'', $1, $2; RETURN $1 < $2; END'
3305+
LANGUAGE plpgsql;
3306+
CREATE OPERATOR <<< (procedure = op_leak, leftarg = record, rightarg = record,
3307+
restrict = scalarltsel);
33033308
SELECT * FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Permission denied
33043309
ERROR: permission denied for table priv_test_tbl
3310+
SELECT * FROM tststats.priv_test_tbl t
3311+
WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL); -- Permission denied
3312+
ERROR: permission denied for table priv_test_tbl
33053313
DELETE FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Permission denied
33063314
ERROR: permission denied for table priv_test_tbl
33073315
-- Grant access via a security barrier view, but hide all data
@@ -3316,10 +3324,17 @@ SELECT * FROM tststats.priv_test_view WHERE a <<< 0 AND b <<< 0; -- Should not l
33163324
---+---
33173325
(0 rows)
33183326

3327+
SELECT * FROM tststats.priv_test_view t
3328+
WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL); -- Should not leak
3329+
a | b
3330+
---+---
3331+
(0 rows)
3332+
33193333
DELETE FROM tststats.priv_test_view WHERE a <<< 0 AND b <<< 0; -- Should not leak
33203334
-- Grant table access, but hide all data with RLS
33213335
RESET SESSION AUTHORIZATION;
33223336
ALTER TABLE tststats.priv_test_tbl ENABLE ROW LEVEL SECURITY;
3337+
CREATE POLICY priv_test_tbl_pol ON tststats.priv_test_tbl USING (2 * a < 0);
33233338
GRANT SELECT, DELETE ON tststats.priv_test_tbl TO regress_stats_user1;
33243339
-- Should now have direct table access, but see nothing and leak nothing
33253340
SET SESSION AUTHORIZATION regress_stats_user1;
@@ -3328,7 +3343,45 @@ SELECT * FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Should not le
33283343
---+---
33293344
(0 rows)
33303345

3346+
SELECT * FROM tststats.priv_test_tbl t
3347+
WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL); -- Should not leak
3348+
a | b
3349+
---+---
3350+
(0 rows)
3351+
33313352
DELETE FROM tststats.priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Should not leak
3353+
-- Create plain inheritance parent table with no access permissions
3354+
RESET SESSION AUTHORIZATION;
3355+
CREATE TABLE tststats.priv_test_parent_tbl (a int, b int);
3356+
ALTER TABLE tststats.priv_test_tbl INHERIT tststats.priv_test_parent_tbl;
3357+
-- Should not have access to parent, and should leak nothing
3358+
SET SESSION AUTHORIZATION regress_stats_user1;
3359+
SELECT * FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0; -- Permission denied
3360+
ERROR: permission denied for table priv_test_parent_tbl
3361+
SELECT * FROM tststats.priv_test_parent_tbl t
3362+
WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL); -- Permission denied
3363+
ERROR: permission denied for table priv_test_parent_tbl
3364+
DELETE FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0; -- Permission denied
3365+
ERROR: permission denied for table priv_test_parent_tbl
3366+
-- Grant table access to parent, but hide all data with RLS
3367+
RESET SESSION AUTHORIZATION;
3368+
ALTER TABLE tststats.priv_test_parent_tbl ENABLE ROW LEVEL SECURITY;
3369+
CREATE POLICY priv_test_parent_tbl_pol ON tststats.priv_test_parent_tbl USING (2 * a < 0);
3370+
GRANT SELECT, DELETE ON tststats.priv_test_parent_tbl TO regress_stats_user1;
3371+
-- Should now have direct table access to parent, but see nothing and leak nothing
3372+
SET SESSION AUTHORIZATION regress_stats_user1;
3373+
SELECT * FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0; -- Should not leak
3374+
a | b
3375+
---+---
3376+
(0 rows)
3377+
3378+
SELECT * FROM tststats.priv_test_parent_tbl t
3379+
WHERE a <<< 0 AND (b <<< 0 OR t.* <<< (1, 1) IS NOT NULL); -- Should not leak
3380+
a | b
3381+
---+---
3382+
(0 rows)
3383+
3384+
DELETE FROM tststats.priv_test_parent_tbl WHERE a <<< 0 AND b <<< 0; -- Should not leak
33323385
-- privilege checks for pg_stats_ext and pg_stats_ext_exprs
33333386
RESET SESSION AUTHORIZATION;
33343387
CREATE TABLE stats_ext_tbl (id INT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, col TEXT);
@@ -3408,11 +3461,14 @@ ALTER TABLE sts_sch1.tbl ALTER COLUMN a TYPE SMALLINT;
34083461
-- Tidy up
34093462
DROP OPERATOR <<< (int, int);
34103463
DROP FUNCTION op_leak(int, int);
3464+
DROP OPERATOR <<< (record, record);
3465+
DROP FUNCTION op_leak(record, record);
34113466
RESET SESSION AUTHORIZATION;
34123467
DROP TABLE stats_ext_tbl;
34133468
DROP SCHEMA tststats CASCADE;
3414-
NOTICE: drop cascades to 2 other objects
3415-
DETAIL: drop cascades to table tststats.priv_test_tbl
3469+
NOTICE: drop cascades to 3 other objects
3470+
DETAIL: drop cascades to table tststats.priv_test_parent_tbl
3471+
drop cascades to table tststats.priv_test_tbl
34163472
drop cascades to view tststats.priv_test_view
34173473
DROP SCHEMA sts_sch1, sts_sch2 CASCADE;
34183474
NOTICE: drop cascades to table sts_sch1.tbl

0 commit comments

Comments
 (0)