diff options
Diffstat (limited to 'src/backend/parser/parse_target.c')
-rw-r--r-- | src/backend/parser/parse_target.c | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 22af4e7f62e..b3739c9c01c 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -815,7 +815,16 @@ transformAssignmentIndirection(ParseState *pstate, fstore->fieldnums = list_make1_int(attnum); fstore->resulttype = baseTypeId; - /* If target is a domain, apply constraints */ + /* + * If target is a domain, apply constraints. Notice that this + * isn't totally right: the expression tree we build would check + * the domain's constraints on a composite value with only this + * one field populated or updated, possibly leading to an unwanted + * failure. The rewriter will merge together any subfield + * assignments to the same table column, resulting in the domain's + * constraints being checked only once after we've assigned to all + * the fields that the INSERT or UPDATE means to. + */ if (baseTypeId != targetTypeId) return coerce_to_domain((Node *) fstore, baseTypeId, baseTypeMod, @@ -948,7 +957,12 @@ transformAssignmentSubscripts(ParseState *pstate, subscripts, rhs); - /* If target was a domain over container, need to coerce up to the domain */ + /* + * If target was a domain over container, need to coerce up to the domain. + * As in transformAssignmentIndirection, this coercion is premature if the + * query assigns to multiple elements of the container; but we'll fix that + * during query rewrite. + */ if (containerType != targetTypeId) { Oid resulttype = exprType(result); |