diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c index 4c6700de04553..dcf56446c747b 100644 --- a/src/backend/executor/execExpr.c +++ b/src/backend/executor/execExpr.c @@ -3225,8 +3225,8 @@ ExecInitSubscriptingRef(ExprEvalStep *scratch, SubscriptingRef *sbsref, * trees in which each level of assignment has its own CaseTestExpr, and the * recursive structure appears within the newvals or refassgnexpr field. * There is an exception, though: if the array is an array-of-domain, we will - * have a CoerceToDomain as the refassgnexpr, and we need to be able to look - * through that. + * have a CoerceToDomain or RelabelType as the refassgnexpr, and we need to + * be able to look through that. */ static bool isAssignmentIndirectionExpr(Expr *expr) @@ -3253,6 +3253,12 @@ isAssignmentIndirectionExpr(Expr *expr) return isAssignmentIndirectionExpr(cd->arg); } + else if (IsA(expr, RelabelType)) + { + RelabelType *r = (RelabelType *) expr; + + return isAssignmentIndirectionExpr(r->arg); + } return false; } diff --git a/src/test/regress/expected/domain.out b/src/test/regress/expected/domain.out index b7937fb3bc6cf..6d94e84414a66 100644 --- a/src/test/regress/expected/domain.out +++ b/src/test/regress/expected/domain.out @@ -606,6 +606,15 @@ table dcomptable; {"(1,5)"} (1 row) +-- if there's no constraints, a different code path is taken: +alter domain dcomptype drop constraint dcomptype_check; +update dcomptable set f1[1].cf1 = -1; -- now ok +table dcomptable; + f1 +------------ + {"(-1,5)"} +(1 row) + drop table dcomptable; drop type comptype cascade; NOTICE: drop cascades to type dcomptype diff --git a/src/test/regress/sql/domain.sql b/src/test/regress/sql/domain.sql index a9a56f5277ca0..745f5d5fd2b10 100644 --- a/src/test/regress/sql/domain.sql +++ b/src/test/regress/sql/domain.sql @@ -307,6 +307,10 @@ table dcomptable; update dcomptable set f1[1].cf1 = -1; -- fail update dcomptable set f1[1].cf1 = 1; table dcomptable; +-- if there's no constraints, a different code path is taken: +alter domain dcomptype drop constraint dcomptype_check; +update dcomptable set f1[1].cf1 = -1; -- now ok +table dcomptable; drop table dcomptable; drop type comptype cascade;