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

Commit060b22a

Browse files
committed
Fix subtly-wrong volatility checking in BeginCopyFrom().
contain_volatile_functions() is best applied to the output ofexpression_planner(), not its input, so that insertion of functiondefault arguments and constant-folding have been done. (See commentsat CheckMutability, for instance.) It's perhaps unlikely that anyonewill notice a difference in practice, but still we should do it properly.In passing, change variable type from Node* to Expr* to reduce the netnumber of casts needed.Noted while perusing uses of contain_volatile_functions().
1 parent20803d7 commit060b22a

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

‎src/backend/commands/copy.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,18 +2506,22 @@ BeginCopyFrom(Relation rel,
25062506
{
25072507
/* attribute is NOT to be copied from input */
25082508
/* use default value if one exists */
2509-
Node*defexpr=build_column_default(cstate->rel,attnum);
2509+
Expr*defexpr= (Expr*)build_column_default(cstate->rel,
2510+
attnum);
25102511

25112512
if (defexpr!=NULL)
25122513
{
2513-
/* Initialize expressions in copycontext. */
2514-
defexprs[num_defaults]=ExecInitExpr(
2515-
expression_planner((Expr*)defexpr),NULL);
2514+
/* Run the expression through planner */
2515+
defexpr=expression_planner(defexpr);
2516+
2517+
/* Initialize executable expression in copycontext */
2518+
defexprs[num_defaults]=ExecInitExpr(defexpr,NULL);
25162519
defmap[num_defaults]=attnum-1;
25172520
num_defaults++;
25182521

2522+
/* Check to see if we have any volatile expressions */
25192523
if (!volatile_defexprs)
2520-
volatile_defexprs=contain_volatile_functions(defexpr);
2524+
volatile_defexprs=contain_volatile_functions((Node*)defexpr);
25212525
}
25222526
}
25232527
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp