summaryrefslogtreecommitdiff
path: root/src/backend/access/nbtree/nbtree.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2006-03-31 23:32:07 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2006-03-31 23:32:07 +0000
commita8b8f4db23cff16af50a2b960cb8d20d39b761cf (patch)
tree224f8cb0da7e2e17ccfd7b8a030db1664acd46c1 /src/backend/access/nbtree/nbtree.c
parent89395bfa6f2fafccec10be377fcf759030910654 (diff)
downloadpostgresql-a8b8f4db23cff16af50a2b960cb8d20d39b761cf.tar.gz
Clean up WAL/buffer interactions as per my recent proposal. Get rid of the
misleadingly-named WriteBuffer routine, and instead require routines that change buffer pages to call MarkBufferDirty (which does exactly what it says). We also require that they do so before calling XLogInsert; this takes care of the synchronization requirement documented in SyncOneBuffer. Note that because bufmgr takes the buffer content lock (in shared mode) while writing out any buffer, it doesn't matter whether MarkBufferDirty is executed before the buffer content change is complete, so long as the content change is completed before releasing exclusive lock on the buffer. So it's OK to set the dirtybit before we fill in the LSN. This eliminates the former kluge of needing to set the dirtybit in LockBuffer. Aside from making the code more transparent, we can also add some new debugging assertions, in particular that the caller of MarkBufferDirty must hold the buffer content lock, not merely a pin.
Diffstat (limited to 'src/backend/access/nbtree/nbtree.c')
-rw-r--r--src/backend/access/nbtree/nbtree.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c
index 84dad045a7..59c733330b 100644
--- a/src/backend/access/nbtree/nbtree.c
+++ b/src/backend/access/nbtree/nbtree.c
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
- * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.142 2006/03/05 15:58:21 momjian Exp $
+ * $PostgreSQL: pgsql/src/backend/access/nbtree/nbtree.c,v 1.143 2006/03/31 23:32:05 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -624,18 +624,13 @@ btbulkdelete(PG_FUNCTION_ARGS)
}
}
- /*
- * If we need to delete anything, do it and write the buffer; else
- * just release the buffer.
- */
- nextpage = opaque->btpo_next;
+ /* Apply any needed deletes */
if (ndeletable > 0)
- {
_bt_delitems(rel, buf, deletable, ndeletable);
- _bt_wrtbuf(rel, buf);
- }
- else
- _bt_relbuf(rel, buf);
+
+ /* Fetch nextpage link before releasing the buffer */
+ nextpage = opaque->btpo_next;
+ _bt_relbuf(rel, buf);
/* call vacuum_delay_point while not holding any buffer lock */
vacuum_delay_point();