Re: [PATCH] no table rewrite when set column type to constrained domain

From: jian he <jian(dot)universality(at)gmail(dot)com>
To: Aditya Gollamudi <adigollamudi(at)gmail(dot)com>
Cc: Viktor Holmberg <v(at)viktorh(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCH] no table rewrite when set column type to constrained domain
Date: 2026-03-23 13:57:10
Message-ID: CACJufxHR1XavFx2NTOkwKXm+Cyn2h5=u6Pz+AQgp52ixqOiGHw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

hi.

https://postgr.es/m/CAEze2Wi4M1grsR0q27etuB-jncJ6qN-1FMdRX-2PkQxcFpM3sQ@mail.gmail.com
Make me realize that ArrayCoerceExpr (one type of array cast to
another type of array) table rewrite is necessary.
For example, the following will cause a table rewrite:
+CREATE TABLE t22(a INT, b INT, c text COLLATE "C", col1 INT[]);
+CREATE DOMAIN domain1 AS INT CHECK(VALUE > 1) NOT NULL;
+CREATE DOMAIN domain2 AS domain1 CHECK(VALUE > 1) NOT NULL;
+CREATE DOMAIN domain6 AS domain2[];
+ALTER TABLE t22 ALTER COLUMN col1 SET DATA TYPE domain6 USING col1;

Now: if the new type is a constrained domain over the old type,
tablescan is enough.
ATColumnChangeRequiresRewrite works just as before.

--
jian
https://www.enterprisedb.com/

Attachment Content-Type Size
v5-0001-Skipping-table-rewrites-for-changing-column-types-in-some-cases.patch text/x-patch 14.9 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2026-03-23 14:13:06 Re: Trying out <stdatomic.h>
Previous Message Bharath Rupireddy 2026-03-23 13:53:28 Re: Reduce log level of some logical decoding messages to DEBUG1