Commit 668e37d1 authored by Tom Lane's avatar Tom Lane

Fix wrong WAL info value generated when gistContinueInsert() performs an

index page split.  This would result in index corruption, or even more likely
an error during WAL replay, if we were unlucky enough to crash during
end-of-recovery cleanup after having completed an incomplete GIST insertion.

Yoichi Hirai
parent 98e8a419
......@@ -8,7 +8,7 @@
* Portions Copyright (c) 1994, Regents of the University of California
*
* IDENTIFICATION
* $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.33 2009/12/19 01:32:32 sriggs Exp $
* $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.34 2009/12/24 17:52:04 tgl Exp $
*-------------------------------------------------------------------------
*/
#include "postgres.h"
......@@ -650,6 +650,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
int j,
k,
pituplen = 0;
uint8 xlinfo;
XLogRecData *rdata;
XLogRecPtr recptr;
Buffer tempbuffer = InvalidBuffer;
......@@ -738,6 +739,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
for (j = 0; j < ntodelete; j++)
PageIndexTupleDelete(pages[0], todelete[j]);
xlinfo = XLOG_GIST_PAGE_SPLIT;
rdata = formSplitRdata(index->rd_node, insert->path[i],
false, &(insert->key),
gistMakePageLayout(buffers, numbuffer));
......@@ -751,6 +753,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
PageIndexTupleDelete(pages[0], todelete[j]);
gistfillbuffer(pages[0], itup, lenitup, InvalidOffsetNumber);
xlinfo = XLOG_GIST_PAGE_UPDATE;
rdata = formUpdateRdata(index->rd_node, buffers[0],
todelete, ntodelete,
itup, lenitup, &(insert->key));
......@@ -767,7 +770,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
GistPageGetOpaque(pages[j])->rightlink = InvalidBlockNumber;
MarkBufferDirty(buffers[j]);
}
recptr = XLogInsert(RM_GIST_ID, XLOG_GIST_PAGE_UPDATE, rdata);
recptr = XLogInsert(RM_GIST_ID, xlinfo, rdata);
for (j = 0; j < numbuffer; j++)
{
PageSetLSN(pages[j], recptr);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment