Re: BUG #17897: Crash on assignment to array of constraint-less domain over composite type

Dmitry Dolgov <9erthalion6@gmail.com>

From: Dmitry Dolgov <9erthalion6@gmail.com>
To: exclusion@gmail.com, pgsql-bugs@lists.postgresql.org
Date: 2023-04-15T15:17:09Z
Lists: pgsql-bugs
> On Fri, Apr 14, 2023 at 07:00:01PM +0000, PG Bug reporting form wrote:
>
> The following modified excerpt from regress/sql/domain.sql:
> create type comptype as (cf1 int, cf2 int);
> create domain dcomptype as comptype;
>
> create table dcomptable (f1 dcomptype[]);
> insert into dcomptable values (null);
> update dcomptable set f1[1].cf2 = 5;
>
> causes a server crash with the following stack trace:
> [...]
> Not reproduced on REL_11_STABLE, but reproduced on REL_12_STABLE .. master
> since 04fe805a1 made a constraint-less domain represented as a RelabelType
> (not CoerceToDomain) and thus the fix for [1] (ae7b1dd59) doesn't cover
> this
> case.

Looks like it could be fixed in the same way as in ae7b1dd59 ?

diff --git a/src/backend/executor/execExpr.c b/src/backend/executor/execExpr.c
index 4c6700de04..06fbf19423 100644
--- a/src/backend/executor/execExpr.c
+++ b/src/backend/executor/execExpr.c
@@ -3253,6 +3253,12 @@ isAssignmentIndirectionExpr(Expr *expr)

				return isAssignmentIndirectionExpr(cd->arg);
		}
+       else if (IsA(expr, RelabelType))
+       {
+               RelabelType *rt = (RelabelType *) expr;
+
+               return isAssignmentIndirectionExpr(rt->arg);
+       }
		return false;
 }



Commits

  1. Fix assignment to array of domain over composite, redux.