88 * Portions Copyright (c) 1994, Regents of the University of California
99 *
1010 * IDENTIFICATION
11- * $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.6 2005/06/30 17:52:14 teodor Exp $
11+ * $PostgreSQL: pgsql/src/backend/access/gist/gistxlog.c,v 1.7 2005/07/01 13:18:17 teodor Exp $
1212 *-------------------------------------------------------------------------
1313 */
1414#include "postgres.h"
@@ -162,7 +162,7 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) {
162162return ;
163163buffer = XLogReadBuffer (false,reln ,xlrec .data -> blkno );
164164if (!BufferIsValid (buffer ))
165- elog (PANIC ,"gistRedoEntryUpdateRecord: block unfound" );
165+ elog (PANIC ,"gistRedoEntryUpdateRecord: block%u unfound" , xlrec . data -> blkno );
166166page = (Page )BufferGetPage (buffer );
167167
168168if (isnewroot ) {
@@ -173,7 +173,7 @@ gistRedoEntryUpdateRecord(XLogRecPtr lsn, XLogRecord *record, bool isnewroot) {
173173}
174174}else {
175175if (PageIsNew ((PageHeader )page ) )
176- elog (PANIC ,"gistRedoEntryUpdateRecord: uninitialized page" );
176+ elog (PANIC ,"gistRedoEntryUpdateRecord: uninitialized page blkno %u" , xlrec . data -> blkno );
177177if (XLByteLE (lsn ,PageGetLSN (page ))) {
178178LockBuffer (buffer ,BUFFER_LOCK_UNLOCK );
179179ReleaseBuffer (buffer );
@@ -476,7 +476,7 @@ gistXLogReadAndLockBuffer( Relation r, BlockNumber blkno ) {
476476if (!BufferIsValid (buffer ))
477477elog (PANIC ,"gistXLogReadAndLockBuffer: block %u unfound" ,blkno );
478478if (PageIsNew ( (PageHeader )(BufferGetPage (buffer )) ) )
479- elog (PANIC ,"gistXLogReadAndLockBuffer: uninitialized page %u" ,blkno );
479+ elog (PANIC ,"gistXLogReadAndLockBuffer: uninitialized pageblkno %u" ,blkno );
480480
481481return buffer ;
482482}
@@ -510,6 +510,15 @@ gixtxlogFindPath( Relation index, gistIncompleteInsert *insert ) {
510510elog (LOG ,"gixtxlogFindPath: lost parent for block %u" ,insert -> origblkno );
511511}
512512
513+ /*
514+ * Continue insert after crash. In normal situation, there isn't any incomplete
515+ * inserts, but if it might be after crash, WAL may has not a record of completetion.
516+ *
517+ * Although stored LSN in gistIncompleteInsert is a LSN of child page,
518+ * we can compare it with LSN of parent, because parent is always locked
519+ * while we change child page (look at gistmakedeal). So if parent's LSN is
520+ * lesser than stored lsn then changes in parent doesn't do yet.
521+ */
513522static void
514523gistContinueInsert (gistIncompleteInsert * insert ) {
515524IndexTuple * itup ;
@@ -574,7 +583,7 @@ gistContinueInsert(gistIncompleteInsert *insert) {
574583elog (PANIC ,"gistContinueInsert: block %u unfound" ,insert -> path [i ]);
575584pages [numbuffer - 1 ]= BufferGetPage (buffers [numbuffer - 1 ] );
576585if (PageIsNew ((PageHeader )(pages [numbuffer - 1 ])) )
577- elog (PANIC ,"gistContinueInsert: uninitialized page" );
586+ elog (PANIC ,"gistContinueInsert: uninitialized page blkno %u" , insert -> path [ i ] );
578587
579588if (XLByteLE (insert -> lsn ,PageGetLSN (pages [numbuffer - 1 ]))) {
580589LockBuffer (buffers [numbuffer - 1 ],BUFFER_LOCK_UNLOCK );