diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:18:09 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:18:09 +0000 |
commit | ebe124eacd7c3faa36ed358e7cc1d7c5b419e5f6 (patch) | |
tree | 48fe9c3270176faa25c7d9fb47326f689be82fe4 /src/backend/access/spgist/spgutils.c | |
parent | Releasing progress-linux version 15.5-0+deb12u1~progress6.99u1. (diff) | |
download | postgresql-15-ebe124eacd7c3faa36ed358e7cc1d7c5b419e5f6.tar.xz postgresql-15-ebe124eacd7c3faa36ed358e7cc1d7c5b419e5f6.zip |
Merging upstream version 15.6.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-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 f2da02e..bff33f3 100644 --- a/src/backend/access/spgist/spgutils.c +++ b/src/backend/access/spgist/spgutils.c @@ -185,8 +185,6 @@ spgGetCache(Relation index) Oid atttype; spgConfigIn in; FmgrInfo *procinfo; - Buffer metabuffer; - SpGistMetaPageData *metadata; cache = MemoryContextAllocZero(index->rd_indexcxt, sizeof(SpGistCache)); @@ -254,19 +252,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; } |