This cache is somewhat problematic because formally indexes used by syscaches needs to be unique, this one is not. This is "just" because of 0/InvalidOids stored in pg_class.relfilenode for nailed/shared catalog relations. The syscache will never be queried for InvalidOid relfilenodes however so it seems to be safe even if it violates the rules somewhat.
It might be nicer to add infrastructure to do this properly, like using a partial index, its not clear what the best way to do this is though. Needs a CATVERSION bump. --- src/backend/utils/cache/syscache.c | 11 +++++++++++ src/include/catalog/indexing.h | 2 ++ src/include/catalog/pg_proc.h | 1 + src/include/utils/syscache.h | 1 + 4 files changed, 15 insertions(+)
diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index ca22efd..9d2f6b7 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -613,6 +613,17 @@ static const struct cachedesc cacheinfo[] = { }, 1024 }, + {RelationRelationId, /* RELFILENODE */ + ClassTblspcRelfilenodeIndexId, + 2, + { + Anum_pg_class_reltablespace, + Anum_pg_class_relfilenode, + 0, + 0 + }, + 1024 + }, {RewriteRelationId, /* RULERELNAME */ RewriteRelRulenameIndexId, 2, diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index 238fe58..c3db3ff 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 2662 DECLARE_UNIQUE_INDEX(pg_class_relname_nsp_index, 2663, on pg_class using btree(relname name_ops, relnamespace oid_ops)); #define ClassNameNspIndexId 2663 +DECLARE_INDEX(pg_class_tblspc_relfilenode_index, 3171, on pg_class using btree(reltablespace oid_ops, relfilenode oid_ops)); +#define ClassTblspcRelfilenodeIndexId 3171 DECLARE_UNIQUE_INDEX(pg_collation_name_enc_nsp_index, 3164, on pg_collation using btree(collname name_ops, collencoding int4_ops, collnamespace oid_ops)); #define CollationNameEncNspIndexId 3164 diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index f935eb1..16033c7 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -4673,6 +4673,7 @@ DATA(insert OID = 3473 ( spg_range_quad_leaf_consistent PGNSP PGUID 12 1 0 0 0 DESCR("SP-GiST support for quad tree over range"); + /* * Symbolic values for provolatile column: these indicate whether the result * of a function is dependent *only* on the values of its explicit arguments, diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index d1a9855..9a39077 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -77,6 +77,7 @@ enum SysCacheIdentifier RANGETYPE, RELNAMENSP, RELOID, + RELFILENODE, RULERELNAME, STATRELATTINH, TABLESPACEOID,
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers