7
7
*
8
8
*
9
9
* IDENTIFICATION
10
- * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.12 1996/12/15 09:05:10 bryanh Exp $
10
+ * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.13 1997/01/05 10:56:36 vadim Exp $
11
11
*
12
12
*-------------------------------------------------------------------------
13
13
*/
@@ -1080,6 +1080,7 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
1080
1080
1081
1081
rel = scan -> relation ;
1082
1082
current = & (scan -> currentItemData );
1083
+ so = (BTScanOpaque ) scan -> opaque ;
1083
1084
1084
1085
buf = _bt_getroot (rel , BT_READ );
1085
1086
blkno = BufferGetBlockNumber (buf );
@@ -1153,6 +1154,9 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
1153
1154
if ( start != P_HIKEY ) /* non-rightmost page */
1154
1155
elog (WARN , "_bt_endpoint: non-rightmost page (%u) is empty" , blkno );
1155
1156
/* It's left- & right- most page - root page, - and it's empty... */
1157
+ _bt_relbuf (rel , buf , BT_READ );
1158
+ ItemPointerSetInvalid (current );
1159
+ so -> btso_curbuf = InvalidBuffer ;
1156
1160
return ((RetrieveIndexResult ) NULL );
1157
1161
}
1158
1162
if ( start > maxoff ) /* start == 2 && maxoff == 1 */
@@ -1188,7 +1192,12 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
1188
1192
{
1189
1193
/* If it's leftmost page too - it's empty root page... */
1190
1194
if ( P_LEFTMOST (opaque ) )
1195
+ {
1196
+ _bt_relbuf (rel , buf , BT_READ );
1197
+ ItemPointerSetInvalid (current );
1198
+ so -> btso_curbuf = InvalidBuffer ;
1191
1199
return ((RetrieveIndexResult ) NULL );
1200
+ }
1192
1201
/* Go back ! */
1193
1202
ItemPointerSet (current , blkno , FirstOffsetNumber );
1194
1203
if (!_bt_step (scan , & buf , BackwardScanDirection ))
@@ -1214,7 +1223,6 @@ _bt_endpoint(IndexScanDesc scan, ScanDirection dir)
1214
1223
res = FormRetrieveIndexResult (current , & (itup -> t_tid ));
1215
1224
1216
1225
/* remember which buffer we have pinned */
1217
- so = (BTScanOpaque ) scan -> opaque ;
1218
1226
so -> btso_curbuf = buf ;
1219
1227
} else {
1220
1228
_bt_relbuf (rel , buf , BT_READ );
0 commit comments