| From: | "Matheus Alcantara" <matheusssilv97(at)gmail(dot)com> |
|---|---|
| To: | "Nitin Motiani" <nitinmotiani(at)google(dot)com> |
| Cc: | "Zsolt Parragi" <zsolt(dot)parragi(at)percona(dot)com>, <pgsql-hackers(at)lists(dot)postgresql(dot)org>, "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 16:20:24 |
| Message-ID: | DN2Q75T0A8JS.3BL7022WNXJSO@gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
The CFbot was failing for this patch set, so I took a look and rebased
it. v5 is attached.
The failures came from Heikki's recent commits for CVE-2026-6460
(d98d99ba17b and ac460a144ac). find_composite_type_dependencies() now
rejects ALTER TYPE / ALTER TABLE up front when a domain CHECK constraint
references the composite type directly. The script from the original
report now fails cleanly instead of hitting the internal error:
CREATE TYPE rt AS (i int);
CREATE DOMAIN dt AS int CHECK ((ROW(value)::rt).i > 0);
ALTER TYPE rt ALTER ATTRIBUTE i TYPE bigint;
ERROR: cannot alter type "rt" because constraint dt_check uses it
All of v4 tests used that ROW(value)::rt pattern, or (null::tbl).col,
so they stopped before reaching the code the patches change.
The bug is still there, though. If the expression reaches the type only
through a field selection on a function that returns it, the constraint
records a dependency on the column, not on the type.
find_composite_type_dependencies() lets that through, and
ATPostAlterTypeCleanup() still hits the old error on master:
CREATE TYPE rt AS (i int);
CREATE FUNCTION rt_mk(int) RETURNS rt LANGUAGE sql
AS 'select row($1)::rt';
CREATE DOMAIN dt AS int CHECK ((rt_mk(value)).i > 0);
ALTER TYPE rt ALTER ATTRIBUTE i TYPE bigint;
ERROR: could not identify relation associated with constraint 16390
Changes in v5:
- 0001: Rewrote the tests to use the function form above. I kept the
original script as a test of the new "cannot alter type" error, and
added a paragraph to the commit message explaining this.
- 0002 and 0003: Rewrote the tests the same way. The expected output is
unchanged, except that the NOT VALID constraint's definition no longer
gets a cast written into it, because the expression no longer contains
one.
- 0002: Fixed a trivial rebase conflict in AlteredTableInfo.
I checked that each patch's tests still fail without its code change:
0001 gives the "could not identify relation" error, 0002 gives garbage
values and a bogus type OID during validation, and 0003 gives "must be
owner of type".
(CC Heikki, since your commits are what changed the behaviour here, I'd
appreciate it if you could take a look).
--
Matheus Alcantara
EDB: https://www.enterprisedb.com
| Attachment | Content-Type | Size |
|---|---|---|
| v5-0001-Fix-ALTER-.-TYPE-failure-with-dependent-domain-co.patch | text/plain | 10.3 KB |
| v5-0002-Validate-re-added-domain-constraints-after-ALTER-.patch | text/plain | 15.3 KB |
| v5-0003-Don-t-require-ownership-when-rebuilding-constrain.patch | text/plain | 9.2 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Tomas Vondra | 2026-11-23 16:23:47 | Re: allow spread checkpoints when changing checksums online |
| Previous Message | Tomas Vondra | 2026-11-23 16:14:25 | Re: allow spread checkpoints when changing checksums online |