@@ -752,59 +752,63 @@ SELECT * FROM check_estimated_rows('SELECT * FROM mcv_lists_bool WHERE NOT a AND
752752-- the underlying table.
753753--
754754-- Currently this is only relevant for MCV stats.
755- CREATE TABLE priv_test_tbl (
755+ CREATE SCHEMA tststats;
756+ CREATE TABLE tststats.priv_test_tbl (
756757 a int,
757758 b int
758759);
759- INSERT INTO priv_test_tbl
760+ INSERT INTO tststats. priv_test_tbl
760761 SELECT mod(i,5), mod(i,10) FROM generate_series(1,100) s(i);
761- CREATE STATISTICS priv_test_stats (mcv) ON a, b
762- FROM priv_test_tbl;
763- ANALYZE priv_test_tbl;
762+ CREATE STATISTICS tststats. priv_test_stats (mcv) ON a, b
763+ FROM tststats. priv_test_tbl;
764+ ANALYZE tststats. priv_test_tbl;
764765-- User with no access
765766CREATE USER regress_stats_user1;
767+ GRANT USAGE ON SCHEMA tststats TO regress_stats_user1;
766768SET SESSION AUTHORIZATION regress_stats_user1;
767- SELECT * FROM priv_test_tbl; -- Permission denied
769+ SELECT * FROM tststats. priv_test_tbl; -- Permission denied
768770ERROR: permission denied for table priv_test_tbl
769771-- Attempt to gain access using a leaky operator
770772CREATE FUNCTION op_leak(int, int) RETURNS bool
771773 AS 'BEGIN RAISE NOTICE ''op_leak => %, %'', $1, $2; RETURN $1 < $2; END'
772774 LANGUAGE plpgsql;
773775CREATE OPERATOR <<< (procedure = op_leak, leftarg = int, rightarg = int,
774776 restrict = scalarltsel);
775- SELECT * FROM priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Permission denied
777+ SELECT * FROM tststats. priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Permission denied
776778ERROR: permission denied for table priv_test_tbl
777- DELETE FROM priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Permission denied
779+ DELETE FROM tststats. priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Permission denied
778780ERROR: permission denied for table priv_test_tbl
779781-- Grant access via a security barrier view, but hide all data
780782RESET SESSION AUTHORIZATION;
781- CREATE VIEW priv_test_view WITH (security_barrier=true)
782- AS SELECT * FROM priv_test_tbl WHERE false;
783- GRANT SELECT, DELETE ON priv_test_view TO regress_stats_user1;
783+ CREATE VIEW tststats. priv_test_view WITH (security_barrier=true)
784+ AS SELECT * FROM tststats. priv_test_tbl WHERE false;
785+ GRANT SELECT, DELETE ON tststats. priv_test_view TO regress_stats_user1;
784786-- Should now have access via the view, but see nothing and leak nothing
785787SET SESSION AUTHORIZATION regress_stats_user1;
786- SELECT * FROM priv_test_view WHERE a <<< 0 AND b <<< 0; -- Should not leak
788+ SELECT * FROM tststats. priv_test_view WHERE a <<< 0 AND b <<< 0; -- Should not leak
787789 a | b
788790---+---
789791(0 rows)
790792
791- DELETE FROM priv_test_view WHERE a <<< 0 AND b <<< 0; -- Should not leak
793+ DELETE FROM tststats. priv_test_view WHERE a <<< 0 AND b <<< 0; -- Should not leak
792794-- Grant table access, but hide all data with RLS
793795RESET SESSION AUTHORIZATION;
794- ALTER TABLE priv_test_tbl ENABLE ROW LEVEL SECURITY;
795- GRANT SELECT, DELETE ON priv_test_tbl TO regress_stats_user1;
796+ ALTER TABLE tststats. priv_test_tbl ENABLE ROW LEVEL SECURITY;
797+ GRANT SELECT, DELETE ON tststats. priv_test_tbl TO regress_stats_user1;
796798-- Should now have direct table access, but see nothing and leak nothing
797799SET SESSION AUTHORIZATION regress_stats_user1;
798- SELECT * FROM priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Should not leak
800+ SELECT * FROM tststats. priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Should not leak
799801 a | b
800802---+---
801803(0 rows)
802804
803- DELETE FROM priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Should not leak
805+ DELETE FROM tststats. priv_test_tbl WHERE a <<< 0 AND b <<< 0; -- Should not leak
804806-- Tidy up
805807DROP OPERATOR <<< (int, int);
806808DROP FUNCTION op_leak(int, int);
807809RESET SESSION AUTHORIZATION;
808- DROP VIEW priv_test_view;
809- DROP TABLE priv_test_tbl;
810+ DROP SCHEMA tststats CASCADE;
811+ NOTICE: drop cascades to 2 other objects
812+ DETAIL: drop cascades to table tststats.priv_test_tbl
813+ drop cascades to view tststats.priv_test_view
810814DROP USER regress_stats_user1;
0 commit comments