mirror of
https://github.com/postgres/postgres.git
synced 2025-05-08 07:21:33 +03:00
Remove publicationcmds.c's expr_allowed_in_node as a function
Its API is quite strange, and since there's only one caller, there's no reason for it to be a separate function in the first place. Inline it instead. Discussion: https://postgr.es/m/20220927124249.4zdzzlz6had7k3x2@alvherre.pgsql
This commit is contained in:
parent
f5441b9124
commit
a60b11327b
@ -447,36 +447,6 @@ contain_mutable_or_user_functions_checker(Oid func_id, void *context)
|
|||||||
func_id >= FirstNormalObjectId);
|
func_id >= FirstNormalObjectId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Check if the node contains any disallowed object. Subroutine for
|
|
||||||
* check_simple_rowfilter_expr_walker.
|
|
||||||
*
|
|
||||||
* If a disallowed object is found, *errdetail_msg is set to a (possibly
|
|
||||||
* translated) message to use as errdetail. If none, *errdetail_msg is not
|
|
||||||
* modified.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
expr_allowed_in_node(Node *node, ParseState *pstate, char **errdetail_msg)
|
|
||||||
{
|
|
||||||
if (IsA(node, List))
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
* OK, we don't need to perform other expr checks for List nodes
|
|
||||||
* because those are undefined for List.
|
|
||||||
*/
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exprType(node) >= FirstNormalObjectId)
|
|
||||||
*errdetail_msg = _("User-defined types are not allowed.");
|
|
||||||
else if (check_functions_in_node(node, contain_mutable_or_user_functions_checker,
|
|
||||||
(void *) pstate))
|
|
||||||
*errdetail_msg = _("User-defined or built-in mutable functions are not allowed.");
|
|
||||||
else if (exprCollation(node) >= FirstNormalObjectId ||
|
|
||||||
exprInputCollation(node) >= FirstNormalObjectId)
|
|
||||||
*errdetail_msg = _("User-defined collations are not allowed.");
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The row filter walker checks if the row filter expression is a "simple
|
* The row filter walker checks if the row filter expression is a "simple
|
||||||
* expression".
|
* expression".
|
||||||
@ -586,12 +556,26 @@ check_simple_rowfilter_expr_walker(Node *node, ParseState *pstate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* For all the supported nodes, check the types, functions, and collations
|
* For all the supported nodes, if we haven't already found a problem,
|
||||||
* used in the nodes.
|
* check the types, functions, and collations used in it. We check List
|
||||||
|
* by walking through each element.
|
||||||
*/
|
*/
|
||||||
if (!errdetail_msg)
|
if (!errdetail_msg && !IsA(node, List))
|
||||||
expr_allowed_in_node(node, pstate, &errdetail_msg);
|
{
|
||||||
|
if (exprType(node) >= FirstNormalObjectId)
|
||||||
|
errdetail_msg = _("User-defined types are not allowed.");
|
||||||
|
else if (check_functions_in_node(node, contain_mutable_or_user_functions_checker,
|
||||||
|
(void *) pstate))
|
||||||
|
errdetail_msg = _("User-defined or built-in mutable functions are not allowed.");
|
||||||
|
else if (exprCollation(node) >= FirstNormalObjectId ||
|
||||||
|
exprInputCollation(node) >= FirstNormalObjectId)
|
||||||
|
errdetail_msg = _("User-defined collations are not allowed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we found a problem in this node, throw error now. Otherwise keep
|
||||||
|
* going.
|
||||||
|
*/
|
||||||
if (errdetail_msg)
|
if (errdetail_msg)
|
||||||
ereport(ERROR,
|
ereport(ERROR,
|
||||||
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
|
||||||
@ -653,13 +637,15 @@ TransformPubWhereClauses(List *tables, const char *queryString,
|
|||||||
errdetail("WHERE clause cannot be used for a partitioned table when %s is false.",
|
errdetail("WHERE clause cannot be used for a partitioned table when %s is false.",
|
||||||
"publish_via_partition_root")));
|
"publish_via_partition_root")));
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A fresh pstate is required so that we only have "this" table in its
|
||||||
|
* rangetable
|
||||||
|
*/
|
||||||
pstate = make_parsestate(NULL);
|
pstate = make_parsestate(NULL);
|
||||||
pstate->p_sourcetext = queryString;
|
pstate->p_sourcetext = queryString;
|
||||||
|
|
||||||
nsitem = addRangeTableEntryForRelation(pstate, pri->relation,
|
nsitem = addRangeTableEntryForRelation(pstate, pri->relation,
|
||||||
AccessShareLock, NULL,
|
AccessShareLock, NULL,
|
||||||
false, false);
|
false, false);
|
||||||
|
|
||||||
addNSItemToQuery(pstate, nsitem, false, true, true);
|
addNSItemToQuery(pstate, nsitem, false, true, true);
|
||||||
|
|
||||||
whereclause = transformWhereClause(pstate,
|
whereclause = transformWhereClause(pstate,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user