[PATCH 03/16] Add a new syscache to fetch a pg_class entry via its relfilenode - Mailing list pgsql-hackers

From Andres Freund
Subject [PATCH 03/16] Add a new syscache to fetch a pg_class entry via its relfilenode
Date
Msg-id 1339586927-13156-3-git-send-email-andres@2ndquadrant.com
Whole thread Raw
In response to [RFC][PATCH] Logical Replication/BDR prototype and architecture  (Andres Freund <andres@2ndquadrant.com>)
Responses Re: [PATCH 03/16] Add a new syscache to fetch a pg_class entry via its relfilenode
List pgsql-hackers
From: Andres Freund <andres@anarazel.de>

This patch is problematic because formally indexes used by syscaches needs to
be unique, this one is not though because of 0/InvalidOids entries for
nailed/shared catalog entries. Those values aren't allowed to be queried though.

It might be nicer to add infrastructure to do this properly, I just don't have
a clue what the best way for this would be.
---src/backend/utils/cache/syscache.c |   11 +++++++++++src/include/catalog/indexing.h     |    2
++src/include/utils/syscache.h      |    1 +3 files changed, 14 insertions(+)
 

diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c
index c365ec7..9cfb013 100644
--- a/src/backend/utils/cache/syscache.c
+++ b/src/backend/utils/cache/syscache.c
@@ -588,6 +588,17 @@ static const struct cachedesc cacheinfo[] = {        },        1024    },
+    {RelationRelationId,        /* RELFILENODE */
+        ClassRelfilenodeIndexId,
+        1,
+        {
+            Anum_pg_class_relfilenode,
+            0,
+            0,
+            0
+        },
+        1024
+    },    {RewriteRelationId,            /* RULERELNAME */        RewriteRelRulenameIndexId,        2,
diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h
index 450ec25..5c9419b 100644
--- a/src/include/catalog/indexing.h
+++ b/src/include/catalog/indexing.h
@@ -106,6 +106,8 @@ DECLARE_UNIQUE_INDEX(pg_class_oid_index, 2662, on pg_class using btree(oid oid_o#define
ClassOidIndexId 2662DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index, 2663, on pg_class using btree(relname name_ops,
relnamespaceoid_ops));#define ClassNameNspIndexId  2663
 
+DECLARE_INDEX(pg_class_relfilenode_index, 2844, on pg_class using btree(relfilenode oid_ops));
+#define ClassRelfilenodeIndexId  2844DECLARE_UNIQUE_INDEX(pg_collation_name_enc_nsp_index, 3164, on pg_collation using
btree(collnamename_ops, collencoding int4_ops, collnamespace oid_ops));#define CollationNameEncNspIndexId 3164
 
diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h
index d59dd4e..63a5042 100644
--- a/src/include/utils/syscache.h
+++ b/src/include/utils/syscache.h
@@ -73,6 +73,7 @@ enum SysCacheIdentifier    RANGETYPE,    RELNAMENSP,    RELOID,
+    RELFILENODE,    RULERELNAME,    STATRELATTINH,    TABLESPACEOID,
-- 
1.7.10.rc3.3.g19a6c.dirty



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: [RFC][PATCH] Logical Replication/BDR prototype and architecture
Next
From: Andres Freund
Date:
Subject: [PATCH 02/16] Add zeroRecPtr as a shortcut for initializing a local variable to {0, 0}