skip_dead_tups_hash_index-v1.patch

application/octet-stream

Filename: skip_dead_tups_hash_index-v1.patch
Type: application/octet-stream
Part: 0
Message: Re: Hash Indexes

Patch

Format: unified
Series: patch v1
File+
src/backend/access/hash/hashovfl.c 4 0
src/backend/access/hash/hashpage.c 4 0
diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c
index db3e268..df7af3e 100644
--- a/src/backend/access/hash/hashovfl.c
+++ b/src/backend/access/hash/hashovfl.c
@@ -656,6 +656,10 @@ _hash_squeezebucket(Relation rel,
 			IndexTuple	itup;
 			Size		itemsz;
 
+			/* skip dead tuples */
+			if (ItemIdIsDead(PageGetItemId(rpage, roffnum)))
+				continue;
+
 			itup = (IndexTuple) PageGetItem(rpage,
 											PageGetItemId(rpage, roffnum));
 			itemsz = IndexTupleDSize(*itup);
diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c
index 178463f..a5e9d17 100644
--- a/src/backend/access/hash/hashpage.c
+++ b/src/backend/access/hash/hashpage.c
@@ -811,6 +811,10 @@ _hash_splitbucket(Relation rel,
 			Size		itemsz;
 			Bucket		bucket;
 
+			/* skip dead tuples */
+			if (ItemIdIsDead(PageGetItemId(opage, ooffnum)))
+				continue;
+
 			/*
 			 * Fetch the item's hash key (conveniently stored in the item) and
 			 * determine which bucket it now belongs in.