Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd0b1dbc

Browse files
committed
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 noreason for it to be a separate function in the first place. Inline itinstead.Discussion:https://postgr.es/m/20220927124249.4zdzzlz6had7k3x2@alvherre.pgsql
1 parent2e560b9 commitd0b1dbc

File tree

1 file changed

+22
-36
lines changed

1 file changed

+22
-36
lines changed

‎src/backend/commands/publicationcmds.c

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -447,36 +447,6 @@ contain_mutable_or_user_functions_checker(Oid func_id, void *context)
447447
func_id >=FirstNormalObjectId);
448448
}
449449

450-
/*
451-
* Check if the node contains any disallowed object. Subroutine for
452-
* check_simple_rowfilter_expr_walker.
453-
*
454-
* If a disallowed object is found, *errdetail_msg is set to a (possibly
455-
* translated) message to use as errdetail. If none, *errdetail_msg is not
456-
* modified.
457-
*/
458-
staticvoid
459-
expr_allowed_in_node(Node*node,ParseState*pstate,char**errdetail_msg)
460-
{
461-
if (IsA(node,List))
462-
{
463-
/*
464-
* OK, we don't need to perform other expr checks for List nodes
465-
* because those are undefined for List.
466-
*/
467-
return;
468-
}
469-
470-
if (exprType(node) >=FirstNormalObjectId)
471-
*errdetail_msg=_("User-defined types are not allowed.");
472-
elseif (check_functions_in_node(node,contain_mutable_or_user_functions_checker,
473-
(void*)pstate))
474-
*errdetail_msg=_("User-defined or built-in mutable functions are not allowed.");
475-
elseif (exprCollation(node) >=FirstNormalObjectId||
476-
exprInputCollation(node) >=FirstNormalObjectId)
477-
*errdetail_msg=_("User-defined collations are not allowed.");
478-
}
479-
480450
/*
481451
* The row filter walker checks if the row filter expression is a "simple
482452
* expression".
@@ -586,12 +556,26 @@ check_simple_rowfilter_expr_walker(Node *node, ParseState *pstate)
586556
}
587557

588558
/*
589-
* For all the supported nodes, check the types, functions, and collations
590-
* used in the nodes.
559+
* For all the supported nodes, if we haven't already found a problem,
560+
* check the types, functions, and collations used in it. We check List
561+
* by walking through each element.
591562
*/
592-
if (!errdetail_msg)
593-
expr_allowed_in_node(node,pstate,&errdetail_msg);
563+
if (!errdetail_msg&& !IsA(node,List))
564+
{
565+
if (exprType(node) >=FirstNormalObjectId)
566+
errdetail_msg=_("User-defined types are not allowed.");
567+
elseif (check_functions_in_node(node,contain_mutable_or_user_functions_checker,
568+
(void*)pstate))
569+
errdetail_msg=_("User-defined or built-in mutable functions are not allowed.");
570+
elseif (exprCollation(node) >=FirstNormalObjectId||
571+
exprInputCollation(node) >=FirstNormalObjectId)
572+
errdetail_msg=_("User-defined collations are not allowed.");
573+
}
594574

575+
/*
576+
* If we found a problem in this node, throw error now. Otherwise keep
577+
* going.
578+
*/
595579
if (errdetail_msg)
596580
ereport(ERROR,
597581
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
@@ -653,13 +637,15 @@ TransformPubWhereClauses(List *tables, const char *queryString,
653637
errdetail("WHERE clause cannot be used for a partitioned table when %s is false.",
654638
"publish_via_partition_root")));
655639

640+
/*
641+
* A fresh pstate is required so that we only have "this" table in its
642+
* rangetable
643+
*/
656644
pstate=make_parsestate(NULL);
657645
pstate->p_sourcetext=queryString;
658-
659646
nsitem=addRangeTableEntryForRelation(pstate,pri->relation,
660647
AccessShareLock,NULL,
661648
false, false);
662-
663649
addNSItemToQuery(pstate,nsitem, false, true, true);
664650

665651
whereclause=transformWhereClause(pstate,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp