Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x8raM-00000001YrX-2Foh for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Sep 2026 03:54:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1x8raL-0000000DFYd-2yzj for pgsql-hackers@arkaria.postgresql.org; Tue, 22 Sep 2026 03:54:25 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1x8raL-0000000DFYU-1Seo for pgsql-hackers@lists.postgresql.org; Tue, 22 Sep 2026 03:54:25 +0000 Received: from mail-vs2-x10.google.com ([2a00:1450:4864:3a::10]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1x8raI-00000000dM9-3BVk for pgsql-hackers@lists.postgresql.org; Tue, 22 Sep 2026 03:54:25 +0000 Received: by mail-vs2-x10.google.com with SMTP id 71dfb90a1353d-5c6560f7a78so132118e0c.3 for ; Mon, 21 Sep 2026 20:54:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1790049261; x=1790654061; darn=lists.postgresql.org; h=content-type:mime-version:references:in-reply-to:message-id:date :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to :content-type; bh=pWYNHiE+JQVAZ4Ypkub9XGY6GV9rhWi/1BCz91wcFgU=; b=kpKQMXnr+EbJL8eNXtRgNJ8gAueQ/Es83UJmYZ8oE6uIYyGPIT/f8nDrVdxtyUrdmg 1XBI/WDH0VYJ6V/QeSumjq7OmQ4srT7cNhfnO7Derty3xZUpkR9Cuj0pKgrEyaMGKUFW MwKWmGRdgieqj0KuoyqVCC0gDMJ7Wn5iYQ9bT9sTjDSf4Fj9oaZSuvwSipQiNbaHgkjW apbHPCAWR0fQ2kTTrM9TrkUX5em+vnn/1B3VFgh7hlLIxEtzCfmPDr8xg3CUP0bUTwcC LdthPQNRNhD2+nNQ0W5bkxLLs596HRJXl5XpYRIWQO1Xu/KnUTCTIpGIITXzSJcteFh/ TzqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1790049261; x=1790654061; h=content-type:mime-version:references:in-reply-to:message-id:date :subject:cc:to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject :date:message-id:reply-to:content-type; bh=pWYNHiE+JQVAZ4Ypkub9XGY6GV9rhWi/1BCz91wcFgU=; b=crMG/vKKQRvfQLrMJgZOcwRADy9pnagpSwt+CN6F8I+Xdx0wcxL5K3XElxlU+C8FCg zWbqtbLzEAhUw0yo1r83Ib39xQnCumSvQ3w0ZssjyO4pEVKLdKkbefgyFsA1ZzDGIEOp OO8/MZA4IHWtBkTv5GHFIMxkEgz/lNdEXevybaARf0z0y/gmGaxxBycRO5Sysi2zFGfX jGAkcuTdCbrw+NKSO4/p9YI3o+Dtn7xMhLKntSjmXZ5hIssaE6iOyjq+zNbBAfANYkwW XsHntdRkXkggbTptOoykV5h1iwSZfJDIr8E5QB7VfYr7BgtD84SrdaVVmXcNBK5B/svr H2jA== X-Gm-Message-State: AFuF++nsjbOmj97p1fT7XH1mVBYUEdIy4wjab+fKt1bYFTWSzavwJRlF BAmQwZAHRa2U6WBnpg4W5lPpZStfjxYQoGGdOJ5g66inZQQZDpDSr+eZvYE8xyYMVPo= X-Gm-Gg: AYBFou1jvVYgL3sBoyKQiXRji924gjwsw2Q8J4TCIz7eaInODjKSwDwhUaFWP9GTzQV o5b8gBiFdIBrpMdqiFXPvTyHafKd6CPhmkX7I6BiNjTRt2gUMsHbCa9JM8iikbfMXIFmEpBXg4h by8OL0C3+M229QltIA04inN/+8OkWPhhJLR63Elf4GN8/jbjPm6lKK1sq6UujaC2fOkDfsU15mr 105h7uHXwMLhWsghawGkvedElg7Y+14v0datCMmwXN7GUwEQ9vZPOnGmDwl8IGcSGktYIx1K3T+ 9Hw5H9AmBN8PXVfEBbdz75UloxJJ/ByV6uAMpgBB9szFsWSog63R+TAu69/0PVddwARuFmrYh8O MlNKm6dw9KqTN4I1cp8meYmRMgRAflU0jZgEWwkJ++eX9wevt7xupfGzfgNRlwC9ubKeB65rf62 eWAkllbVlevYUYQy1zexhBIt87Zb83rkI5vmyf6c9kQ1rjz0nN9qHaf+ravPbCMtBxpGjxKXv12 bbeGWy5WyWewILia6CTGBQYecmEq6t2eIe1SfXszynqjZn5jiaB9E3T4LuzCEs43h5+LyaQ9ick AN+fVrTxM6Re73T02euAE8aMKA== X-Received: by 2002:a05:6122:e010:10b0:5c9:9faf:180b with SMTP id 71dfb90a1353d-5c9b8aa975bmr5947134e0c.2.1790049261023; Mon, 21 Sep 2026 20:54:21 -0700 (PDT) Received: from 192.168.1.109 ([2803:3c90:cee:ea00:5c3c:7e70:29e3:7a55]) by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5c9e7d32e7csm506068e0c.11.2026.09.21.20.54.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2026 20:54:20 -0700 (PDT) From: Manu To: pgsql-hackers@lists.postgresql.org Cc: Marko Grujic , Marko Grujic , Michael Paquier Subject: Re: Temp schema drop leaves an inconsistent state behind Date: Tue, 22 Sep 2026 00:54:17 -0300 Message-ID: <179004925704.353107.8509591474906479967@gmail.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============3251726071259558321==" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --===============3251726071259558321== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi Marko, Marko Grujic wrote: > The reason it wasn't re-created is because the internal static variable > (myTempNamespace) is left holding the 16409 value internally. This came up in 2019-2020 [1]. a052f6cbb84 forbade DROP SCHEMA on temp schemas and was reverted (65192e02441) after Robert and Tom argued that a superuser should be able to do it, and that code should cope with a missing schema instead of crashing; 80d76be51cf then fixed autovacuum that way. Michael pointed out the stale myTempNamespace in that thread, but it was left as is, so your patches fill that gap in the direction agreed there. (Cc'ing Michael for that reason.) I tested them on master d39fda1cc40, with --enable-cassert, and master without them as the control. Both reported problems are fixed, and 0002 covers more than tables. After dropping the own temp schema, on master CREATE DOMAIN, CREATE FUNCTION and CREATE STATISTICS in pg_temp fail with "referenced schema was concurrently dropped", while a composite type and a temp table with a serial column and an index are created in the missing schema: 9 rows in pg_class and pg_type point to it. With 0002, everything is created and nothing is left dangling. The same when anot= her superuser session drops the schema: on master that session leaves a pg_class row with a missing schema behind when it exits; with 0002, it doesn't. About 0001: the strlist_to_textarray() part is worth a line in the commit message, because on master a NULL name is silently dropped from the array, and that is worse than it looks. With a table whose pg_namespace row is gone (I deleted it with allow_system_table_mods) and another table of the same name in public, pg_get_object_address('table', (pg_identify_object_as_address('pg_class'::regclass, oid, 0)).object_= names, '{}') resolves to public.x on master. With 0001 the names are {NULL,x} and it fails with "name or argument lists may not contain nulls". On master, pg_identify_object() on that table crashes too, as in your report. One problem with 0002: if the DROP SCHEMA is rolled back, the session loses its temp schema, and the next temp table empties it. CREATE TEMP TABLE keep(a int); INSERT INTO keep VALUES (1), (2), (3); BEGIN; DROP SCHEMA pg_temp_0 CASCADE; CREATE TEMP TABLE t3(a int); ROLLBACK; SELECT count(*) FROM keep; ERROR: relation "keep" does not exist keep is still in pg_class, in pg_temp_0, but pg_my_temp_schema() is 0, pg_temp is gone from the search path, and "SELECT * FROM pg_temp_0.keep" fails with "cannot access temporary tables of other sessions". The next CREATE TEMP TABLE goes through InitTempTableNamespace(), finds pg_temp_0, takes it for a crashed backend's leftover, and RemoveTempRelations() drops keep. It's the same with ROLLBACK TO SAVEPOINT. On master, keep still has its 3 rows in both cases. Nothing undoes the reset in AccessTempTableNamespace() on abort: AtEOXact_Namespace() sees the myTempNamespaceSubID set by the new InitTempTableNamespace() and forgets the new schema, but nothing brings back the old one. The attached diff, on top of 0002, remembers the forgotten schema and the subtransaction that forgot it, and puts it back if that subtransaction aborts, unless the schema was created in it; on subtransaction commit it moves to the parent, like myTempNamespaceSubID. If the drop was committed earlier, what it puts back is still stale, and the next access forgets it again. The diff adds both rollback cases to your test in temp.sql, which fails with 0002 alone. With it, those two cases behave as on master, and so do these: - a temp schema created, dropped and rolled back in one transaction - a committed drop, then an aborted CREATE TEMP TABLE, then another - a drop undone by ROLLBACK TO an outer savepoint, with a savepoint released in between - a drop released from a savepoint, then the whole transaction rolled back 0002 alone loses keep in the last two. make check (239) and isolation (133) pass with 0001 and 0002, and with the diff on top; pgindent leaves it unchanged. The attached temp_schema_drop_cases.sql has all of the above as a plain psql script, one case per session, with what each should return. Case 8 deletes a pg_namespace row, so it is meant for a scratch database. On master cases 1, 5 and 8 fail (8 by crashing, as the last statement), with 0001 and 0002 cases 2, 3, 6 and 7, and with the diff none. [1] https://www.postgresql.org/message-id/CAKYtNAr9Zq%3D1-ww4etHo-VCC-k120YxZ= y5OS01VkaLPaDbv2tg%40mail.gmail.com Regards, Manu --===============3251726071259558321== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="nocfbot-restore-temp-namespace-on-abort.diff.txt" MIME-Version: 1.0 diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index f2480509e80..9d2053a9d50 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -207,6 +207,17 @@ static SubTransactionId myTempNamespaceSubID =3D Invalid= SubTransactionId; /* Have we registered RemoveTempRelationsCallback for this session yet? */ static bool myTempNamespaceCleanupRegistered =3D false; =20 +/* + * The temp namespace we forgot because it seemed to be gone, and the + * subtransaction in which we did that. If that subtransaction aborts, the + * DROP SCHEMA that made it disappear may be rolled back with it, so we go + * back to the namespace we had. + */ +static Oid forgottenTempNamespace =3D InvalidOid; +static Oid forgottenTempToastNamespace =3D InvalidOid; +static SubTransactionId forgottenTempNamespaceCreateSubID =3D InvalidSubTran= sactionId; +static SubTransactionId forgottenTempNamespaceSubID =3D InvalidSubTransactio= nId; + /* * This is the user's textual search path specification --- it's the value * of the GUC variable 'search_path'. @@ -4451,6 +4462,14 @@ AccessTempTableNamespace(bool force) !SearchSysCacheExists1(NAMESPACEOID, ObjectIdGetDatum(myTempNamespace))) { + if (forgottenTempNamespaceSubID =3D=3D InvalidSubTransactionId) + { + forgottenTempNamespace =3D myTempNamespace; + forgottenTempToastNamespace =3D myTempToastNamespace; + forgottenTempNamespaceCreateSubID =3D myTempNamespaceSubID; + forgottenTempNamespaceSubID =3D GetCurrentSubTransactionId(); + } + myTempNamespace =3D InvalidOid; myTempToastNamespace =3D InvalidOid; myTempNamespaceSubID =3D InvalidSubTransactionId; @@ -4600,6 +4619,32 @@ InitTempTableNamespace(void) searchPathCacheValid =3D false; } =20 +/* + * Go back to the temp namespace that AccessTempTableNamespace() forgot, + * because the (sub)transaction that forgot it, abortingSubid, is aborting. + * If that namespace was created within abortingSubid, its creation is being + * rolled back too, and there is nothing to go back to. + */ +static void +RestoreForgottenTempNamespace(SubTransactionId abortingSubid) +{ + if (forgottenTempNamespaceCreateSubID =3D=3D InvalidSubTransactionId || + forgottenTempNamespaceCreateSubID < abortingSubid) + { + myTempNamespace =3D forgottenTempNamespace; + myTempToastNamespace =3D forgottenTempToastNamespace; + myTempNamespaceSubID =3D forgottenTempNamespaceCreateSubID; + MyProc->tempNamespaceId =3D forgottenTempNamespace; + baseSearchPathValid =3D false; /* need to rebuild list */ + searchPathCacheValid =3D false; + } + + forgottenTempNamespace =3D InvalidOid; + forgottenTempToastNamespace =3D InvalidOid; + forgottenTempNamespaceCreateSubID =3D InvalidSubTransactionId; + forgottenTempNamespaceSubID =3D InvalidSubTransactionId; +} + /* * End-of-transaction cleanup for namespaces. */ @@ -4646,6 +4691,18 @@ AtEOXact_Namespace(bool isCommit, bool parallel) myTempNamespaceSubID =3D InvalidSubTransactionId; } =20 + if (forgottenTempNamespaceSubID !=3D InvalidSubTransactionId && !parallel) + { + if (isCommit) + { + forgottenTempNamespace =3D InvalidOid; + forgottenTempToastNamespace =3D InvalidOid; + forgottenTempNamespaceCreateSubID =3D InvalidSubTransactionId; + forgottenTempNamespaceSubID =3D InvalidSubTransactionId; + } + else + RestoreForgottenTempNamespace(TopSubTransactionId); + } } =20 /* @@ -4686,6 +4743,18 @@ AtEOSubXact_Namespace(bool isCommit, SubTransactionId = mySubid, MyProc->tempNamespaceId =3D InvalidOid; } } + + if (forgottenTempNamespaceSubID =3D=3D mySubid) + { + if (isCommit) + { + forgottenTempNamespaceSubID =3D parentSubid; + if (forgottenTempNamespaceCreateSubID =3D=3D mySubid) + forgottenTempNamespaceCreateSubID =3D parentSubid; + } + else + RestoreForgottenTempNamespace(mySubid); + } } =20 /* diff --git a/src/test/regress/expected/temp.out b/src/test/regress/expected/t= emp.out index 476e312e352..92b61c09e25 100644 --- a/src/test/regress/expected/temp.out +++ b/src/test/regress/expected/temp.out @@ -601,3 +601,38 @@ SELECT count(*) AS orphans FROM pg_class c 0 (1 row) =20 +-- if the drop is rolled back, the session keeps its temp schema and tables +INSERT INTO test_temp_t3 VALUES (1), (2), (3); +SELECT pg_my_temp_schema()::regnamespace AS mytempschema \gset +BEGIN; +DROP SCHEMA :mytempschema CASCADE; +NOTICE: drop cascades to table test_temp_t3 +CREATE TEMP TABLE test_temp_t4(f1 int); +ROLLBACK; +SELECT count(*) FROM test_temp_t3; + count=20 +------- + 3 +(1 row) + +BEGIN; +SAVEPOINT sp; +DROP SCHEMA :mytempschema CASCADE; +NOTICE: drop cascades to table test_temp_t3 +CREATE TEMP TABLE test_temp_t4(f1 int); +ROLLBACK TO sp; +CREATE TEMP TABLE test_temp_t5(f1 int); +COMMIT; +SELECT count(*) FROM test_temp_t3; + count=20 +------- + 3 +(1 row) + +SELECT pg_my_temp_schema()::regnamespace =3D :'mytempschema'::regnamespace + AS same_temp_schema; + same_temp_schema=20 +------------------ + t +(1 row) + diff --git a/src/test/regress/sql/temp.sql b/src/test/regress/sql/temp.sql index 7d7e18ce8c8..95e41865242 100644 --- a/src/test/regress/sql/temp.sql +++ b/src/test/regress/sql/temp.sql @@ -439,3 +439,22 @@ SELECT EXISTS (SELECT 1 FROM pg_namespace WHERE oid =3D = pg_my_temp_schema()) AS temp_schema_exists; SELECT count(*) AS orphans FROM pg_class c WHERE NOT EXISTS (SELECT 1 FROM pg_namespace n WHERE n.oid =3D c.relname= space); + +-- if the drop is rolled back, the session keeps its temp schema and tables +INSERT INTO test_temp_t3 VALUES (1), (2), (3); +SELECT pg_my_temp_schema()::regnamespace AS mytempschema \gset +BEGIN; +DROP SCHEMA :mytempschema CASCADE; +CREATE TEMP TABLE test_temp_t4(f1 int); +ROLLBACK; +SELECT count(*) FROM test_temp_t3; +BEGIN; +SAVEPOINT sp; +DROP SCHEMA :mytempschema CASCADE; +CREATE TEMP TABLE test_temp_t4(f1 int); +ROLLBACK TO sp; +CREATE TEMP TABLE test_temp_t5(f1 int); +COMMIT; +SELECT count(*) FROM test_temp_t3; +SELECT pg_my_temp_schema()::regnamespace =3D :'mytempschema'::regnamespace + AS same_temp_schema; --===============3251726071259558321== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="temp_schema_drop_cases.sql.txt" MIME-Version: 1.0 -- Cases around DROP SCHEMA of the session's own pg_temp_N. -- Run as a superuser in a scratch database: psql -X -f temp_schema_drop_cas= es.sql -- Each case starts a new session (\c -). "expected" is master's behavior, -- or what should happen where master is broken. \set VERBOSITY terse \pset footer off \echo \echo =3D=3D 1. drop committed, then other temp objects \echo expected: all created, nothing pointing to a missing schema \echo (master: errors, and rows left in pg_class/pg_type) \c - CREATE TEMP TABLE z(a int); SELECT pg_my_temp_schema()::regnamespace AS s \gset DROP SCHEMA :s CASCADE; CREATE TYPE pg_temp.ty AS (a int); CREATE DOMAIN pg_temp.dom AS int; CREATE FUNCTION pg_temp.eq3(int, int) RETURNS bool LANGUAGE sql AS 'SELECT $1= =3D $2'; CREATE OPERATOR pg_temp.=3D=3D=3D (LEFTARG =3D int, RIGHTARG =3D int, FUNCTIO= N =3D pg_temp.eq3); CREATE TEMP TABLE ser(id serial PRIMARY KEY, b int); CREATE INDEX ON ser(b); CREATE STATISTICS pg_temp.st ON id, b FROM ser; SELECT EXISTS (SELECT 1 FROM pg_namespace WHERE oid =3D pg_my_temp_schema()) = AS temp_schema_exists, (SELECT count(*) FROM pg_class c WHERE NOT EXISTS (SELECT 1 FROM pg_na= mespace n WHERE n.oid =3D c.relnamespace)) AS dangling_class, (SELECT count(*) FROM pg_type t WHERE NOT EXISTS (SELECT 1 FROM pg_nam= espace n WHERE n.oid =3D t.typnamespace)) AS dangling_type; \echo \echo =3D=3D 2. drop rolled back \echo expected: keep has 3 rows, before and after the next CREATE TEMP TAB= LE \c - CREATE TEMP TABLE keep(a int); INSERT INTO keep VALUES (1), (2), (3); SELECT pg_my_temp_schema()::regnamespace AS s \gset BEGIN; DROP SCHEMA :s CASCADE; CREATE TEMP TABLE t(a int); ROLLBACK; SELECT count(*) AS keep_rows FROM keep; CREATE TEMP TABLE t2(a int); SELECT count(*) AS keep_rows FROM keep; \echo \echo =3D=3D 3. drop undone by ROLLBACK TO SAVEPOINT \echo expected: keep has 3 rows, before and after the next CREATE TEMP TAB= LE \c - CREATE TEMP TABLE keep(a int); INSERT INTO keep VALUES (1), (2), (3); SELECT pg_my_temp_schema()::regnamespace AS s \gset BEGIN; SAVEPOINT sp; DROP SCHEMA :s CASCADE; CREATE TEMP TABLE t(a int); ROLLBACK TO sp; COMMIT; SELECT count(*) AS keep_rows FROM keep; CREATE TEMP TABLE t2(a int); SELECT count(*) AS keep_rows FROM keep; \echo \echo =3D=3D 4. temp schema created, dropped and rolled back in one transacti= on \echo expected: c has 1 row, temp schema exists \c - BEGIN; CREATE TEMP TABLE a(x int); SELECT pg_my_temp_schema()::regnamespace AS s \gset DROP SCHEMA :s CASCADE; CREATE TEMP TABLE b(x int); ROLLBACK; CREATE TEMP TABLE c(x int); INSERT INTO c VALUES (1); SELECT count(*) AS c_rows, EXISTS (SELECT 1 FROM pg_namespace WHERE oid =3D pg_my_temp_schema()) = AS temp_schema_exists; \echo \echo =3D=3D 5. drop committed, then an aborted CREATE TEMP TABLE, then anoth= er \echo expected: c has 1 row, temp schema exists (master: it doesn't) \c - CREATE TEMP TABLE a(x int); SELECT pg_my_temp_schema()::regnamespace AS s \gset DROP SCHEMA :s CASCADE; BEGIN; CREATE TEMP TABLE b(x int); ROLLBACK; CREATE TEMP TABLE c(x int); INSERT INTO c VALUES (1); SELECT count(*) AS c_rows, EXISTS (SELECT 1 FROM pg_namespace WHERE oid =3D pg_my_temp_schema()) = AS temp_schema_exists; \echo \echo =3D=3D 6. drop undone by ROLLBACK TO an outer savepoint, a savepoint re= leased in between \echo expected: keep has 3 rows \c - CREATE TEMP TABLE keep(x int); INSERT INTO keep VALUES (1), (2), (3); SELECT pg_my_temp_schema()::regnamespace AS s \gset BEGIN; SAVEPOINT a; SAVEPOINT b; DROP SCHEMA :s CASCADE; SAVEPOINT c; CREATE TEMP TABLE t(x int); RELEASE c; ROLLBACK TO b; CREATE TEMP TABLE t2(x int); COMMIT; SELECT count(*) AS keep_rows FROM keep; \echo \echo =3D=3D 7. drop released from a savepoint, then the transaction rolled b= ack \echo expected: keep has 3 rows, before and after the next CREATE TEMP TAB= LE \c - CREATE TEMP TABLE keep(x int); INSERT INTO keep VALUES (1), (2), (3); SELECT pg_my_temp_schema()::regnamespace AS s \gset BEGIN; SAVEPOINT a; DROP SCHEMA :s CASCADE; CREATE TEMP TABLE t(x int); RELEASE a; ROLLBACK; SELECT count(*) AS keep_rows FROM keep; CREATE TEMP TABLE t3(x int); SELECT count(*) AS keep_rows FROM keep; \echo \echo =3D=3D 8. a table whose pg_namespace row is gone, and a same-named tabl= e in public \echo expected: no crash; the round trip must not land on public.x \echo (master: pg_identify_object crashes, and the round trip returns publ= ic.x) \echo This one deletes a catalog row: run it in a database you can throw a= way. \c - CREATE SCHEMA gone; CREATE TABLE gone.x(a int); CREATE TABLE public.x(b text); SELECT oid AS xoid FROM pg_class WHERE relnamespace =3D 'gone'::regnamespace = AND relname =3D 'x' \gset SET allow_system_table_mods =3D on; DELETE FROM pg_namespace WHERE nspname =3D 'gone'; RESET allow_system_table_mods; SELECT :xoid AS gone_x_oid, 'public.x'::regclass::oid AS public_x_oid; SELECT (pg_identify_object_as_address('pg_class'::regclass, :xoid, 0)).object= _names; SELECT objid AS round_trip_oid FROM pg_get_object_address('table', (pg_identify_object_as_address('pg_class'::regclass, :xoid, 0)).obje= ct_names, '{}'); SELECT pg_identify_object('pg_class'::regclass, :xoid, 0); --===============3251726071259558321==--