BUG #19954: pg_upgrade fails to handle foreign data wrapper and event trigger when their owner demoted

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: exclusion(at)gmail(dot)com
Subject: BUG #19954: pg_upgrade fails to handle foreign data wrapper and event trigger when their owner demoted
Date: 2026-11-28 12:00:00
Message-ID: 19954-5635d15b1b658713@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19954
Logged by: Alexander Lakhin
Email address: exclusion(at)gmail(dot)com
PostgreSQL version: 19.0
Operating system: Ubuntu 24.04
Description:

A database with the following contents:
echo "CREATE DATABASE regression;
\connect regression

CREATE ROLE regress_test_role_super SUPERUSER;
CREATE FOREIGN DATA WRAPPER foo1;
ALTER FOREIGN DATA WRAPPER foo1 OWNER TO regress_test_role_super;
ALTER ROLE regress_test_role_super NOSUPERUSER;
" > /tmp/db.sql

can't be processed by pg_upgrade, e.g., executed with:
olddump=/tmp/db.sql oldinstall=`pwd`/tmp_install/usr/local/pgsql
PROVE_TESTS="t/002*" make -s check -C src/bin/pg_upgrade/
due to:
# Restoring global objects in the new cluster ok
# Restoring database schemas in the new cluster
# *failure*
#
# Consult the last few lines of
".../src/bin/pg_upgrade/tmp_check/t_002_pg_upgrade_new_node_data/pgdata/pg_upgrade_output.d/20261128T130855.919/log/pg_upgrade_dump_16384.log"
for
# the probable cause of the failure.
# Failure, exiting

tail .../pg_upgrade_dump_16384.log
pg_restore: creating FOREIGN DATA WRAPPER "foo1"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 2093; 2328 16386 FOREIGN DATA WRAPPER foo1
regress_test_role_super
pg_restore: error: could not execute query: ERROR: permission denied to
change owner of foreign-data wrapper "foo1"
HINT: The owner of a foreign-data wrapper must be a superuser.
Command was: ALTER FOREIGN DATA WRAPPER foo1 OWNER TO
regress_test_role_super;

The same is observed with event triggers:
echo "CREATE DATABASE regression;
\connect regression

CREATE ROLE regress_test_role_super SUPERUSER;
SET ROLE regress_test_role_super;
CREATE FUNCTION regress_et() RETURNS event_trigger LANGUAGE plpgsql AS
'BEGIN END;';
CREATE EVENT TRIGGER regress_et ON ddl_command_start EXECUTE FUNCTION
regress_et();
RESET ROLE;
ALTER ROLE regress_test_role_super NOSUPERUSER;
" > /tmp/db.sql

olddump=/tmp/db.sql oldinstall=`pwd`/tmp_install/usr/local/pgsql
PROVE_TESTS="t/002*" make -s check -C src/bin/pg_upgrade/
...
# Restoring database schemas in the new cluster
# *failure*
#
# Consult the last few lines of
".../src/bin/pg_upgrade/tmp_check/t_002_pg_upgrade_new_node_data/pgdata/pg_upgrade_output.d/20261128T131638.415/log/pg_upgrade_dump_16384.log"
for
# the probable cause of the failure.
# Failure, exiting

tail .../pg_upgrade_dump_16384.log
pg_restore: creating EVENT TRIGGER "regress_et"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3356; 3466 16387 EVENT TRIGGER regress_et
regress_test_role_super
pg_restore: error: could not execute query: ERROR: permission denied to
change owner of event trigger "regress_et"
HINT: The owner of an event trigger must be a superuser.
Command was: ALTER EVENT TRIGGER regress_et OWNER TO
regress_test_role_super;

Reproduced on REL_15_STABLE .. master. The first case is discovered by
Bohyun Lee.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Zsolt Parragi 2026-11-28 12:13:58 Re: pg_rewind WAL segments deletion pitfall
Previous Message Michael Paquier 2026-11-28 07:53:44 Re: BUG #19890: pg_receivewal advances past a truncated LZ4 WAL segment