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
This commit is contained in:
Tom Lane 2009-12-24 17:52:19 +00:00
parent 65a5d12be1
commit f216f56e6e

View File

@ -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.27 2008/01/01 19:45:46 momjian Exp $
* $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.27.2.1 2009/12/24 17:52:19 tgl Exp $
*-------------------------------------------------------------------------
*/
#include "postgres.h"
@ -649,6 +649,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
int j,
k,
pituplen = 0;
uint8 xlinfo;
XLogRecData *rdata;
XLogRecPtr recptr;
Buffer tempbuffer = InvalidBuffer;
@ -737,6 +738,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));
@ -750,6 +752,7 @@ gistContinueInsert(gistIncompleteInsert *insert)
PageIndexTupleDelete(pages[0], todelete[j]);
gistfillbuffer(index, pages[0], itup, lenitup, InvalidOffsetNumber);
xlinfo = XLOG_GIST_PAGE_UPDATE;
rdata = formUpdateRdata(index->rd_node, buffers[0],
todelete, ntodelete,
itup, lenitup, &(insert->key));
@ -766,7 +769,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);