aboutsummaryrefslogtreecommitdiff
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:41:30 +0300
commitfdf28853ae6a397497b79fea69f89f4f7b9aa991 (patch)
tree25f4732403b6f0c24d349e84803787f07723bbed
parentb48ecf862b3896631660ee8d38054aded82a4f8b (diff)
downloadpostgresql-fdf28853ae6a397497b79fea69f89f4f7b9aa991.tar.gz
postgresql-fdf28853ae6a397497b79fea69f89f4f7b9aa991.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.
-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 2f8586725a2..da28e21d5cb 100644
--- a/src/backend/access/nbtree/nbtxlog.c
+++ b/src/backend/access/nbtree/nbtxlog.c
@@ -864,9 +864,10 @@ btree_xlog_unlink_page(uint8 info, XLogReaderState *record)
buffer = XLogInitBufferForRedo(record, 3);
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;