Re: Generated column is not updated (Postgres 13)

Поиск
Список
Период
Сортировка
От David G. Johnston
Тема Re: Generated column is not updated (Postgres 13)
Дата
Msg-id CAKFQuwZaFiiGphgJsJgV0tUkaA_Z2zQXodvWkx9enR7hjHRmKQ@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Generated column is not updated (Postgres 13)  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Generated column is not updated (Postgres 13)  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-bugs
On Wed, May 19, 2021 at 3:03 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:
Vitaly Ustinov <vitaly@ustinov.ca> writes:
> I would like to report the following:
> - a generated column is never updated if you pass the whole record to a
> stored procedure (an immutable function);

You could perhaps argue that it'd be okay to pass NULL.  The problem
with that, though, is that it'd violate the NOT NULL constraint that
exists for the generated column.  Quite aside from any confusion that
ensues at the user level, I'm afraid that that could result in C code
crashes --- there are, for example, places in tuple deforming that
assume that NOT NULL constraints are truthful.

Knowing why version 12 worked would be helpful in judging whether to live with past decisions, fix poorly made previous decisions, or just move forward with the new behavior in v14 and leave the past alone.  I agree that the better design choice would have us forbid this, though that seems problematic in its own right.  The function itself is defined correctly and aside from the fact it is in a generated expression it is also called correctly.  I suppose the error would be of the form "cannot form a valid whole-row var due to unspecified generated column data"?

FWIW I can definitely see where the OP is coming from with this - the expression at first blush, if one assumes PostgreSQL can handle the nuances, seems like a perfectly reasonable semantic way to express the programmer's desire.  Combined with the fact it used to work makes me want to lean toward keeping it working even if it takes come code hackery.

David J.

В списке pgsql-bugs по дате отправления:

Предыдущее
От: Michael Paquier
Дата:
Сообщение: Re: BUG #17023: wal_log_hints not configured even if it on
Следующее
От: David Rowley
Дата:
Сообщение: Re: Less selective index chosen unexpectedly