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+tz45m...@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: v1-0001-Alow-ALTER-COLUMN-TYPE-when-dependent-generated-c.patch
Description: Binary data

Reply via email to