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

Commitc6873ea

Browse files
committed
Fix overly-enthusiastic Assert in printing of Param reference expressions.
A NestLoopParam's value can only be a Var or Aggref, but this isn't thecase in general for SubPlan parameters, so print_parameter_expr had betterbe prepared to cope. Brain fade in my recent patch to print the referencedexpression instead of just printing $N for PARAM_EXEC Params. Per reportfrom Pavel Stehule.
1 parentef55e29 commitc6873ea

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

‎src/backend/utils/adt/ruleutils.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4368,6 +4368,7 @@ print_parameter_expr(Node *expr, ListCell *ancestor_cell,
43684368
{
43694369
deparse_namespacesave_dpns;
43704370
boolsave_varprefix;
4371+
boolneed_paren;
43714372

43724373
/* Switch attention to the ancestor plan node */
43734374
push_ancestor_plan(dpns,ancestor_cell,&save_dpns);
@@ -4380,13 +4381,21 @@ print_parameter_expr(Node *expr, ListCell *ancestor_cell,
43804381
context->varprefix= true;
43814382

43824383
/*
4383-
* We don't need to add parentheses because a Param's expansion is
4384-
* (currently) always a Var or Aggref.
4384+
* A Param's expansion is typically a Var, Aggref, or upper-level Param,
4385+
* which wouldn't need extra parentheses. Otherwise, insert parens to
4386+
* ensure the expression looks atomic.
43854387
*/
4386-
Assert(IsA(expr,Var)||IsA(expr,Aggref));
4388+
need_paren= !(IsA(expr,Var)||
4389+
IsA(expr,Aggref)||
4390+
IsA(expr,Param));
4391+
if (need_paren)
4392+
appendStringInfoChar(context->buf,'(');
43874393

43884394
get_rule_expr(expr,context, false);
43894395

4396+
if (need_paren)
4397+
appendStringInfoChar(context->buf,')');
4398+
43904399
context->varprefix=save_varprefix;
43914400

43924401
pop_ancestor_plan(dpns,&save_dpns);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp