1 /* $NetBSD: bt_split.c,v 1.19 2009/04/22 18:44:06 christos Exp $ */
4 * Copyright (c) 1990, 1993, 1994
5 * The Regents of the University of California. All rights reserved.
7 * This code is derived from software contributed to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 #if HAVE_NBTOOL_CONFIG_H
36 #include "nbtool_config.h"
39 #include <sys/cdefs.h>
40 __RCSID("$NetBSD: bt_split.c,v 1.19 2009/04/22 18:44:06 christos Exp $");
42 #include "namespace.h"
43 #include <sys/types.h>
54 static int bt_broot(BTREE
*, PAGE
*, PAGE
*, PAGE
*);
55 static PAGE
*bt_page(BTREE
*, PAGE
*, PAGE
**, PAGE
**, indx_t
*, size_t);
56 static int bt_preserve(BTREE
*, pgno_t
);
57 static PAGE
*bt_psplit(BTREE
*, PAGE
*, PAGE
*, PAGE
*, indx_t
*, size_t);
58 static PAGE
*bt_root(BTREE
*, PAGE
*, PAGE
**, PAGE
**, indx_t
*, size_t);
59 static int bt_rroot(BTREE
*, PAGE
*, PAGE
*, PAGE
*);
60 static recno_t
rec_total(PAGE
*);
63 unsigned long bt_rootsplit
, bt_split
, bt_sortsplit
, bt_pfxsaved
;
67 * __BT_SPLIT -- Split the tree.
73 * data: data to insert
74 * flags: BIGKEY/BIGDATA flags
76 * skip: index to leave open
79 * RET_ERROR, RET_SUCCESS
82 __bt_split(BTREE
*t
, PAGE
*sp
, const DBT
*key
, const DBT
*data
, int flags
,
83 size_t ilen
, uint32_t argskip
)
85 BINTERNAL
*bi
= NULL
; /* pacify gcc */
86 BLEAF
*bl
= NULL
, *tbl
; /* pacify gcc */
89 PAGE
*h
, *l
, *r
, *lchild
, *rchild
;
92 uint32_t n
, nbytes
, nksize
= 0; /* pacify gcc */
97 * Split the page into two pages, l and r. The split routines return
98 * a pointer to the page into which the key should be inserted and with
99 * skip set to the offset which should be used. Additionally, l and r
103 h
= sp
->pgno
== P_ROOT
?
104 bt_root(t
, sp
, &l
, &r
, &skip
, ilen
) :
105 bt_page(t
, sp
, &l
, &r
, &skip
, ilen
);
110 * Insert the new key/data pair into the leaf page. (Key inserts
111 * always cause a leaf page to split first.)
113 _DBFIT(ilen
, indx_t
);
114 h
->upper
-= (indx_t
)ilen
;
115 h
->linp
[skip
] = h
->upper
;
116 dest
= (char *)(void *)h
+ h
->upper
;
117 if (F_ISSET(t
, R_RECNO
))
118 WR_RLEAF(dest
, data
, flags
);
120 WR_BLEAF(dest
, key
, data
, flags
);
122 /* If the root page was split, make it look right. */
123 if (sp
->pgno
== P_ROOT
&&
124 (F_ISSET(t
, R_RECNO
) ?
125 bt_rroot(t
, sp
, l
, r
) : bt_broot(t
, sp
, l
, r
)) == RET_ERROR
)
129 * Now we walk the parent page stack -- a LIFO stack of the pages that
130 * were traversed when we searched for the page that split. Each stack
131 * entry is a page number and a page index offset. The offset is for
132 * the page traversed on the search. We've just split a page, so we
133 * have to insert a new key into the parent page.
135 * If the insert into the parent page causes it to split, may have to
136 * continue splitting all the way up the tree. We stop if the root
137 * splits or the page inserted into didn't have to split to hold the
138 * new key. Some algorithms replace the key for the old page as well
139 * as the new page. We don't, as there's no reason to believe that the
140 * first key on the old page is any better than the key we have, and,
141 * in the case of a key being placed at index 0 causing the split, the
142 * key is unavailable.
144 * There are a maximum of 5 pages pinned at any time. We keep the left
145 * and right pages pinned while working on the parent. The 5 are the
146 * two children, left parent and right parent (when the parent splits)
147 * and the root page or the overflow key page when calling bt_preserve.
148 * This code must make sure that all pins are released other than the
149 * root page or overflow page which is unlocked elsewhere.
151 while ((parent
= BT_POP(t
)) != NULL
) {
155 /* Get the parent page. */
156 if ((h
= mpool_get(t
->bt_mp
, parent
->pgno
, 0)) == NULL
)
160 * The new key goes ONE AFTER the index, because the split
163 skip
= parent
->index
+ 1;
166 * Calculate the space needed on the parent page.
168 * Prefix trees: space hack when inserting into BINTERNAL
169 * pages. Retain only what's needed to distinguish between
170 * the new entry and the LAST entry on the page to its left.
171 * If the keys compare equal, retain the entire key. Note,
172 * we don't touch overflow keys, and the entire key must be
173 * retained for the next-to-left most key on the leftmost
174 * page of each level, or the search will fail. Applicable
175 * ONLY to internal pages that have leaf pages as children.
176 * Further reduction of the key between pairs of internal
177 * pages loses too much information.
179 switch (rchild
->flags
& P_TYPE
) {
181 bi
= GETBINTERNAL(rchild
, 0);
182 nbytes
= NBINTERNAL(bi
->ksize
);
185 bl
= GETBLEAF(rchild
, 0);
186 nbytes
= NBINTERNAL(bl
->ksize
);
187 if (t
->bt_pfx
&& !(bl
->flags
& P_BIGKEY
) &&
188 (h
->prevpg
!= P_INVALID
|| skip
> 1)) {
190 tbl
= GETBLEAF(lchild
, NEXTINDEX(lchild
) - 1);
195 temp
= t
->bt_pfx(&a
, &b
);
196 _DBFIT(temp
, uint32_t);
197 nksize
= (uint32_t)temp
;
198 n
= NBINTERNAL(nksize
);
201 bt_pfxsaved
+= nbytes
- n
;
217 /* Split the parent page if necessary or shift the indices. */
218 if ((uint32_t)h
->upper
- (uint32_t)h
->lower
< nbytes
+ sizeof(indx_t
)) {
220 h
= h
->pgno
== P_ROOT
?
221 bt_root(t
, h
, &l
, &r
, &skip
, nbytes
) :
222 bt_page(t
, h
, &l
, &r
, &skip
, nbytes
);
227 if (skip
< (nxtindex
= NEXTINDEX(h
)))
228 memmove(h
->linp
+ skip
+ 1, h
->linp
+ skip
,
229 (nxtindex
- skip
) * sizeof(indx_t
));
230 h
->lower
+= sizeof(indx_t
);
234 /* Insert the key into the parent page. */
235 switch (rchild
->flags
& P_TYPE
) {
237 h
->linp
[skip
] = h
->upper
-= nbytes
;
238 dest
= (char *)(void *)h
+ h
->linp
[skip
];
239 memmove(dest
, bi
, nbytes
);
240 ((BINTERNAL
*)(void *)dest
)->pgno
= rchild
->pgno
;
243 h
->linp
[skip
] = h
->upper
-= nbytes
;
244 dest
= (char *)(void *)h
+ h
->linp
[skip
];
245 WR_BINTERNAL(dest
, nksize
? nksize
: bl
->ksize
,
246 rchild
->pgno
, bl
->flags
& P_BIGKEY
);
247 memmove(dest
, bl
->bytes
, nksize
? nksize
: bl
->ksize
);
248 if (bl
->flags
& P_BIGKEY
&&
249 bt_preserve(t
, *(pgno_t
*)(void *)bl
->bytes
) ==
255 * Update the left page count. If split
256 * added at index 0, fix the correct page.
259 dest
= (char *)(void *)h
+ h
->linp
[skip
- 1];
261 dest
= (char *)(void *)l
+ l
->linp
[NEXTINDEX(l
) - 1];
262 ((RINTERNAL
*)(void *)dest
)->nrecs
= rec_total(lchild
);
263 ((RINTERNAL
*)(void *)dest
)->pgno
= lchild
->pgno
;
265 /* Update the right page count. */
266 h
->linp
[skip
] = h
->upper
-= nbytes
;
267 dest
= (char *)(void *)h
+ h
->linp
[skip
];
268 ((RINTERNAL
*)(void *)dest
)->nrecs
= rec_total(rchild
);
269 ((RINTERNAL
*)(void *)dest
)->pgno
= rchild
->pgno
;
273 * Update the left page count. If split
274 * added at index 0, fix the correct page.
277 dest
= (char *)(void *)h
+ h
->linp
[skip
- 1];
279 dest
= (char *)(void *)l
+ l
->linp
[NEXTINDEX(l
) - 1];
280 ((RINTERNAL
*)(void *)dest
)->nrecs
= NEXTINDEX(lchild
);
281 ((RINTERNAL
*)(void *)dest
)->pgno
= lchild
->pgno
;
283 /* Update the right page count. */
284 h
->linp
[skip
] = h
->upper
-= nbytes
;
285 dest
= (char *)(void *)h
+ h
->linp
[skip
];
286 ((RINTERNAL
*)(void *)dest
)->nrecs
= NEXTINDEX(rchild
);
287 ((RINTERNAL
*)(void *)dest
)->pgno
= rchild
->pgno
;
293 /* Unpin the held pages. */
295 mpool_put(t
->bt_mp
, h
, MPOOL_DIRTY
);
299 /* If the root page was split, make it look right. */
300 if (sp
->pgno
== P_ROOT
&&
301 (F_ISSET(t
, R_RECNO
) ?
302 bt_rroot(t
, sp
, l
, r
) : bt_broot(t
, sp
, l
, r
)) == RET_ERROR
)
305 mpool_put(t
->bt_mp
, lchild
, MPOOL_DIRTY
);
306 mpool_put(t
->bt_mp
, rchild
, MPOOL_DIRTY
);
309 /* Unpin the held pages. */
310 mpool_put(t
->bt_mp
, l
, MPOOL_DIRTY
);
311 mpool_put(t
->bt_mp
, r
, MPOOL_DIRTY
);
313 /* Clear any pages left on the stack. */
314 return (RET_SUCCESS
);
317 * If something fails in the above loop we were already walking back
318 * up the tree and the tree is now inconsistent. Nothing much we can
319 * do about it but release any memory we're holding.
321 err1
: mpool_put(t
->bt_mp
, lchild
, MPOOL_DIRTY
);
322 mpool_put(t
->bt_mp
, rchild
, MPOOL_DIRTY
);
324 err2
: mpool_put(t
->bt_mp
, l
, 0);
325 mpool_put(t
->bt_mp
, r
, 0);
326 __dbpanic(t
->bt_dbp
);
331 * BT_PAGE -- Split a non-root page of a btree.
336 * lp: pointer to left page pointer
337 * rp: pointer to right page pointer
338 * skip: pointer to index to leave open
339 * ilen: insert length
342 * Pointer to page in which to insert or NULL on error.
345 bt_page(BTREE
*t
, PAGE
*h
, PAGE
**lp
, PAGE
**rp
, indx_t
*skip
, size_t ilen
)
353 /* Put the new right page for the split into place. */
354 if ((r
= __bt_new(t
, &npg
)) == NULL
)
357 r
->lower
= BTDATAOFF
;
358 r
->upper
= t
->bt_psize
;
359 r
->nextpg
= h
->nextpg
;
361 r
->flags
= h
->flags
& P_TYPE
;
364 * If we're splitting the last page on a level because we're appending
365 * a key to it (skip is NEXTINDEX()), it's likely that the data is
366 * sorted. Adding an empty page on the side of the level is less work
367 * and can push the fill factor much higher than normal. If we're
368 * wrong it's no big deal, we'll just do the split the right way next
369 * time. It may look like it's equally easy to do a similar hack for
370 * reverse sorted data, that is, split the tree left, but it's not.
373 if (h
->nextpg
== P_INVALID
&& *skip
== NEXTINDEX(h
)) {
378 r
->lower
= BTDATAOFF
+ sizeof(indx_t
);
385 /* Put the new left page for the split into place. */
386 if ((l
= calloc(1, t
->bt_psize
)) == NULL
) {
387 mpool_put(t
->bt_mp
, r
, 0);
391 memset(l
, 0xff, t
->bt_psize
);
395 l
->prevpg
= h
->prevpg
;
396 l
->lower
= BTDATAOFF
;
397 l
->upper
= t
->bt_psize
;
398 l
->flags
= h
->flags
& P_TYPE
;
400 /* Fix up the previous pointer of the page after the split page. */
401 if (h
->nextpg
!= P_INVALID
) {
402 if ((tp
= mpool_get(t
->bt_mp
, h
->nextpg
, 0)) == NULL
) {
404 /* XXX mpool_free(t->bt_mp, r->pgno); */
407 tp
->prevpg
= r
->pgno
;
408 mpool_put(t
->bt_mp
, tp
, MPOOL_DIRTY
);
412 * Split right. The key/data pairs aren't sorted in the btree page so
413 * it's simpler to copy the data from the split page onto two new pages
414 * instead of copying half the data to the right page and compacting
415 * the left page in place. Since the left page can't change, we have
416 * to swap the original and the allocated left page after the split.
418 tp
= bt_psplit(t
, h
, l
, r
, skip
, ilen
);
420 /* Move the new left page onto the old left page. */
421 memmove(h
, l
, t
->bt_psize
);
432 * BT_ROOT -- Split the root page of a btree.
437 * lp: pointer to left page pointer
438 * rp: pointer to right page pointer
439 * skip: pointer to index to leave open
440 * ilen: insert length
443 * Pointer to page in which to insert or NULL on error.
446 bt_root(BTREE
*t
, PAGE
*h
, PAGE
**lp
, PAGE
**rp
, indx_t
*skip
, size_t ilen
)
455 /* Put the new left and right pages for the split into place. */
456 if ((l
= __bt_new(t
, &lnpg
)) == NULL
||
457 (r
= __bt_new(t
, &rnpg
)) == NULL
)
463 l
->prevpg
= r
->nextpg
= P_INVALID
;
464 l
->lower
= r
->lower
= BTDATAOFF
;
465 l
->upper
= r
->upper
= t
->bt_psize
;
466 l
->flags
= r
->flags
= h
->flags
& P_TYPE
;
468 /* Split the root page. */
469 tp
= bt_psplit(t
, h
, l
, r
, skip
, ilen
);
477 * BT_RROOT -- Fix up the recno root page after it has been split.
486 * RET_ERROR, RET_SUCCESS
489 bt_rroot(BTREE
*t
, PAGE
*h
, PAGE
*l
, PAGE
*r
)
495 temp
= t
->bt_psize
- NRINTERNAL
;
496 _DBFIT(temp
, uint32_t);
499 /* Insert the left and right keys, set the header information. */
501 h
->linp
[0] = h
->upper
= (indx_t
)sz
;
502 dest
= (char *)(void *)h
+ h
->upper
;
504 l
->flags
& P_RLEAF
? NEXTINDEX(l
) : rec_total(l
), l
->pgno
);
506 h
->linp
[1] = h
->upper
-= NRINTERNAL
;
507 dest
= (char *)(void *)h
+ h
->upper
;
509 r
->flags
& P_RLEAF
? NEXTINDEX(r
) : rec_total(r
), r
->pgno
);
511 h
->lower
= BTDATAOFF
+ 2 * sizeof(indx_t
);
513 /* Unpin the root page, set to recno internal page. */
515 h
->flags
|= P_RINTERNAL
;
516 mpool_put(t
->bt_mp
, h
, MPOOL_DIRTY
);
518 return (RET_SUCCESS
);
522 * BT_BROOT -- Fix up the btree root page after it has been split.
531 * RET_ERROR, RET_SUCCESS
534 bt_broot(BTREE
*t
, PAGE
*h
, PAGE
*l
, PAGE
*r
)
536 BINTERNAL
*bi
= NULL
; /* pacify gcc */
542 * If the root page was a leaf page, change it into an internal page.
543 * We copy the key we split on (but not the key's data, in the case of
544 * a leaf page) to the new root page.
546 * The btree comparison code guarantees that the left-most key on any
547 * level of the tree is never used, so it doesn't need to be filled in.
549 nbytes
= NBINTERNAL(0);
550 h
->linp
[0] = h
->upper
= t
->bt_psize
- nbytes
;
551 dest
= (char *)(void *)h
+ h
->upper
;
552 WR_BINTERNAL(dest
, 0, l
->pgno
, 0);
554 switch (h
->flags
& P_TYPE
) {
557 nbytes
= NBINTERNAL(bl
->ksize
);
558 h
->linp
[1] = h
->upper
-= nbytes
;
559 dest
= (char *)(void *)h
+ h
->upper
;
560 WR_BINTERNAL(dest
, bl
->ksize
, r
->pgno
, 0);
561 memmove(dest
, bl
->bytes
, bl
->ksize
);
564 * If the key is on an overflow page, mark the overflow chain
565 * so it isn't deleted when the leaf copy of the key is deleted.
567 if (bl
->flags
& P_BIGKEY
&&
568 bt_preserve(t
, *(pgno_t
*)(void *)bl
->bytes
) == RET_ERROR
)
572 bi
= GETBINTERNAL(r
, 0);
573 nbytes
= NBINTERNAL(bi
->ksize
);
574 h
->linp
[1] = h
->upper
-= nbytes
;
575 dest
= (char *)(void *)h
+ h
->upper
;
576 memmove(dest
, bi
, nbytes
);
577 ((BINTERNAL
*)(void *)dest
)->pgno
= r
->pgno
;
583 /* There are two keys on the page. */
584 h
->lower
= BTDATAOFF
+ 2 * sizeof(indx_t
);
586 /* Unpin the root page, set to btree internal page. */
588 h
->flags
|= P_BINTERNAL
;
589 mpool_put(t
->bt_mp
, h
, MPOOL_DIRTY
);
591 return (RET_SUCCESS
);
595 * BT_PSPLIT -- Do the real work of splitting the page.
599 * h: page to be split
600 * l: page to put lower half of data
601 * r: page to put upper half of data
602 * pskip: pointer to index to leave open
603 * ilen: insert length
606 * Pointer to page in which to insert.
609 bt_psplit(BTREE
*t
, PAGE
*h
, PAGE
*l
, PAGE
*r
, indx_t
*pskip
, size_t ilen
)
616 void *src
= NULL
; /* pacify gcc */
617 indx_t full
, half
, nxt
, off
, skip
, top
, used
;
620 int bigkeycnt
, isbigkey
;
623 * Split the data to the left and right pages. Leave the skip index
624 * open. Additionally, make some effort not to split on an overflow
625 * key. This makes internal page processing faster and can save
626 * space as overflow keys used by internal pages are never deleted.
630 temp
= t
->bt_psize
- BTDATAOFF
;
631 _DBFIT(temp
, indx_t
);
635 for (nxt
= off
= 0, top
= NEXTINDEX(h
); nxt
< top
; ++off
) {
637 _DBFIT(ilen
, uint32_t);
638 nbytes
= (uint32_t)ilen
;
639 isbigkey
= 0; /* XXX: not really known. */
641 switch (h
->flags
& P_TYPE
) {
643 src
= bi
= GETBINTERNAL(h
, nxt
);
644 nbytes
= NBINTERNAL(bi
->ksize
);
645 isbigkey
= bi
->flags
& P_BIGKEY
;
648 src
= bl
= GETBLEAF(h
, nxt
);
650 isbigkey
= bl
->flags
& P_BIGKEY
;
653 src
= GETRINTERNAL(h
, nxt
);
658 src
= rl
= GETRLEAF(h
, nxt
);
667 * If the key/data pairs are substantial fractions of the max
668 * possible size for the page, it's possible to get situations
669 * where we decide to try and copy too much onto the left page.
670 * Make sure that doesn't happen.
672 if ((skip
<= off
&& used
+ nbytes
+ sizeof(indx_t
) >= full
) ||
678 /* Copy the key/data pair, if not the skipped index. */
682 l
->linp
[off
] = l
->upper
-= nbytes
;
683 memmove((char *)(void *)l
+ l
->upper
, src
, nbytes
);
686 temp
= nbytes
+ sizeof(indx_t
);
687 _DBFIT(temp
, indx_t
);
688 used
+= (indx_t
)temp
;
690 if (!isbigkey
|| bigkeycnt
== 3)
698 * Off is the last offset that's valid for the left page.
699 * Nxt is the first offset to be placed on the right page.
701 temp
= (off
+ 1) * sizeof(indx_t
);
702 _DBFIT(temp
, indx_t
);
703 l
->lower
+= (indx_t
)temp
;
706 * If splitting the page that the cursor was on, the cursor has to be
707 * adjusted to point to the same record as before the split. If the
708 * cursor is at or past the skipped slot, the cursor is incremented by
709 * one. If the cursor is on the right page, it is decremented by the
710 * number of records split to the left page.
713 if (F_ISSET(c
, CURS_INIT
) && c
->pg
.pgno
== h
->pgno
) {
714 if (c
->pg
.index
>= skip
)
716 if (c
->pg
.index
< nxt
) /* Left page. */
717 c
->pg
.pgno
= l
->pgno
;
718 else { /* Right page. */
719 c
->pg
.pgno
= r
->pgno
;
725 * If the skipped index was on the left page, just return that page.
726 * Otherwise, adjust the skip index to reflect the new position on
730 skip
= MAX_PAGE_OFFSET
;
737 for (off
= 0; nxt
< top
; ++off
) {
740 skip
= MAX_PAGE_OFFSET
;
742 switch (h
->flags
& P_TYPE
) {
744 src
= bi
= GETBINTERNAL(h
, nxt
);
745 nbytes
= NBINTERNAL(bi
->ksize
);
748 src
= bl
= GETBLEAF(h
, nxt
);
752 src
= GETRINTERNAL(h
, nxt
);
756 src
= rl
= GETRLEAF(h
, nxt
);
763 r
->linp
[off
] = r
->upper
-= nbytes
;
764 memmove((char *)(void *)r
+ r
->upper
, src
, nbytes
);
766 temp
= off
* sizeof(indx_t
);
767 _DBFIT(temp
, indx_t
);
768 r
->lower
+= (indx_t
)temp
;
770 /* If the key is being appended to the page, adjust the index. */
772 r
->lower
+= sizeof(indx_t
);
778 * BT_PRESERVE -- Mark a chain of pages as used by an internal node.
780 * Chains of indirect blocks pointed to by leaf nodes get reclaimed when the
781 * record that references them gets deleted. Chains pointed to by internal
782 * pages never get deleted. This routine marks a chain as pointed to by an
787 * pg: page number of first page in the chain.
790 * RET_SUCCESS, RET_ERROR.
793 bt_preserve(BTREE
*t
, pgno_t pg
)
797 if ((h
= mpool_get(t
->bt_mp
, pg
, 0)) == NULL
)
799 h
->flags
|= P_PRESERVE
;
800 mpool_put(t
->bt_mp
, h
, MPOOL_DIRTY
);
801 return (RET_SUCCESS
);
805 * REC_TOTAL -- Return the number of recno entries below a page.
811 * The number of recno entries below a page.
814 * These values could be set by the bt_psplit routine. The problem is that the
815 * entry has to be popped off of the stack etc. or the values have to be passed
816 * all the way back to bt_split/bt_rroot and it's not very clean.
824 for (recs
= 0, nxt
= 0, top
= NEXTINDEX(h
); nxt
< top
; ++nxt
)
825 recs
+= GETRINTERNAL(h
, nxt
)->nrecs
;