Re: BUG #16644: null value for defaults in OLD variable for trigger

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Amit Langote <amitlangote09(at)gmail(dot)com>
Cc: fedor_erastov(at)mail(dot)ru, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>, Andres Freund <andres(at)anarazel(dot)de>, Andrew Dunstan <andrew(at)dunslane(dot)net>
Subject: Re: BUG #16644: null value for defaults in OLD variable for trigger
Date: 2020-10-25 20:53:35
Message-ID: 623211.1603659215@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

I wrote:
> I fixed the should_free business, and spent a fair amount of time
> convincing myself that no other code paths in trigger.c need this,
> and pushed it.

No sooner had I pushed that than I thought of a potentially better
answer: why is it that the executor's slot hasn't got the right
descriptor, anyway? The reason is that ExecInitModifyTable is relying
on ExecInitJunkFilter, and thence ExecCleanTypeFromTL, to build that
descriptor. But we have the relation's *actual* descriptor right at
hand, and could use that instead. This saves a few cycles ---
ExecCleanTypeFromTL isn't enormously expensive, but it's not free
either. Moreover, it's more correct, even disregarding the problem
at hand, because the tlist isn't a perfectly accurate depiction of
the relation rowtype: ExecCleanTypeFromTL will not derive the correct
info for dropped columns.

We do have to refactor ExecInitJunkFilter a little to make this
possible, but it's not a big change. (I initially tried to use the
existing ExecInitJunkFilterConversion function, but that does the
wrong thing for attisdropped columns.) Otherwise, this reverts the
prior patch's code changes in triggers.c, but keeps the test case.

Thoughts? I'm inclined to leave the previous patch alone in the
back branches, because that has fewer potential side-effects,
but I like this better for HEAD.

regards, tom lane

Attachment Content-Type Size
use-the-right-descriptor-during-UPDATE-1.patch text/x-diff 6.4 KB

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Kyotaro Horiguchi 2020-10-26 01:12:18 Re: BUG #16678: The ecpg connect/test5 test sometimes fails on Windows
Previous Message Tom Lane 2020-10-25 17:59:30 Re: BUG #16644: null value for defaults in OLD variable for trigger