pgsql: Fix two crashes on a concurrently dropped schema

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix two crashes on a concurrently dropped schema
Date: 2026-10-31 11:47:29
Message-ID: E1xN7YX-00000001WzN-0GdW@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix two crashes on a concurrently dropped schema

pg_identify_object() looks up the object's schema name without a lock
on the schema, so a concurrent DROP SCHEMA can make get_namespace_name()
return NULL, which was then passed to quote_identifier(). Report the
schema as NULL instead, as is already done for objects that have gone
away.

Similarly, schema_to_xml() and the related SQL/XML functions look up
the schema name without a lock on the schema, and a concurrent DROP
SCHEMA can make get_namespace_name() return NULL, which was then
dereferenced. Report that the schema does not exist, or skip it when
mapping all schemas of the database.

Author: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
Discussion: https://www.postgresql.org/message-id/CA+fm-RPD0m9QL8W+804SGBBxn5iFz5wn=kncaP9SkM-s4PUANw@mail.gmail.com
Backpatch-through: 14

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/77705d1e5a616339c3e92f586bbfa7b6bb562beb

Modified Files
--------------
src/backend/catalog/objectaddress.c | 13 +++++++-----
src/backend/utils/adt/xml.c | 40 ++++++++++++++++++++++++++++++-------
2 files changed, 41 insertions(+), 12 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Previous Message Heikki Linnakangas 2026-10-31 11:01:03 pgsql: Fix PL/pgSQL error message on EOF in the middle of an expression