Commit 9613a1d9 authored by Tom Lane's avatar Tom Lane

Improve regression test for pg_filenode_relation().

Make it print the details in case there's a failure.

Andres Freund, slightly modified by me
parent e1827012
...@@ -2319,22 +2319,16 @@ Check constraints: ...@@ -2319,22 +2319,16 @@ 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.
-- Don't display all the mappings so the test output doesn't change -- Only display bad mappings so the test output doesn't change all the
-- all the time, but make sure we actually do test some values. -- time.
SELECT SELECT
SUM((mapped_oid != oid OR mapped_oid IS NULL)::int) incorrectly_mapped, oid, mapped_oid, reltablespace, relfilenode, relname
count(*) > 200 have_mappings FROM pg_class,
FROM ( pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid
SELECT WHERE relkind IN ('r', 'i', 'S', 't', 'm') AND mapped_oid IS DISTINCT FROM oid;
oid, reltablespace, relfilenode, relname, oid | mapped_oid | reltablespace | relfilenode | relname
pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) mapped_oid -----+------------+---------------+-------------+---------
FROM pg_class (0 rows)
WHERE relkind IN ('r', 'i', 'S', 't', 'm')
) mapped;
incorrectly_mapped | have_mappings
--------------------+---------------
0 | t
(1 row)
-- Checks on creating and manipulation of user defined relations in -- Checks on creating and manipulation of user defined relations in
-- pg_catalog. -- pg_catalog.
......
...@@ -1554,18 +1554,13 @@ DROP TABLE alter2.tt8; ...@@ -1554,18 +1554,13 @@ 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.
-- Don't display all the mappings so the test output doesn't change -- Only display bad mappings so the test output doesn't change all the
-- all the time, but make sure we actually do test some values. -- time.
SELECT SELECT
SUM((mapped_oid != oid OR mapped_oid IS NULL)::int) incorrectly_mapped, oid, mapped_oid, reltablespace, relfilenode, relname
count(*) > 200 have_mappings FROM pg_class,
FROM ( pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) AS mapped_oid
SELECT WHERE relkind IN ('r', 'i', 'S', 't', 'm') AND mapped_oid IS DISTINCT FROM oid;
oid, reltablespace, relfilenode, relname,
pg_filenode_relation(reltablespace, pg_relation_filenode(oid)) mapped_oid
FROM pg_class
WHERE relkind IN ('r', 'i', 'S', 't', 'm')
) mapped;
-- Checks on creating and manipulation of user defined relations in -- Checks on creating and manipulation of user defined relations in
-- pg_catalog. -- pg_catalog.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment