summaryrefslogtreecommitdiffstats
path: root/src/backend/parser/parse_target.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:05:26 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:05:26 +0000
commite75d99818dd3940be997520e64db8c9e3b207e39 (patch)
tree0003ca0de74fcc8d18433e34ea68d2e7aaf06b7c /src/backend/parser/parse_target.c
parentReleasing progress-linux version 15.6-0+deb12u1~progress6.99u1. (diff)
downloadpostgresql-15-e75d99818dd3940be997520e64db8c9e3b207e39.tar.xz
postgresql-15-e75d99818dd3940be997520e64db8c9e3b207e39.zip
Merging upstream version 15.7.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/backend/parser/parse_target.c')
-rw-r--r--src/backend/parser/parse_target.c18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c
index bff3003..4d6d88c 100644
--- a/src/backend/parser/parse_target.c
+++ b/src/backend/parser/parse_target.c
@@ -828,7 +828,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,
@@ -976,7 +985,12 @@ transformAssignmentSubscripts(ParseState *pstate,
result = (Node *) sbsref;
- /* 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);