8000 Back-patch fix for 'btree: failed to add item to the page in _bt_sort… · percona/postgres@de9b43f · GitHub
[go: up one dir, main page]

Skip to content

Commit de9b43f

Browse files
committed
Back-patch fix for 'btree: failed to add item to the page in _bt_sort (2)'
failure during index creation. This problem should be gone in current sources, but I just thought I'd commit the 7.0.* patch in case anyone else needs it.
1 parent a860a40 commit de9b43f

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/backend/access/nbtree/nbtsort.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
* Portions Copyright (c) 1994, Regents of the University of California
2929
*
3030
* IDENTIFICATION
31-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.52 2000/04/12 17:14:49 momjian Exp $
31+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsort.c,v 1.52.2.1 2001/01/04 21:51:49 tgl Exp $
3232
*
3333
*-------------------------------------------------------------------------
3434
*/
@@ -321,7 +321,7 @@ _bt_buildadd(Relation index, Size keysz, ScanKey scankey,
321321
btisz,
322322
(PageGetPageSize(npage) - sizeof(PageHeaderData) - MAXALIGN(sizeof(BTPageOpaqueData))) /3 - sizeof(ItemIdData));
323323

324-
if (pgspc < btisz)
324+
while (pgspc < btisz)
325325
{
326326
Buffer obuf = nbuf;
327327
Page opage = npage;
@@ -436,6 +436,13 @@ _bt_buildadd(Relation index, Size keysz, ScanKey scankey,
436436
* we aren't locking).
437437
*/
438438
_bt_wrtbuf(index, obuf);
439+
440+
/*
441+
* Recompute pgspc and loop back to check free space again. If
442+
* we were forced to split at a bad split point, we might need
443+
* to split again.
444+
*/
445+
pgspc = PageGetFreeSpace(npage);
439446
}
440447

441448
/*

0 commit comments

Comments
 (0)
0