pgsql: Avoid SIGSEGV in pg_get_database_ddl() on NULL tablespace

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Avoid SIGSEGV in pg_get_database_ddl() on NULL tablespace
Date: 2026-04-30 14:52:33
Message-ID: E1wISki-003TMJ-31@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Avoid SIGSEGV in pg_get_database_ddl() on NULL tablespace

There is a narrow race in which a concurrent ALTER DATABASE ... SET
TABLESPACE moves the database off the tablespace and a DROP TABLESPACE
removes it between the syscache lookup and the catalog scan. If that
happens, output an error.

Author: Chao Li <lic(at)highgo(dot)com>
Reviewed-by: Jack Bonatakis <jack(at)bonatak(dot)is>
Reviewed-by: Satyanarayana Narlapuram <satyanarlapuram(at)gmail(dot)com>
Reviewed-by: Japin Li <japinli(at)hotmail(dot)com>
Discussion: https://postgr.es/m/573E45C1-31A4-4885-A00C-1A2171159A2A@gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/5642a0367c2fe69684800c5d5c5929c20d99ef72

Modified Files
--------------
src/backend/utils/adt/ddlutils.c | 7 +++++++
1 file changed, 7 insertions(+)

Browse pgsql-committers by date

  From Date Subject
Next Message Andrew Dunstan 2026-04-30 15:17:29 pgsql: Fix attnum remapping in generateClonedExtStatsStmt()
Previous Message Daniel Gustafsson 2026-04-30 11:46:35 pgsql: Fix data_checksum GUC show_hook