summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/backend/access/hash/hash.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c
index 34cc08f12d..b835f772d4 100644
--- a/src/backend/access/hash/hash.c
+++ b/src/backend/access/hash/hash.c
@@ -476,9 +476,17 @@ hashrescan(IndexScanDesc scan, ScanKey scankey, int nscankeys,
HashScanOpaque so = (HashScanOpaque) scan->opaque;
Relation rel = scan->indexRelation;
- /* Before leaving current page, deal with any killed items */
+ /*
+ * Before leaving current page, deal with any killed items.
+ * Also, ensure that we acquire lock on current page before
+ * calling _hash_kill_items.
+ */
if (so->numKilled > 0)
+ {
+ LockBuffer(so->hashso_curbuf, BUFFER_LOCK_SHARE);
_hash_kill_items(scan);
+ LockBuffer(so->hashso_curbuf, BUFFER_LOCK_UNLOCK);
+ }
_hash_dropscanbuf(rel, so);
@@ -507,9 +515,17 @@ hashendscan(IndexScanDesc scan)
HashScanOpaque so = (HashScanOpaque) scan->opaque;
Relation rel = scan->indexRelation;
- /* Before leaving current page, deal with any killed items */
+ /*
+ * Before leaving current page, deal with any killed items.
+ * Also, ensure that we acquire lock on current page before
+ * calling _hash_kill_items.
+ */
if (so->numKilled > 0)
+ {
+ LockBuffer(so->hashso_curbuf, BUFFER_LOCK_SHARE);
_hash_kill_items(scan);
+ LockBuffer(so->hashso_curbuf, BUFFER_LOCK_UNLOCK);
+ }
_hash_dropscanbuf(rel, so);