Fix use-after-free bug with AfterTriggersTableData.storeslot AfterTriggerSaveEvent() wrongly allocates the slot in execution-span memory context, whereas the correct thing is to allocate it in a transaction-span context, because that's where the enclosing AfterTriggersTableData instance belongs into.
Backpatch to 12 (the test back to 11, where it works well with no code changes, and it's good to have to confirm that the case was previously well supported); this bug seems introduced by commit ff11e7f4b9ae. Reported-by: Bertrand Drouvot <[email protected]> Author: Amit Langote <[email protected]> Discussion: https://postgr.es/m/[email protected] Branch ------ REL_11_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/d1c6edd31d6c3e6d173d47a64a3b28660705def7 Modified Files -------------- src/test/regress/expected/triggers.out | 59 ++++++++++++++++++++++++++++++ src/test/regress/sql/triggers.sql | 65 ++++++++++++++++++++++++++++++++++ 2 files changed, 124 insertions(+)
