mirror of https://github.com/postgres/postgres
ALTER TABLE commands in an extension script are added to an event
trigger command list; but starting with commit b5810de3f4
they do so in
a memory context that's too short-lived, so when execution ends and time
comes to use the entries, they've already been freed.
(This would also be a problem with ALTER TABLE commands in a
multi-command query string, but these serendipitously end in
PortalContext -- which probably explains why it took so long for this to
be reported.)
Fix by using the memory context specifically set for that, instead.
Backpatch to 13, where the aforementioned commit appeared.
Reported-by: Philippe Beaudoin
Author: Jehan-Guillaume de Rorthais <jgdr@dalibo.com>
Discussion: https://postgr.es/m/20200902193715.6e0269d4@firost
pull/57/head
parent
10a5b35a00
commit
ced138e8cb
@ -0,0 +1,7 @@ |
||||
/* src/test/modules/test_extensions/test_event_trigger--1.0--2.0.sql */ |
||||
-- complain if script is sourced in psql, rather than via ALTER EXTENSION |
||||
\echo Use "ALTER EXTENSION test_event_trigger UPDATE TO '2.0'" to load this file. \quit |
||||
|
||||
-- Test extension upgrade with event trigger. |
||||
ALTER EVENT TRIGGER table_rewrite_trg DISABLE; |
||||
ALTER TABLE t DROP COLUMN id; |
@ -0,0 +1,16 @@ |
||||
/* src/test/modules/test_extensions/test_event_trigger--1.0.sql */ |
||||
-- complain if script is sourced in psql, rather than via CREATE EXTENSION |
||||
\echo Use "CREATE EXTENSION test_event_trigger" to load this file. \quit |
||||
|
||||
-- Base table with event trigger, used in a regression test involving |
||||
-- extension upgrades. |
||||
CREATE TABLE t (id text); |
||||
CREATE OR REPLACE FUNCTION _evt_table_rewrite_fnct() |
||||
RETURNS EVENT_TRIGGER LANGUAGE plpgsql AS |
||||
$$ |
||||
BEGIN |
||||
END; |
||||
$$; |
||||
CREATE EVENT TRIGGER table_rewrite_trg |
||||
ON table_rewrite |
||||
EXECUTE PROCEDURE _evt_table_rewrite_fnct(); |
@ -0,0 +1,3 @@ |
||||
comment = 'Test extension - event trigger' |
||||
default_version = '1.0' |
||||
relocatable = true |
Loading…
Reference in new issue