Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit85376c6

Browse files
committed
Fix coredump during replay WAL after crash. Change entrySplitPage() to prevent
usage of any information from system catalog, because it could be called duringreplay of WAL.Per bug report from Craig McElroy <craig.mcelroy@contegix.com>. Patch doesn'tchange on-disk storage.
1 parent811be89 commit85376c6

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

‎src/backend/access/gin/ginentrypage.c

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
1010
* IDENTIFICATION
11-
*$PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.9 2007/09/20 17:56:30 tgl Exp $
11+
*$PostgreSQL: pgsql/src/backend/access/gin/ginentrypage.c,v 1.10 2007/10/29 13:49:21 teodor Exp $
1212
*-------------------------------------------------------------------------
1313
*/
1414

@@ -403,6 +403,31 @@ entryPlaceToPage(GinBtree btree, Buffer buf, OffsetNumber off, XLogRecData **prd
403403
btree->entry=NULL;
404404
}
405405

406+
/*
407+
* Returns new tuple with copied value from source tuple.
408+
* New tuple will not store posting list
409+
*/
410+
staticIndexTuple
411+
copyIndexTuple(IndexTupleitup,Pagepage)
412+
{
413+
IndexTuplenitup;
414+
415+
if (GinPageIsLeaf(page)&& !GinIsPostingTree(itup))
416+
{
417+
nitup= (IndexTuple)palloc(MAXALIGN(GinGetOrigSizePosting(itup)));
418+
memcpy(nitup,itup,GinGetOrigSizePosting(itup));
419+
nitup->t_info &= ~INDEX_SIZE_MASK;
420+
nitup->t_info |=GinGetOrigSizePosting(itup);
421+
}
422+
else
423+
{
424+
nitup= (IndexTuple)palloc(MAXALIGN(IndexTupleSize(itup)));
425+
memcpy(nitup,itup,IndexTupleSize(itup));
426+
}
427+
428+
returnnitup;
429+
}
430+
406431
/*
407432
* Place tuple and split page, original buffer(lbuf) leaves untouched,
408433
* returns shadow page of lbuf filled new data.
@@ -424,8 +449,6 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
424449
IndexTupleitup,
425450
leftrightmost=NULL;
426451
staticginxlogSplitdata;
427-
Datumvalue;
428-
boolisnull;
429452
Pagepage;
430453
Pagelpage=GinPageGetCopyPage(BufferGetPage(lbuf));
431454
Pagerpage=BufferGetPage(rbuf);
@@ -494,9 +517,9 @@ entrySplitPage(GinBtree btree, Buffer lbuf, Buffer rbuf, OffsetNumber off, XLogR
494517
ptr+=MAXALIGN(IndexTupleSize(itup));
495518
}
496519

497-
value=index_getattr(leftrightmost,FirstOffsetNumber,btree->ginstate->tupdesc,&isnull);
498-
btree->entry=GinFormTuple(btree->ginstate,value,NULL,0);
520+
btree->entry=copyIndexTuple(leftrightmost,lpage);
499521
ItemPointerSet(&(btree->entry)->t_tid,BufferGetBlockNumber(lbuf),InvalidOffsetNumber);
522+
500523
btree->rightblkno=BufferGetBlockNumber(rbuf);
501524

502525
data.node=btree->index->rd_node;
@@ -533,20 +556,9 @@ ginPageGetLinkItup(Buffer buf)
533556
Pagepage=BufferGetPage(buf);
534557

535558
itup=getRightMostTuple(page);
536-
if (GinPageIsLeaf(page)&& !GinIsPostingTree(itup))
537-
{
538-
nitup= (IndexTuple)palloc(MAXALIGN(GinGetOrigSizePosting(itup)));
539-
memcpy(nitup,itup,GinGetOrigSizePosting(itup));
540-
nitup->t_info &= ~INDEX_SIZE_MASK;
541-
nitup->t_info |=GinGetOrigSizePosting(itup);
542-
}
543-
else
544-
{
545-
nitup= (IndexTuple)palloc(MAXALIGN(IndexTupleSize(itup)));
546-
memcpy(nitup,itup,IndexTupleSize(itup));
547-
}
548-
559+
nitup=copyIndexTuple(itup,page);
549560
ItemPointerSet(&nitup->t_tid,BufferGetBlockNumber(buf),InvalidOffsetNumber);
561+
550562
returnnitup;
551563
}
552564

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp