summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorRobert Haas2013-07-22 14:34:34 +0000
committerRobert Haas2013-07-22 15:09:10 +0000
commitf01d1ae3a104019d6d68aeff85c4816a275130b3 (patch)
treea0fa034de5d28f5eb458bba87c6ed6e5a163bd37 /src/test
parentb3b10c39038c20457ef058c7f4e5589c28a84f1c (diff)
Add infrastructure for mapping relfilenodes to relation OIDs.
Future patches are expected to introduce logical replication that works by decoding WAL. WAL contains relfilenodes rather than relation OIDs, so this infrastructure will be needed to find the relation OID based on WAL contents. If logical replication does not make it into this release, we probably should consider reverting this, since it will add some overhead to DDL operations that create new relations. One additional index insert per pg_class row is not a large overhead, but it's more than zero. Another way of meeting the needs of logical replication would be to the relation OID to WAL, but that would burden DML operations, not only DDL. Andres Freund, with some changes by me. Design review, in earlier versions, by Álvaro Herrera.
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/alter_table.out18
-rw-r--r--src/test/regress/sql/alter_table.sql14
2 files changed, 32 insertions, 0 deletions
diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out
index 18daf95c668..7cc0084b920 100644
--- a/src/test/regress/expected/alter_table.out
+++ b/src/test/regress/expected/alter_table.out
@@ -2305,3 +2305,21 @@ Check constraints:
DROP TABLE alter2.tt8;
DROP SCHEMA alter2;
+-- Check that we map relation oids to filenodes and back correctly.
+-- Don't display all the mappings so the test output doesn't change
+-- all the time, but make sure we actually do test some values.
+SELECT
+ SUM((mapped_oid != oid OR mapped_oid IS NULL)::int) incorrectly_mapped,
+ count(*) > 200 have_mappings
+FROM (
+ SELECT
+ 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;
+ incorrectly_mapped | have_mappings
+--------------------+---------------
+ 0 | t
+(1 row)
+
diff --git a/src/test/regress/sql/alter_table.sql b/src/test/regress/sql/alter_table.sql
index dcf8121d70c..a546ba74af3 100644
--- a/src/test/regress/sql/alter_table.sql
+++ b/src/test/regress/sql/alter_table.sql
@@ -1544,3 +1544,17 @@ ALTER TABLE IF EXISTS tt8 SET SCHEMA alter2;
DROP TABLE alter2.tt8;
DROP SCHEMA alter2;
+
+-- Check that we map relation oids to filenodes and back correctly.
+-- Don't display all the mappings so the test output doesn't change
+-- all the time, but make sure we actually do test some values.
+SELECT
+ SUM((mapped_oid != oid OR mapped_oid IS NULL)::int) incorrectly_mapped,
+ count(*) > 200 have_mappings
+FROM (
+ SELECT
+ 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;