diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c
index 59c4213..268f0cbc 100644
--- a/src/backend/access/hash/hashinsert.c
+++ b/src/backend/access/hash/hashinsert.c
@@ -58,7 +58,8 @@ _hash_doinsert(Relation rel, IndexTuple itup)
 restart_insert:
 	/* Read the metapage */
 	metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ, LH_META_PAGE);
-	metap = HashPageGetMeta(BufferGetPage(metabuf));
+	page = BufferGetPage(metabuf);
+	metap = HashPageGetMeta(page);
 
 	/*
 	 * Check whether the item can fit on a hash page at all. (Eventually, we
@@ -67,11 +68,11 @@ restart_insert:
 	 *
 	 * XXX this is useless code if we are only storing hash keys.
 	 */
-	if (itemsz > HashMaxItemSize((Page) metap))
+	if (itemsz > HashMaxItemSize(page))
 		ereport(ERROR,
 				(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
 				 errmsg("index row size %zu exceeds hash maximum %zu",
-						itemsz, HashMaxItemSize((Page) metap)),
+						itemsz, HashMaxItemSize(page)),
 			errhint("Values larger than a buffer page cannot be indexed.")));
 
 	oldblkno = InvalidBlockNumber;
