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-23T15:52:09Z
Lists: pgsql-bugs
Amit Langote <amitlangote09@gmail.com> writes: > On Wed, Sep 30, 2020 at 11:21 AM Tom Lane <tgl@sss.pgh.pa.us> wrote: >> I've not tried to find where is the difference between 11 and >> 12 that makes it fail or not fail. > In v11, GetTupleForTrigger() expands the HeapTuple, with this: > /* > * While this is not necessary anymore after 297d627e, as a defense > * against C code that has not recompiled for minor releases after the > * fix, continue to expand the tuple. > */ > if (HeapTupleHeaderGetNatts(tuple.t_data) < relation->rd_att->natts) > result = heap_expand_tuple(&tuple, relation->rd_att); > else > result = heap_copytuple(&tuple); > ReleaseBuffer(buffer); Ah, good sleuthing. >> I think we can band-aid this immediate problem by forcing >> trigger.c to materialize the "old" tuples it fetches from disk >> (or whatever needs to be done to substitute missing values into >> them). > Maybe something like the attached? Probably needs some attention to memory management (e.g., should_free_trig) but I'm okay with doing this as a short-term fix. I remain worried about similar instances elsewhere, but I have no good ideas about how to find them. 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