Re: BUG #16644: null value for defaults in OLD variable for trigger
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Amit Langote <amitlangote09@gmail.com>
Cc: fedor_erastov@mail.ru,
PostgreSQL mailing lists <pgsql-bugs@lists.postgresql.org>,
Andres Freund <andres@anarazel.de>,
Andrew Dunstan <andrew@dunslane.net>
Date: 2020-10-25T20:53:35Z
Lists: pgsql-bugs
Attachments
- use-the-right-descriptor-during-UPDATE-1.patch (text/x-diff) patch
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
Commits
-
In INSERT/UPDATE, use the table's real tuple descriptor as target.
- 94ec005f334e 12.5 landed
- 8b39345a9d9a 14.0 landed
- 7aeb6404f0aa 13.1 landed
- 20d3fe9009dd 14.0 landed
-
Fix corner case for a BEFORE ROW UPDATE trigger returning OLD.
- de78c10072b3 12.5 landed
- d88d8ad28484 13.1 landed
- ba9f18abd365 14.0 landed
-
Use slots in trigger infrastructure, except for the actual invocation.
- ff11e7f4b9ae 12.0 cited