aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2013-11-08 08:59:43 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2013-11-08 08:59:43 -0500
commit3c24b08f9bdc191d9e389dbcd97dbfb4cdb546d4 (patch)
tree73fe7e0a40e3a022b772a759d37063e167d1bddb /src/backend/commands
parente3480438e89f74019f271b1b5501bb9eed2e0d2a (diff)
downloadpostgresql-3c24b08f9bdc191d9e389dbcd97dbfb4cdb546d4.tar.gz
postgresql-3c24b08f9bdc191d9e389dbcd97dbfb4cdb546d4.zip
Fix subtly-wrong volatility checking in BeginCopyFrom().
contain_volatile_functions() is best applied to the output of expression_planner(), not its input, so that insertion of function default arguments and constant-folding have been done. (See comments at CheckMutability, for instance.) It's perhaps unlikely that anyone will notice a difference in practice, but still we should do it properly. In passing, change variable type from Node* to Expr* to reduce the net number of casts needed. Noted while perusing uses of contain_volatile_functions().
Diffstat (limited to 'src/backend/commands')
-rw-r--r--src/backend/commands/copy.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index 31819cce1d8..082f70fdc38 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -2500,18 +2500,22 @@ BeginCopyFrom(Relation rel,
{
/* attribute is NOT to be copied from input */
/* use default value if one exists */
- Node *defexpr = build_column_default(cstate->rel, attnum);
+ Expr *defexpr = (Expr *) build_column_default(cstate->rel,
+ attnum);
if (defexpr != NULL)
{
- /* Initialize expressions in copycontext. */
- defexprs[num_defaults] = ExecInitExpr(
- expression_planner((Expr *) defexpr), NULL);
+ /* Run the expression through planner */
+ defexpr = expression_planner(defexpr);
+
+ /* Initialize executable expression in copycontext */
+ defexprs[num_defaults] = ExecInitExpr(defexpr, NULL);
defmap[num_defaults] = attnum - 1;
num_defaults++;
+ /* Check to see if we have any volatile expressions */
if (!volatile_defexprs)
- volatile_defexprs = contain_volatile_functions(defexpr);
+ volatile_defexprs = contain_volatile_functions((Node *) defexpr);
}
}
}