From: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com> |
---|---|
To: | jian he <jian(dot)universality(at)gmail(dot)com>, Peter Eisentraut <peter(at)eisentraut(dot)org> |
Cc: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: Why cannot alter a column's type when it's used by a generated column |
Date: | 2025-10-21 07:03:41 |
Message-ID: | CAEoWx2ntXwiAS8-gknV32uosSKPsS7gXKwT7T3ijqKyWWoMkJw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Jian,
Thanks for looking into this problem.
> The attached patch removes this restriction.
> it need more polish, but it's good enough to use it to verify the bug I
> reported
> on
>
> https://postgr.es/m/CACJufxHZsgn3zM5g-x7YmtFGzNDnRwR07S+GYfiUs+tZ45MDDw@mail.gmail.com
I think we can keep the discussion in your thread. Actually, I got this
idea from your discussion.
But for this topic, I don't want to go that far in the first place, because
completely allowing that might require more discussion.
Here I am just proposing a patch for a small step. When any dependent
generated column has SET EXPRESSION, then we can allow the column type
change:
```
-- Before this patch, the recommended usage was:
ALTER TABLE gtest
DROP COLUMN x,
ALTER COLUMN a TYPE float8,
ADD COLUMN x bigint GENERATED ALWAYS AS ((a::int + b) * 2) STORED;
-- With this patch, the statement is simplified as:
ALTER TABLE gtest
ALTER COLUMN a TYPE float8,
ALTER COLUMN x SET EXPRESSION ((a::int + b) * 2);
```
Best regards,
Chao Li (Evan)
---------------------
HighGo Software Co., Ltd.
https://www.highgo.com/
Attachment | Content-Type | Size |
---|---|---|
v1-0001-Alow-ALTER-COLUMN-TYPE-when-dependent-generated-c.patch | application/octet-stream | 11.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Heikki Linnakangas | 2025-10-21 07:10:38 | Re: Optimizing ResouceOwner to speed up COPY |
Previous Message | Amit Kapila | 2025-10-21 06:56:12 | Re: Logical Replication of sequences |