Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf3fdd25

Browse files
committed
Harden pg_filenode_relation test against concurrent DROP TABLE.
Per buildfarm member prairiedog. Back-patch to 9.4, where the test wasintroduced.Reviewed by Tom Lane.
1 parenta7205d8 commitf3fdd25

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

‎src/test/regress/expected/alter_table.out

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2375,14 +2375,19 @@ Check constraints:
23752375

23762376
DROP TABLE alter2.tt8;
23772377
DROP SCHEMA alter2;
2378-
-- Check that we map relation oids to filenodes and back correctly.
2379-
-- Only display bad mappings so the test output doesn't change all the
2380-
-- time.
2378+
-- Check that we map relation oids to filenodes and back correctly. Only
2379+
-- display bad mappings so the test output doesn't change all the time. A
2380+
-- filenode function call can return NULL for a relation dropped concurrently
2381+
-- with the call's surrounding query, so ignore a NULL mapped_oid for
2382+
-- relations that no longer exist after all calls finish.
2383+
CREATE TEMP TABLE filenode_mapping AS
23812384
SELECT
23822385
oid, mapped_oid, reltablespace, relfilenode, relname
23832386
FROM pg_class,
23842387
pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid
23852388
WHERE relkind IN ('r', 'i', 'S', 't', 'm') AND mapped_oid IS DISTINCT FROM oid;
2389+
SELECT m.* FROM filenode_mapping m LEFT JOIN pg_class c ON c.oid = m.oid
2390+
WHERE c.oid IS NOT NULL OR m.mapped_oid IS NOT NULL;
23862391
oid | mapped_oid | reltablespace | relfilenode | relname
23872392
-----+------------+---------------+-------------+---------
23882393
(0 rows)

‎src/test/regress/sql/alter_table.sql

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1582,15 +1582,21 @@ ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2;
15821582
DROPTABLEalter2.tt8;
15831583
DROPSCHEMA alter2;
15841584

1585-
-- Check that we map relation oids to filenodes and back correctly.
1586-
-- Only display bad mappings so the test output doesn't change all the
1587-
-- time.
1585+
-- Check that we map relation oids to filenodes and back correctly. Only
1586+
-- display bad mappings so the test output doesn't change all the time. A
1587+
-- filenode function call can return NULL for a relation dropped concurrently
1588+
-- with the call's surrounding query, so ignore a NULL mapped_oid for
1589+
-- relations that no longer exist after all calls finish.
1590+
CREATE TEMP TABLE filenode_mappingAS
15881591
SELECT
15891592
oid, mapped_oid, reltablespace, relfilenode, relname
15901593
FROM pg_class,
15911594
pg_filenode_relation(reltablespace, pg_relation_filenode(oid))AS mapped_oid
15921595
WHERE relkindIN ('r','i','S','t','m')AND mapped_oid IS DISTINCTFROMoid;
15931596

1597+
SELECT m.*FROM filenode_mapping mLEFT JOIN pg_class cONc.oid=m.oid
1598+
WHEREc.oidIS NOT NULLORm.mapped_oidIS NOT NULL;
1599+
15941600
-- Checks on creating and manipulation of user defined relations in
15951601
-- pg_catalog.
15961602
--

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp