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

2023-04-13 Thread Tom Lane
Adrian Klaver writes: > On 4/13/23 09:27, Ciprian Craciun wrote: >> 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. > Just realized we may have both being saying the same thing. T

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

2023-04-13 Thread Adrian Klaver
On 4/13/23 09:27, Ciprian Craciun wrote: On Thu, Apr 13, 2023 at 5:32 PM David G. Johnston wrote: ALSO rules behave like before triggers, not after triggers. The original command is appended to the end of the list of commands, not the start. As Tom observed, the documentation states that in

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

2023-04-13 Thread Adrian Klaver
On 4/13/23 09:27, Ciprian Craciun wrote: On Thu, Apr 13, 2023 at 5:32 PM David G. Johnston wrote: ALSO rules behave like before triggers, not after triggers. The original command is appended to the end of the list of commands, not the start. As Tom observed, the documentation states that in

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

2023-04-13 Thread Ciprian Craciun
On Thu, Apr 13, 2023 at 5:32 PM David G. Johnston wrote: > ALSO rules behave like before triggers, not after triggers. The original > command is appended to the end of the list of commands, not the start. As Tom observed, the documentation states that in case of update rules, the original query

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

2023-04-13 Thread Tom Lane
"David G. Johnston" writes: > On Thursday, April 13, 2023, Ciprian Craciun > wrote: >> create or replace rule propagate_x_and_d as on update to x do also >> update y set x = new.x, d = new.d where y.x = old.x; >> >> As seen above, although the rule correctly propagates the change to >> the `x` c

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

2023-04-13 Thread David G. Johnston
On Thursday, April 13, 2023, Ciprian Craciun wrote: > > create or replace rule propagate_x_and_d as on update to x do also > update y set x = new.x, d = new.d where y.x = old.x; > > As seen above, although the rule correctly propagates the change to > the `x` column, it fails to use the new v

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

2023-04-13 Thread Ciprian Craciun
Hello all! I'm uncertain if what I've observed (and describe below) is a bug, works as expected (but I've not found it mentioned in the documentation), or it's just a by-product of combining two advanced features that haven't been thoroughly tested together. So, to summarize: I'm trying to use t