Re: Unexpected behavior when combining `generated always` columns and update rules

Поиск
Список
Период
Сортировка
От Ciprian Craciun
Тема Re: Unexpected behavior when combining `generated always` columns and update rules
Дата
Msg-id CA+Tk8fyW4d2Q6yKq1dOH3o5LEt2VQ-QPgfrP1tdq0sUC8nVj8Q@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Unexpected behavior when combining `generated always` columns and update rules  ("David G. Johnston" <david.g.johnston@gmail.com>)
Ответы Re: Unexpected behavior when combining `generated always` columns and update rules  (Adrian Klaver <adrian.klaver@aklaver.com>)
Re: Unexpected behavior when combining `generated always` columns and update rules  (Adrian Klaver <adrian.klaver@aklaver.com>)
Список pgsql-general
On Thu, Apr 13, 2023 at 5:32 PM David G. Johnston
<david.g.johnston@gmail.com> wrote:
> ALSO rules behave like before triggers, not after triggers. The original command is appended to the end of the list
ofcommands, not the start. 


As Tom observed, the documentation states that in case of update
rules, the original query is executed at the end.

However, regardless of the order of the execution between new and
original query, as per the documentation the `new` table should
contain the new values regardless.

In fact, from my example above, one can see that the `y.x` is properly
updated with the new value, meanwhile the `y.d` is the previous one
(i.e. `old.d`).

So, based on these observations, I think that `generated always`
columns are actually computed on insertion, and thus they are not
reflected in `new` on rules.

Ciprian.



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

Предыдущее
От: Adrian Klaver
Дата:
Сообщение: Re: JSON / ASP.NET AJAX Dates support in PostgreSQL
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Unexpected behavior when combining `generated always` columns and update rules