mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +03:00
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.
This commit is contained in:
@@ -372,6 +372,13 @@ check_agglevels_and_constraints(ParseState *pstate, Node *expr)
|
||||
break;
|
||||
case EXPR_KIND_WHERE:
|
||||
errkind = true;
|
||||
break;
|
||||
case EXPR_KIND_POLICY:
|
||||
if (isAgg)
|
||||
err = _("aggregate functions are not allowed in policy expressions");
|
||||
else
|
||||
err = _("grouping operations are not allowed in policy expressions");
|
||||
|
||||
break;
|
||||
case EXPR_KIND_HAVING:
|
||||
/* okay */
|
||||
@@ -770,6 +777,9 @@ transformWindowFuncCall(ParseState *pstate, WindowFunc *wfunc,
|
||||
case EXPR_KIND_WHERE:
|
||||
errkind = true;
|
||||
break;
|
||||
case EXPR_KIND_POLICY:
|
||||
err = _("window functions are not allowed in policy expressions");
|
||||
break;
|
||||
case EXPR_KIND_HAVING:
|
||||
errkind = true;
|
||||
break;
|
||||
|
Reference in New Issue
Block a user