aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-06-30 13:37:16 +0300
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>2015-06-30 13:45:00 +0300
commit7dc721889b31450cad338a189a97ff0ff46534d5 (patch)
treec357b651276e72d7a85d69f2f0b7a7c84465d8dd /src
parent1afc1fe9c7bb72652ff9681c2e59a5751a33cda1 (diff)
downloadpostgresql-7dc721889b31450cad338a189a97ff0ff46534d5.tar.gz
postgresql-7dc721889b31450cad338a189a97ff0ff46534d5.zip
Don't call PageGetSpecialPointer() on page until it's been initialized.
After calling XLogInitBufferForRedo(), the page might be all-zeros if it was not in page cache already. btree_xlog_unlink_page initialized the page correctly, but it called PageGetSpecialPointer before initializing it, which would lead to a corrupt page at WAL replay, if the unlinked page is not in page cache. Backpatch to 9.4, the bug came with the rewrite of B-tree page deletion.
Diffstat (limited to 'src')
-rw-r--r--src/backend/access/nbtree/nbtxlog.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/access/nbtree/nbtxlog.c b/src/backend/access/nbtree/nbtxlog.c
index 5f9fc49e78c..2debb870bd0 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -997,9 +997,10 @@ btree_xlog_unlink_page(uint8 info, XLogRecPtr lsn, XLogRecord *record)
buffer = XLogReadBuffer(xlrec->node, xlrec->leafblk, true);
Assert(BufferIsValid(buffer));
page = (Page) BufferGetPage(buffer);
- pageop = (BTPageOpaque) PageGetSpecialPointer(page);
_bt_pageinit(page, BufferGetPageSize(buffer));
+ pageop = (BTPageOpaque) PageGetSpecialPointer(page);
+
pageop->btpo_flags = BTP_HALF_DEAD | BTP_LEAF;
pageop->btpo_prev = xlrec->leafleftsib;
pageop->btpo_next = xlrec->leafrightsib;