summaryrefslogtreecommitdiff
path: root/src/test/regress
diff options
context:
space:
mode:
authorJoe Conway <mail@joeconway.com>2015-07-29 15:37:48 -0700
committerJoe Conway <mail@joeconway.com>2015-07-29 15:40:24 -0700
commit632cd9f892119858bc5b617bb60c0377a8a2ed13 (patch)
treea68b80b1cbbccf4b8b42086e9984e651c6956720 /src/test/regress
parentf04ce3147560de90d5250ae822d8d714b76f61cd (diff)
downloadpostgresql-632cd9f892119858bc5b617bb60c0377a8a2ed13.tar.gz
Create new ParseExprKind for use by policy expressions.
Policy USING and WITH CHECK expressions were using EXPR_KIND_WHERE for parse analysis, which results in inappropriate ERROR messages when the expression contains unsupported constructs such as aggregates. Create a new ParseExprKind called EXPR_KIND_POLICY and tailor the related messages to fit. Reported by Noah Misch. Reviewed by Dean Rasheed, Alvaro Herrera, and Robert Haas. Back-patch to 9.5 where RLS was introduced.
Diffstat (limited to 'src/test/regress')
-rw-r--r--src/test/regress/expected/rowsecurity.out9
-rw-r--r--src/test/regress/sql/rowsecurity.sql9
2 files changed, 18 insertions, 0 deletions
diff --git a/src/test/regress/expected/rowsecurity.out b/src/test/regress/expected/rowsecurity.out
index b146da373c..b0556c2ff1 100644
--- a/src/test/regress/expected/rowsecurity.out
+++ b/src/test/regress/expected/rowsecurity.out
@@ -3024,6 +3024,15 @@ CREATE RULE "_RETURN" AS ON SELECT TO t DO INSTEAD
SELECT * FROM generate_series(1,5) t0(c); -- succeeds
ROLLBACK;
--
+-- Policy expression handling
+--
+BEGIN;
+SET row_security = FORCE;
+CREATE TABLE t (c) AS VALUES ('bar'::text);
+CREATE POLICY p ON t USING (max(c)); -- fails: aggregate functions are not allowed in policy expressions
+ERROR: aggregate functions are not allowed in policy expressions
+ROLLBACK;
+--
-- Clean up objects
--
RESET SESSION AUTHORIZATION;
diff --git a/src/test/regress/sql/rowsecurity.sql b/src/test/regress/sql/rowsecurity.sql
index 54f2c89eda..300f34ad4b 100644
--- a/src/test/regress/sql/rowsecurity.sql
+++ b/src/test/regress/sql/rowsecurity.sql
@@ -1290,6 +1290,15 @@ CREATE RULE "_RETURN" AS ON SELECT TO t DO INSTEAD
ROLLBACK;
--
+-- Policy expression handling
+--
+BEGIN;
+SET row_security = FORCE;
+CREATE TABLE t (c) AS VALUES ('bar'::text);
+CREATE POLICY p ON t USING (max(c)); -- fails: aggregate functions are not allowed in policy expressions
+ROLLBACK;
+
+--
-- Clean up objects
--
RESET SESSION AUTHORIZATION;