BUG #19934: pg_upgrade can't handle "interesting" user-defined system relation

Started by PG Bug reporting form5 days ago2 messagesbugs

Thread notes

1 note#bug#not-a-bug
hackorum-bot#bug#not-a-bug
hackorum-bot
2 days ago

@global #bug #not-a-bug

#bug#not-a-bug
Jump to latest
#1PG Bug reporting form
noreply@postgresql.org

The following bug has been logged on the website:

Bug reference: 19934
Logged by: Alexander Lakhin
Email address: exclusion@gmail.com
PostgreSQL version: 19.0
Operating system: Ubuntu 24.04
Description:

A database with the following contents:
echo "CREATE DATABASE regression;
\connect regression
--- Borrowed from src/test/regress/sql/alter_table.sql
CREATE TABLE new_system_table(id serial primary key, othercol text);
ALTER TABLE new_system_table SET SCHEMA pg_catalog;

-- Tables needed for the version-adaptation step
CREATE TABLE brintest (lsncol pg_lsn);
CREATE TABLE tab_core_types (pg_lsn pg_lsn);
CREATE TABLE brintest_multi (lsncol pg_lsn);
CREATE TABLE brintest_bloom (lsncol pg_lsn);
" > /tmp/db18.sql

can't be upgraded from v18, e.g. with:
olddump=/tmp/db18.sql oldinstall=/tmp/pg18 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/20261123T215735.050/log/pg_upgrade_dump_16384.log"
for
# the probable cause of the failure.
# Failure, exiting

cat
".../src/bin/pg_upgrade/tmp_check/t_002_pg_upgrade_new_node_data/pgdata/pg_upgrade_output.d/20261123T215735.050/log/pg_upgrade_dump_16384.log"
...
pg_restore: processing data for table "pg_catalog.pg_shdepend"
pg_restore: while PROCESSING TOC:
pg_restore: from TOC entry 3518; 0 0 STATISTICS DATA new_system_table_pkey
(no owner)
pg_restore: error: could not execute query: ERROR: relation
"pg_catalog.new_system_table_pkey" does not exist
Command was: SELECT * FROM pg_catalog.pg_restore_relation_stats(
'version', '180007'::integer,
'schemaname', 'pg_catalog',
'relname', 'new_system_table_pkey',
'relpages', '1'::integer,
'reltuples', '0'::real,
'relallvisible', '0'::integer,
'relallfrozen', '0'::integer
);

An alternative way to reproduce this failure:
sed -i '/^ALTER TABLE new_system_table SET SCHEMA public;$/,/^DROP TABLE
old_system_table;$/d' src/test/regress/sql/alter_table.sql
src/test/regress/expected/alter_table.out
PROVE_TESTS="t/002*" make -s check -C src/bin/pg_upgrade/

allows to pin-point a commit that introduced it: 1fd1bd871.

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: PG Bug reporting form (#1)
Re: BUG #19934: pg_upgrade can't handle "interesting" user-defined system relation

PG Bug reporting form <noreply@postgresql.org> writes:

A database with the following contents:
echo "CREATE DATABASE regression;
\connect regression
--- Borrowed from src/test/regress/sql/alter_table.sql
CREATE TABLE new_system_table(id serial primary key, othercol text);
ALTER TABLE new_system_table SET SCHEMA pg_catalog;

I don't think we've ever regarded that as a supported thing to do.

regards, tom lane