On 23 Mar 2026 at 14:57 +0100, jian he <[email protected]>, wrote:
> hi.
>
> https://postgr.es/m/caeze2wi4m1grsr0q27etub-jncj6qn-1fmdrx-2pkqxcfpm...@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
This appears to address some of my comments but not this one?

CREATE DOMAIN domain1 AS INT CHECK(VALUE > 1) NOT NULL;
CREATE TABLE t_const_using(a INT);
INSERT INTO t_const_using VALUES(-2);
ALTER TABLE t_const_using ALTER COLUMN a SET DATA TYPE domain1 USING 5;
SELECT a FROM t_const_using; -- should be 5 after rewrite, not -2
 a
----
 -2

Reply via email to