7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.14 1997/05/31 06:35:56 vadim Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.15 1997/06/06 03:11:42 vadim Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -488,7 +488,8 @@ _bt_insertonpg(Relation rel,
488
488
upditem_offset = P_FIRSTKEY ;
489
489
if ( !P_LEFTMOST (lpageop ) ||
490
490
stack -> bts_offset != upditem_offset )
491
- elog (FATAL , "btree: items are out of order" );
491
+ elog (FATAL , "btree: items are out of order (leftmost %d, stack %u, update %u)" ,
492
+ P_LEFTMOST (lpageop ), stack -> bts_offset , upditem_offset );
492
493
}
493
494
/*
494
495
* There was bug caused by deletion all minimum keys (K1) from
@@ -682,7 +683,8 @@ _bt_split(Relation rel, Buffer buf, BTItem hiRightItem)
682
683
+ (sizeof (BTItemData ) - sizeof (IndexTupleData ));
683
684
itemsz = DOUBLEALIGN (itemsz );
684
685
}
685
- (void ) PageAddItem (rightpage , (Item ) item , itemsz , P_HIKEY , LP_USED );
686
+ if ( PageAddItem (rightpage , (Item ) item , itemsz , P_HIKEY , LP_USED ) == InvalidOffsetNumber )
687
+ elog (FATAL , "btree: failed to add hikey to the right sibling" );
686
688
rightoff = P_FIRSTKEY ;
687
689
} else {
688
690
/* splitting a rightmost page, "high key" is the first data item */
@@ -702,12 +704,14 @@ _bt_split(Relation rel, Buffer buf, BTItem hiRightItem)
702
704
703
705
/* decide which page to put it on */
704
706
if (i < firstright ) {
705
- (void ) PageAddItem (leftpage , (Item ) item , itemsz , leftoff ,
706
- LP_USED );
707
+ if ( PageAddItem (leftpage , (Item ) item , itemsz , leftoff ,
708
+ LP_USED ) == InvalidOffsetNumber )
709
+ elog (FATAL , "btree: failed to add item to the left sibling" );
707
710
leftoff = OffsetNumberNext (leftoff );
708
711
} else {
709
- (void ) PageAddItem (rightpage , (Item ) item , itemsz , rightoff ,
710
- LP_USED );
712
+ if ( PageAddItem (rightpage , (Item ) item , itemsz , rightoff ,
713
+ LP_USED ) == InvalidOffsetNumber )
714
+ elog (FATAL , "btree: failed to add item to the right sibling" );
711
715
rightoff = OffsetNumberNext (rightoff );
712
716
}
713
717
}
@@ -735,7 +739,8 @@ _bt_split(Relation rel, Buffer buf, BTItem hiRightItem)
735
739
*/
736
740
737
741
PageManagerModeSet (OverwritePageManagerMode );
738
- (void ) PageAddItem (leftpage , (Item ) item , itemsz , P_HIKEY , LP_USED );
742
+ if ( PageAddItem (leftpage , (Item ) item , itemsz , P_HIKEY , LP_USED ) == InvalidOffsetNumber )
743
+ elog (FATAL , "btree: failed to add hikey to the left sibling" );
739
744
PageManagerModeSet (ShufflePageManagerMode );
740
745
741
746
/*
@@ -913,7 +918,8 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
913
918
* page is the rightmost page on its level so the "high key" item
914
919
* is the first data item.
915
920
*/
916
- (void ) PageAddItem (rootpage , (Item ) new_item , itemsz , P_HIKEY , LP_USED );
921
+ if ( PageAddItem (rootpage , (Item ) new_item , itemsz , P_HIKEY , LP_USED ) == InvalidOffsetNumber )
922
+ elog (FATAL , "btree: failed to add leftkey to new root page" );
917
923
pfree (new_item );
918
924
919
925
/*
@@ -929,7 +935,8 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf)
929
935
/*
930
936
* insert the right page pointer into the new root page.
931
937
*/
932
- (void ) PageAddItem (rootpage , (Item ) new_item , itemsz , P_FIRSTKEY , LP_USED );
938
+ if ( PageAddItem (rootpage , (Item ) new_item , itemsz , P_FIRSTKEY , LP_USED ) == InvalidOffsetNumber )
939
+ elog (FATAL , "btree: failed to add rightkey to new root page" );
933
940
pfree (new_item );
934
941
935
942
/* write and let go of the root buffer */
@@ -981,7 +988,8 @@ _bt_pgaddtup(Relation rel,
981
988
} while ( ! BTItemSame (chkitem , afteritem ) );
982
989
}
983
990
984
- (void ) PageAddItem (page , (Item ) btitem , itemsize , itup_off , LP_USED );
991
+ if ( PageAddItem (page , (Item ) btitem , itemsize , itup_off , LP_USED ) == InvalidOffsetNumber )
992
+ elog (FATAL , "btree: failed to add item to the page" );
985
993
986
994
/* write the buffer, but hold our lock */
987
995
_bt_wrtnorelbuf (rel , buf );
@@ -1325,14 +1333,16 @@ _bt_shift (Relation rel, Buffer buf, BTStack stack, int keysz,
1325
1333
itemsz = IndexTupleDSize (hikey -> bti_itup )
1326
1334
+ (sizeof (BTItemData ) - sizeof (IndexTupleData ));
1327
1335
itemsz = DOUBLEALIGN (itemsz );
1328
- (void ) PageAddItem (page , (Item ) hikey , itemsz , P_HIKEY , LP_USED );
1336
+ if ( PageAddItem (page , (Item ) hikey , itemsz , P_HIKEY , LP_USED ) == InvalidOffsetNumber )
1337
+ elog (FATAL , "btree: failed to add hikey in _bt_shift" );
1329
1338
pfree (hikey );
1330
1339
1331
1340
/* add btitem */
1332
1341
itemsz = IndexTupleDSize (btitem -> bti_itup )
1333
1342
+ (sizeof (BTItemData ) - sizeof (IndexTupleData ));
1334
1343
itemsz = DOUBLEALIGN (itemsz );
1335
- (void ) PageAddItem (page , (Item ) btitem , itemsz , P_FIRSTKEY , LP_USED );
1344
+ if ( PageAddItem (page , (Item ) btitem , itemsz , P_FIRSTKEY , LP_USED ) == InvalidOffsetNumber )
1345
+ elog (FATAL , "btree: failed to add firstkey in _bt_shift" );
1336
1346
pfree (btitem );
1337
1347
nitem = (BTItem ) PageGetItem (page , PageGetItemId (page , P_FIRSTKEY ));
1338
1348
btitem = _bt_formitem (& (nitem -> bti_itup ));
0 commit comments