Re: Does rewriteTargetListIU still need to add UPDATE tlist entries?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Does rewriteTargetListIU still need to add UPDATE tlist entries?
Дата
Msg-id 2250169.1619446133@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Does rewriteTargetListIU still need to add UPDATE tlist entries?  (Amit Langote <amitlangote09@gmail.com>)
Ответы Re: Does rewriteTargetListIU still need to add UPDATE tlist entries?
Список pgsql-hackers
Amit Langote <amitlangote09@gmail.com> writes:
> On Mon, Apr 26, 2021 at 9:40 AM Tom Lane <tgl@sss.pgh.pa.us> wrote:
>> I would think that this is a totally straightforward improvement,
>> but there's one thing in the comments for rewriteTargetListIU that
>> gives me a little pause: it says
>> 
>> * We must do items 1,2,3 before firing rewrite rules, else rewritten
>> * references to NEW.foo will produce wrong or incomplete results.
>> 
>> As far as I can tell, though, references to NEW values still do the
>> right thing.  I'm not certain whether any of the existing regression
>> tests really cover this point, but experimenting with the scenario shown
>> in the attached SQL file says that the DO ALSO rule gets the right
>> results.  It's possible that the expansion sequence is a bit different
>> than before, but we still end up with the right answer.

> I also checked what the rewriter and the planner do for the following
> DO ALSO insert:
> create rule logit as on update to v1 do also
> insert into log values(old.a1, new.a1, old.b2, new.b2);
> and can see that the insert ends up with the right targetlist
> irrespective of whether or not rewriteTargetListIU() adds an item for
> NEW.b2.

Thanks for looking at that.  On reflection I think this must be so,
because those rewriter mechanisms were designed long before we had
trigger-updatable views, and rewriteTargetListIU has never added
tlist items like this for any other sort of view.  So the ability
to insert the original view output column has necessarily been there
from the beginning.  This is just getting rid of a weird implementation
difference between trigger-updatable views and other views.

            regards, tom lane



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

Предыдущее
От: Bharath Rupireddy
Дата:
Сообщение: Re: How to test Postgres for any unaligned memory accesses?
Следующее
От: Dilip Kumar
Дата:
Сообщение: Re: [BUG] "FailedAssertion" reported when streaming in logical replication