Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression

From: Peter Eisentraut <peter(at)eisentraut(dot)org>
To: Amul Sul <sulamul(at)gmail(dot)com>
Cc: Robert Haas <robertmhaas(at)gmail(dot)com>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com>, Vaibhav Dalvi <vaibhav(dot)dalvi(at)enterprisedb(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: ALTER COLUMN ... SET EXPRESSION to alter stored generated column's expression
Date: 2023-11-15 21:20:41
Message-ID: e9ae99e2-1f99-43ab-b4e8-067a7aa581a0@eisentraut.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 15.11.23 13:26, Amul Sul wrote:
> Question: Why are you using AT_PASS_ADD_OTHERCONSTR?  I don't know if
> it's right or wrong, but if you have a specific reason, it would be
> good
> to know.
>
> I referred to ALTER COLUMN DEFAULT and used that.

Hmm, I'm not sure if that is a good comparison. For ALTER TABLE, SET
DEFAULT is just a catalog manipulation, it doesn't change any data, so
it's pretty easy. SET EXPRESSION changes data, which other phases might
want to inspect? For example, if you do SET EXPRESSION and add a
constraint in the same ALTER TABLE statement, do those run in the
correct order?

> I think ATExecSetExpression() needs to lock pg_attribute?  Did you lose
> that during the refactoring?
>
> I have removed that intentionally since we were not updating anything in
> pg_attribute like ALTER DROP EXPRESSION.

ok

> Tiny comment: The error message in ATExecSetExpression() does not need
> to mention "stored", since it would be also applicable to virtual
> generated columns in the future.
>
> I had to have the same thought, but later decided when we do that
> virtual column thing, we could simply change that. I am fine to do that
> change
> now as well, let me know your thought.

Not a big deal, but I would change it now.

Another small thing I found: In ATExecColumnDefault(), there is an
errhint() that suggests DROP EXPRESSION instead of DROP DEFAULT. You
could now add another hint that suggests SET EXPRESSION instead of SET
DEFAULT.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Melanie Plageman 2023-11-15 21:21:45 Re: lazy_scan_heap() should release lock on buffer before vacuuming FSM
Previous Message Tom Lane 2023-11-15 21:17:08 Re: On non-Windows, hard depend on uselocale(3)