BUG #15310: pg_upgrade dissociates event triggers from extensions - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15310: pg_upgrade dissociates event triggers from extensions
Date
Msg-id 153360083872.1395.4593932457718151600@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #15310: pg_upgrade dissociates event triggers from extensions  (Haribabu Kommi <kommi.haribabu@gmail.com>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15310
Logged by:          Nick Barnes
Email address:      nickbarnes01@gmail.com
PostgreSQL version: 10.4
Operating system:   CentOS 7
Description:

Hi,

I have an extension which contains an event trigger. As expected, CREATE
EXTENSION adds a pg_depend entry between the trigger and the extension. But
after running pg_upgrade, this pg_depend entry is gone (and the extension's
CREATE EVENT TRIGGER statement now shows up in the pg_dump output, causing
the restore to fail with an "event trigger already exists" error).

Reproduced for 9.5->9.6 and 9.6->10 upgrades with the attached script.

Did I miss something, or is this a bug? If so, is an ALTER EXTENSION ... ADD
EVENT TRIGGER command on the upgraded database enough to work around it? It
solves my issue, but I'm not sure if there are other symptoms.

Thanks,
Nick Barnes


export PGDATAOLD=~/9.5/data
export PGDATANEW=~/10/data
export PGBINOLD=/usr/pgsql-9.5/bin
export PGBINNEW=/usr/pgsql-10/bin

# Create extension files
cat >$PGBINOLD/../share/extension/event_trigger_test.control <<EOF
default_version = '1.0'
EOF
cat >$PGBINOLD/../share/extension/event_trigger_test--1.0.sql <<EOF
CREATE FUNCTION t() RETURNS event_trigger LANGUAGE plpgsql AS 'BEGIN END';
CREATE EVENT TRIGGER t ON ddl_command_end EXECUTE PROCEDURE t();
EOF
cp $PGBINOLD/../share/extension/event_trigger_test*
$PGBINNEW/../share/extension/

# Set up old server
$PGBINOLD/initdb -D $PGDATAOLD
$PGBINOLD/pg_ctl start -w -D $PGDATAOLD
$PGBINOLD/createdb test
$PGBINOLD/psql test -c "CREATE EXTENSION event_trigger_test"

# Upgrade
$PGBINOLD/pg_ctl stop -D $PGDATAOLD
$PGBINNEW/initdb -D $PGDATANEW
$PGBINNEW/pg_upgrade
$PGBINNEW/pg_ctl start -w -D $PGDATANEW

# Dump/restore
$PGBINNEW/createdb test2
$PGBINNEW/pg_dump test | $PGBINNEW/psql test2 # ERROR: event trigger "t"
already exists


pgsql-bugs by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: BUG #15309: ERROR: catalog is missing 1 attribute(s) for relid760676 when max_parallel_maintenance_workers > 0
Next
From: Amit Langote
Date:
Subject: Re: Fwd: Problem with a "complex" upsert