aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRobert Haas <rhaas@postgresql.org>2017-02-09 14:02:58 -0500
committerRobert Haas <rhaas@postgresql.org>2017-02-09 14:34:34 -0500
commitfc8219dc54c95ea673560b786aa8123ce6ec5977 (patch)
treea33bf5ea881e397242775e97df4a606ecc21c717 /src
parent86d911ec0f9d4643e9a47db42510959dec0ed76b (diff)
downloadpostgresql-fc8219dc54c95ea673560b786aa8123ce6ec5977.tar.gz
postgresql-fc8219dc54c95ea673560b786aa8123ce6ec5977.zip
pageinspect: Fix hash_bitmap_info not to read the underlying page.
It did that to verify that the page was an overflow page rather than anything else, but that means that checking the status of all the overflow bits requires reading the entire index. So don't do that. The new code validates that the page is not a primary bucket page or bitmap page by looking at the metapage, so that using this on large numbers of pages can be reasonably efficient. Ashutosh Sharma, per a complaint from me, and with further modifications by me.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/hash/hashovfl.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c
index 753c8a6a134..33340893291 100644
--- a/src/backend/access/hash/hashovfl.c
+++ b/src/backend/access/hash/hashovfl.c
@@ -69,11 +69,20 @@ _hash_ovflblkno_to_bitno(HashMetaPage metap, BlockNumber ovflblkno)
if (ovflblkno <= (BlockNumber) (1 << i))
break; /* oops */
bitnum = ovflblkno - (1 << i);
- if (bitnum <= metap->hashm_spares[i])
+
+ /*
+ * bitnum has to be greater than number of overflow page added in
+ * previous split point. The overflow page at this splitnum (i) if any
+ * should start from ((2 ^ i) + metap->hashm_spares[i - 1] + 1).
+ */
+ if (bitnum > metap->hashm_spares[i - 1] &&
+ bitnum <= metap->hashm_spares[i])
return bitnum - 1; /* -1 to convert 1-based to 0-based */
}
- elog(ERROR, "invalid overflow block number %u", ovflblkno);
+ ereport(ERROR,
+ (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+ errmsg("invalid overflow block number %u", ovflblkno)));
return 0; /* keep compiler quiet */
}