summaryrefslogtreecommitdiff
path: root/src/backend/commands/copy.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/commands/copy.c')
-rw-r--r--src/backend/commands/copy.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c
index f91f1646dac..7c4039cb7ff 100644
--- a/src/backend/commands/copy.c
+++ b/src/backend/commands/copy.c
@@ -2519,9 +2519,20 @@ BeginCopyFrom(Relation rel,
defmap[num_defaults] = attnum - 1;
num_defaults++;
- /* Check to see if we have any volatile expressions */
+ /*
+ * If a default expression looks at the table being loaded, then
+ * it could give the wrong answer when using multi-insert. Since
+ * database access can be dynamic this is hard to test for
+ * exactly, so we use the much wider test of whether the
+ * default expression is volatile. We allow for the special case
+ * of when the default expression is the nextval() of a sequence
+ * which in this specific case is known to be safe for use with
+ * the multi-insert optimisation. Hence we use this special case
+ * function checker rather than the standard check for
+ * contain_volatile_functions().
+ */
if (!volatile_defexprs)
- volatile_defexprs = contain_volatile_functions((Node *) defexpr);
+ volatile_defexprs = contain_volatile_functions_not_nextval((Node *)defexpr);
}
}
}