pgsql: Make INSERT-from-multiple-VALUES-rows handle domain target colum
Make INSERT-from-multiple-VALUES-rows handle domain target columns. Commit a3c7a993d fixed some cases involving target columns that are arrays or composites by applying transformAssignedExpr to the VALUES entries, and then stripping off any assignment ArrayRefs or FieldStores that the transformation added. But I forgot about domains over arrays or composites :-(. Such cases would either fail with surprising complaints about mismatched datatypes, or insert unexpected coercions that could lead to odd results. To fix, extend the stripping logic to get rid of CoerceToDomain if it's atop an ArrayRef or FieldStore. While poking at this, I realized that there's a poorly documented and not-at-all-tested behavior nearby: we coerce each VALUES column to the domain type separately, and rely on the rewriter to merge those operations so that the domain constraints are checked only once. If that merging did not happen, it's entirely possible that we'd get unexpected domain constraint failures due to checking a partially-updated container value. There's no bug there, but while we're here let's improve the commentary about it and add some test cases that explicitly exercise that behavior. Per bug #18393 from Pablo Kharo. Back-patch to all supported branches. Discussion: https://postgr.es/m/18393-65fedb1a0de92...@postgresql.org Branch -- master Details --- https://git.postgresql.org/pg/commitdiff/b4a71cf65d70b98aaf890b13ec600e340ff69e3f Modified Files -- src/backend/parser/analyze.c | 19 -- src/backend/parser/parse_target.c| 18 +- src/backend/rewrite/rewriteHandler.c | 6 +- src/test/regress/expected/insert.out | 116 ++- src/test/regress/sql/insert.sql | 79 +++- 5 files changed, 227 insertions(+), 11 deletions(-)
pgsql: Make INSERT-from-multiple-VALUES-rows handle domain target colum
Make INSERT-from-multiple-VALUES-rows handle domain target columns. Commit a3c7a993d fixed some cases involving target columns that are arrays or composites by applying transformAssignedExpr to the VALUES entries, and then stripping off any assignment ArrayRefs or FieldStores that the transformation added. But I forgot about domains over arrays or composites :-(. Such cases would either fail with surprising complaints about mismatched datatypes, or insert unexpected coercions that could lead to odd results. To fix, extend the stripping logic to get rid of CoerceToDomain if it's atop an ArrayRef or FieldStore. While poking at this, I realized that there's a poorly documented and not-at-all-tested behavior nearby: we coerce each VALUES column to the domain type separately, and rely on the rewriter to merge those operations so that the domain constraints are checked only once. If that merging did not happen, it's entirely possible that we'd get unexpected domain constraint failures due to checking a partially-updated container value. There's no bug there, but while we're here let's improve the commentary about it and add some test cases that explicitly exercise that behavior. Per bug #18393 from Pablo Kharo. Back-patch to all supported branches. Discussion: https://postgr.es/m/18393-65fedb1a0de92...@postgresql.org Branch -- REL_16_STABLE Details --- https://git.postgresql.org/pg/commitdiff/52898c63e724cd6e18728b4bc0f8d9ec49f12b14 Modified Files -- src/backend/parser/analyze.c | 19 -- src/backend/parser/parse_target.c| 18 +- src/backend/rewrite/rewriteHandler.c | 6 +- src/test/regress/expected/insert.out | 116 ++- src/test/regress/sql/insert.sql | 79 +++- 5 files changed, 227 insertions(+), 11 deletions(-)
pgsql: Make INSERT-from-multiple-VALUES-rows handle domain target colum
Make INSERT-from-multiple-VALUES-rows handle domain target columns. Commit a3c7a993d fixed some cases involving target columns that are arrays or composites by applying transformAssignedExpr to the VALUES entries, and then stripping off any assignment ArrayRefs or FieldStores that the transformation added. But I forgot about domains over arrays or composites :-(. Such cases would either fail with surprising complaints about mismatched datatypes, or insert unexpected coercions that could lead to odd results. To fix, extend the stripping logic to get rid of CoerceToDomain if it's atop an ArrayRef or FieldStore. While poking at this, I realized that there's a poorly documented and not-at-all-tested behavior nearby: we coerce each VALUES column to the domain type separately, and rely on the rewriter to merge those operations so that the domain constraints are checked only once. If that merging did not happen, it's entirely possible that we'd get unexpected domain constraint failures due to checking a partially-updated container value. There's no bug there, but while we're here let's improve the commentary about it and add some test cases that explicitly exercise that behavior. Per bug #18393 from Pablo Kharo. Back-patch to all supported branches. Discussion: https://postgr.es/m/18393-65fedb1a0de92...@postgresql.org Branch -- REL_13_STABLE Details --- https://git.postgresql.org/pg/commitdiff/0200398dd39e5db0eba06043129f1a4daf9170c5 Modified Files -- src/backend/parser/analyze.c | 19 -- src/backend/parser/parse_target.c| 18 +- src/backend/rewrite/rewriteHandler.c | 6 +- src/test/regress/expected/insert.out | 116 ++- src/test/regress/sql/insert.sql | 79 +++- 5 files changed, 227 insertions(+), 11 deletions(-)
pgsql: Make INSERT-from-multiple-VALUES-rows handle domain target colum
Make INSERT-from-multiple-VALUES-rows handle domain target columns. Commit a3c7a993d fixed some cases involving target columns that are arrays or composites by applying transformAssignedExpr to the VALUES entries, and then stripping off any assignment ArrayRefs or FieldStores that the transformation added. But I forgot about domains over arrays or composites :-(. Such cases would either fail with surprising complaints about mismatched datatypes, or insert unexpected coercions that could lead to odd results. To fix, extend the stripping logic to get rid of CoerceToDomain if it's atop an ArrayRef or FieldStore. While poking at this, I realized that there's a poorly documented and not-at-all-tested behavior nearby: we coerce each VALUES column to the domain type separately, and rely on the rewriter to merge those operations so that the domain constraints are checked only once. If that merging did not happen, it's entirely possible that we'd get unexpected domain constraint failures due to checking a partially-updated container value. There's no bug there, but while we're here let's improve the commentary about it and add some test cases that explicitly exercise that behavior. Per bug #18393 from Pablo Kharo. Back-patch to all supported branches. Discussion: https://postgr.es/m/18393-65fedb1a0de92...@postgresql.org Branch -- REL_12_STABLE Details --- https://git.postgresql.org/pg/commitdiff/82c87af7a0ac97ec6e99277f2deb4ee55e347e1e Modified Files -- src/backend/parser/analyze.c | 19 -- src/backend/parser/parse_target.c| 18 +- src/backend/rewrite/rewriteHandler.c | 6 +- src/test/regress/expected/insert.out | 116 ++- src/test/regress/sql/insert.sql | 79 +++- 5 files changed, 227 insertions(+), 11 deletions(-)
pgsql: Make INSERT-from-multiple-VALUES-rows handle domain target colum
Make INSERT-from-multiple-VALUES-rows handle domain target columns. Commit a3c7a993d fixed some cases involving target columns that are arrays or composites by applying transformAssignedExpr to the VALUES entries, and then stripping off any assignment ArrayRefs or FieldStores that the transformation added. But I forgot about domains over arrays or composites :-(. Such cases would either fail with surprising complaints about mismatched datatypes, or insert unexpected coercions that could lead to odd results. To fix, extend the stripping logic to get rid of CoerceToDomain if it's atop an ArrayRef or FieldStore. While poking at this, I realized that there's a poorly documented and not-at-all-tested behavior nearby: we coerce each VALUES column to the domain type separately, and rely on the rewriter to merge those operations so that the domain constraints are checked only once. If that merging did not happen, it's entirely possible that we'd get unexpected domain constraint failures due to checking a partially-updated container value. There's no bug there, but while we're here let's improve the commentary about it and add some test cases that explicitly exercise that behavior. Per bug #18393 from Pablo Kharo. Back-patch to all supported branches. Discussion: https://postgr.es/m/18393-65fedb1a0de92...@postgresql.org Branch -- REL_14_STABLE Details --- https://git.postgresql.org/pg/commitdiff/3621ffd9f21b313116e84301a1dce0d3f1dc2f8a Modified Files -- src/backend/parser/analyze.c | 19 -- src/backend/parser/parse_target.c| 18 +- src/backend/rewrite/rewriteHandler.c | 6 +- src/test/regress/expected/insert.out | 116 ++- src/test/regress/sql/insert.sql | 79 +++- 5 files changed, 227 insertions(+), 11 deletions(-)
pgsql: Make INSERT-from-multiple-VALUES-rows handle domain target colum
Make INSERT-from-multiple-VALUES-rows handle domain target columns. Commit a3c7a993d fixed some cases involving target columns that are arrays or composites by applying transformAssignedExpr to the VALUES entries, and then stripping off any assignment ArrayRefs or FieldStores that the transformation added. But I forgot about domains over arrays or composites :-(. Such cases would either fail with surprising complaints about mismatched datatypes, or insert unexpected coercions that could lead to odd results. To fix, extend the stripping logic to get rid of CoerceToDomain if it's atop an ArrayRef or FieldStore. While poking at this, I realized that there's a poorly documented and not-at-all-tested behavior nearby: we coerce each VALUES column to the domain type separately, and rely on the rewriter to merge those operations so that the domain constraints are checked only once. If that merging did not happen, it's entirely possible that we'd get unexpected domain constraint failures due to checking a partially-updated container value. There's no bug there, but while we're here let's improve the commentary about it and add some test cases that explicitly exercise that behavior. Per bug #18393 from Pablo Kharo. Back-patch to all supported branches. Discussion: https://postgr.es/m/18393-65fedb1a0de92...@postgresql.org Branch -- REL_15_STABLE Details --- https://git.postgresql.org/pg/commitdiff/7c61d23422afece255ed47c84876fb062f40d451 Modified Files -- src/backend/parser/analyze.c | 19 -- src/backend/parser/parse_target.c| 18 +- src/backend/rewrite/rewriteHandler.c | 6 +- src/test/regress/expected/insert.out | 116 ++- src/test/regress/sql/insert.sql | 79 +++- 5 files changed, 227 insertions(+), 11 deletions(-)