Re: [PATCH v1] Fix for Bug#19724 - ALTER TYPE ... ALTER ATTRIBUTE triggers internal error for base type of domain with check

From: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
To: Matheus Alcantara <matheusssilv97(at)gmail(dot)com>
Cc: pgsql-hackers(at)lists(dot)postgresql(dot)org, Nitin Motiani <nitinmotiani(at)google(dot)com>, Ayush Tiwari <ayushtiwari(dot)slg01(at)gmail(dot)com>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: [PATCH v1] Fix for Bug#19724 - ALTER TYPE ... ALTER ATTRIBUTE triggers internal error for base type of domain with check
Date: 2026-11-23 21:59:58
Message-ID: CAN4CZFP_dDLv1-J5yRLL5VXutBzjHYMCsSNm2dbqScks9hu_xQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hello

The following shape still doesn't work properly with v5:

create type ct as (i int);
create function ct_mk(int) returns ct language sql as 'select row($1)::ct';
create table t2 (x int check ((ct_mk(x)).i > 0));
insert into t2 values (1);
create domain d as int constraint d_check check ((ct_mk(value)).i > 0);
comment on constraint d_check on domain d is 'bob comment';

s1: begin; select count(*) from t2;
s2: alter type ct alter attribute i type bigint; (waits for t2)
s3: alter domain d rename to d_old; create domain d as int;
s1: commit;

-- master: s2 fails
ERROR: could not identify relation associated with constraint 16408

-- v5: s2 succeeds, and
select t.typname, c.conname, obj_description(c.oid,'pg_constraint')
from pg_constraint c join pg_type t on t.oid = c.contypid;
d | d_check | bob comment
select (-1)::d_old;
d_old
-------
-1

> We may try to capture the domain oid above AlterDomainAddConstraint,
> while the old constraint still exists and re-add the constraint to that
> OID instead of resolving the name again.

That doesn't seem that complicated to me, and it would fix the above issue?

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Masahiko Sawada 2026-11-23 22:25:31 Re: Fix LogStandbySnapshot() race during logical decoding activation
Previous Message surya poondla 2026-11-23 21:31:53 Re: Fix FATAL error when using recovery_target = 'immediate' on cleanly shut down clusters