mirror of
https://github.com/postgres/postgres.git
synced 2025-05-17 06:41:24 +03:00
Harden pg_filenode_relation test against concurrent DROP TABLE.
Per buildfarm member prairiedog. Back-patch to 9.4, where the test was introduced. Reviewed by Tom Lane.
This commit is contained in:
parent
b31218798a
commit
cc3e1553fa
@ -2375,14 +2375,19 @@ Check constraints:
|
|||||||
|
|
||||||
DROP TABLE alter2.tt8;
|
DROP TABLE alter2.tt8;
|
||||||
DROP SCHEMA alter2;
|
DROP SCHEMA alter2;
|
||||||
-- Check that we map relation oids to filenodes and back correctly.
|
-- Check that we map relation oids to filenodes and back correctly. Only
|
||||||
-- Only display bad mappings so the test output doesn't change all the
|
-- display bad mappings so the test output doesn't change all the time. A
|
||||||
-- time.
|
-- filenode function call can return NULL for a relation dropped concurrently
|
||||||
|
-- with the call's surrounding query, so ignore a NULL mapped_oid for
|
||||||
|
-- relations that no longer exist after all calls finish.
|
||||||
|
CREATE TEMP TABLE filenode_mapping AS
|
||||||
SELECT
|
SELECT
|
||||||
oid, mapped_oid, reltablespace, relfilenode, relname
|
oid, mapped_oid, reltablespace, relfilenode, relname
|
||||||
FROM pg_class,
|
FROM pg_class,
|
||||||
pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid
|
pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid
|
||||||
WHERE relkind IN ('r', 'i', 'S', 't', 'm') AND mapped_oid IS DISTINCT FROM oid;
|
WHERE relkind IN ('r', 'i', 'S', 't', 'm') AND mapped_oid IS DISTINCT FROM oid;
|
||||||
|
SELECT m.* FROM filenode_mapping m LEFT JOIN pg_class c ON c.oid = m.oid
|
||||||
|
WHERE c.oid IS NOT NULL OR m.mapped_oid IS NOT NULL;
|
||||||
oid | mapped_oid | reltablespace | relfilenode | relname
|
oid | mapped_oid | reltablespace | relfilenode | relname
|
||||||
-----+------------+---------------+-------------+---------
|
-----+------------+---------------+-------------+---------
|
||||||
(0 rows)
|
(0 rows)
|
||||||
|
@ -1582,15 +1582,21 @@ ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2;
|
|||||||
DROP TABLE alter2.tt8;
|
DROP TABLE alter2.tt8;
|
||||||
DROP SCHEMA alter2;
|
DROP SCHEMA alter2;
|
||||||
|
|
||||||
-- Check that we map relation oids to filenodes and back correctly.
|
-- Check that we map relation oids to filenodes and back correctly. Only
|
||||||
-- Only display bad mappings so the test output doesn't change all the
|
-- display bad mappings so the test output doesn't change all the time. A
|
||||||
-- time.
|
-- filenode function call can return NULL for a relation dropped concurrently
|
||||||
|
-- with the call's surrounding query, so ignore a NULL mapped_oid for
|
||||||
|
-- relations that no longer exist after all calls finish.
|
||||||
|
CREATE TEMP TABLE filenode_mapping AS
|
||||||
SELECT
|
SELECT
|
||||||
oid, mapped_oid, reltablespace, relfilenode, relname
|
oid, mapped_oid, reltablespace, relfilenode, relname
|
||||||
FROM pg_class,
|
FROM pg_class,
|
||||||
pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid
|
pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid
|
||||||
WHERE relkind IN ('r', 'i', 'S', 't', 'm') AND mapped_oid IS DISTINCT FROM oid;
|
WHERE relkind IN ('r', 'i', 'S', 't', 'm') AND mapped_oid IS DISTINCT FROM oid;
|
||||||
|
|
||||||
|
SELECT m.* FROM filenode_mapping m LEFT JOIN pg_class c ON c.oid = m.oid
|
||||||
|
WHERE c.oid IS NOT NULL OR m.mapped_oid IS NOT NULL;
|
||||||
|
|
||||||
-- Checks on creating and manipulation of user defined relations in
|
-- Checks on creating and manipulation of user defined relations in
|
||||||
-- pg_catalog.
|
-- pg_catalog.
|
||||||
--
|
--
|
||||||
|
Loading…
x
Reference in New Issue
Block a user