diff options
Diffstat (limited to 'src/backend/access/spgist/spgutils.c')
-rw-r--r-- | src/backend/access/spgist/spgutils.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/backend/access/spgist/spgutils.c b/src/backend/access/spgist/spgutils.c index fd4b6157101..a8055c51a2d 100644 --- a/src/backend/access/spgist/spgutils.c +++ b/src/backend/access/spgist/spgutils.c @@ -188,8 +188,6 @@ spgGetCache(Relation index) Oid atttype; spgConfigIn in; FmgrInfo *procinfo; - Buffer metabuffer; - SpGistMetaPageData *metadata; cache = MemoryContextAllocZero(index->rd_indexcxt, sizeof(SpGistCache)); @@ -257,19 +255,28 @@ spgGetCache(Relation index) fillTypeDesc(&cache->attPrefixType, cache->config.prefixType); fillTypeDesc(&cache->attLabelType, cache->config.labelType); - /* Last, get the lastUsedPages data from the metapage */ - metabuffer = ReadBuffer(index, SPGIST_METAPAGE_BLKNO); - LockBuffer(metabuffer, BUFFER_LOCK_SHARE); + /* + * Finally, if it's a real index (not a partitioned one), get the + * lastUsedPages data from the metapage + */ + if (index->rd_rel->relkind != RELKIND_PARTITIONED_INDEX) + { + Buffer metabuffer; + SpGistMetaPageData *metadata; + + metabuffer = ReadBuffer(index, SPGIST_METAPAGE_BLKNO); + LockBuffer(metabuffer, BUFFER_LOCK_SHARE); - metadata = SpGistPageGetMeta(BufferGetPage(metabuffer)); + metadata = SpGistPageGetMeta(BufferGetPage(metabuffer)); - if (metadata->magicNumber != SPGIST_MAGIC_NUMBER) - elog(ERROR, "index \"%s\" is not an SP-GiST index", - RelationGetRelationName(index)); + if (metadata->magicNumber != SPGIST_MAGIC_NUMBER) + elog(ERROR, "index \"%s\" is not an SP-GiST index", + RelationGetRelationName(index)); - cache->lastUsedPages = metadata->lastUsedPages; + cache->lastUsedPages = metadata->lastUsedPages; - UnlockReleaseBuffer(metabuffer); + UnlockReleaseBuffer(metabuffer); + } index->rd_amcache = (void *) cache; } |