Rename variable 'index' to 'idx' to avoid name collision with index(3),

this commit does not affect any object code.

Obtained from:	OpenBSD
Verified with:	md5(1)
This commit is contained in:
Xin LI 2009-03-03 02:16:12 +00:00
parent 0ac22237f1
commit 4c66e4b64b
7 changed files with 87 additions and 101 deletions

View File

@ -142,7 +142,7 @@ __bt_stkacq(BTREE *t, PAGE **hp, CURSOR *c)
EPG *e; EPG *e;
EPGNO *parent; EPGNO *parent;
PAGE *h; PAGE *h;
indx_t index; indx_t idx;
pgno_t pgno; pgno_t pgno;
recno_t nextpg, prevpg; recno_t nextpg, prevpg;
int exact, level; int exact, level;
@ -180,8 +180,8 @@ __bt_stkacq(BTREE *t, PAGE **hp, CURSOR *c)
/* Move to the next index. */ /* Move to the next index. */
if (parent->index != NEXTINDEX(h) - 1) { if (parent->index != NEXTINDEX(h) - 1) {
index = parent->index + 1; idx = parent->index + 1;
BT_PUSH(t, h->pgno, index); BT_PUSH(t, h->pgno, idx);
break; break;
} }
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
@ -190,7 +190,7 @@ __bt_stkacq(BTREE *t, PAGE **hp, CURSOR *c)
/* Restore the stack. */ /* Restore the stack. */
while (level--) { while (level--) {
/* Push the next level down onto the stack. */ /* Push the next level down onto the stack. */
bi = GETBINTERNAL(h, index); bi = GETBINTERNAL(h, idx);
pgno = bi->pgno; pgno = bi->pgno;
BT_PUSH(t, pgno, 0); BT_PUSH(t, pgno, 0);
@ -200,7 +200,7 @@ __bt_stkacq(BTREE *t, PAGE **hp, CURSOR *c)
/* Get the next level down. */ /* Get the next level down. */
if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL)
return (1); return (1);
index = 0; idx = 0;
} }
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL) if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL)
@ -235,8 +235,8 @@ __bt_stkacq(BTREE *t, PAGE **hp, CURSOR *c)
/* Move to the next index. */ /* Move to the next index. */
if (parent->index != 0) { if (parent->index != 0) {
index = parent->index - 1; idx = parent->index - 1;
BT_PUSH(t, h->pgno, index); BT_PUSH(t, h->pgno, idx);
break; break;
} }
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
@ -245,7 +245,7 @@ __bt_stkacq(BTREE *t, PAGE **hp, CURSOR *c)
/* Restore the stack. */ /* Restore the stack. */
while (level--) { while (level--) {
/* Push the next level down onto the stack. */ /* Push the next level down onto the stack. */
bi = GETBINTERNAL(h, index); bi = GETBINTERNAL(h, idx);
pgno = bi->pgno; pgno = bi->pgno;
/* Lose the currently pinned page. */ /* Lose the currently pinned page. */
@ -255,8 +255,8 @@ __bt_stkacq(BTREE *t, PAGE **hp, CURSOR *c)
if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL)
return (1); return (1);
index = NEXTINDEX(h) - 1; idx = NEXTINDEX(h) - 1;
BT_PUSH(t, pgno, index); BT_PUSH(t, pgno, idx);
} }
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL) if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL)
@ -370,7 +370,7 @@ __bt_pdelete(BTREE *t, PAGE *h)
BINTERNAL *bi; BINTERNAL *bi;
PAGE *pg; PAGE *pg;
EPGNO *parent; EPGNO *parent;
indx_t cnt, index, *ip, offset; indx_t cnt, idx, *ip, offset;
u_int32_t nksize; u_int32_t nksize;
char *from; char *from;
@ -391,8 +391,8 @@ __bt_pdelete(BTREE *t, PAGE *h)
if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
index = parent->index; idx = parent->index;
bi = GETBINTERNAL(pg, index); bi = GETBINTERNAL(pg, idx);
/* Free any overflow pages. */ /* Free any overflow pages. */
if (bi->flags & P_BIGKEY && if (bi->flags & P_BIGKEY &&
@ -424,11 +424,11 @@ __bt_pdelete(BTREE *t, PAGE *h)
pg->upper += nksize; pg->upper += nksize;
/* Adjust indices' offsets, shift the indices down. */ /* Adjust indices' offsets, shift the indices down. */
offset = pg->linp[index]; offset = pg->linp[idx];
for (cnt = index, ip = &pg->linp[0]; cnt--; ++ip) for (cnt = idx, ip = &pg->linp[0]; cnt--; ++ip)
if (ip[0] < offset) if (ip[0] < offset)
ip[0] += nksize; ip[0] += nksize;
for (cnt = NEXTINDEX(pg) - index; --cnt; ++ip) for (cnt = NEXTINDEX(pg) - idx; --cnt; ++ip)
ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1]; ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1];
pg->lower -= sizeof(indx_t); pg->lower -= sizeof(indx_t);
} }
@ -453,17 +453,13 @@ __bt_pdelete(BTREE *t, PAGE *h)
* t: tree * t: tree
* key: referenced key * key: referenced key
* h: page * h: page
* index: index on page to delete * idx: index on page to delete
* *
* Returns: * Returns:
* RET_SUCCESS, RET_ERROR. * RET_SUCCESS, RET_ERROR.
*/ */
int int
__bt_dleaf(t, key, h, index) __bt_dleaf(BTREE *t, const DBT *key, PAGE *h, u_int idx)
BTREE *t;
const DBT *key;
PAGE *h;
u_int index;
{ {
BLEAF *bl; BLEAF *bl;
indx_t cnt, *ip, offset; indx_t cnt, *ip, offset;
@ -474,12 +470,12 @@ __bt_dleaf(t, key, h, index)
/* If this record is referenced by the cursor, delete the cursor. */ /* If this record is referenced by the cursor, delete the cursor. */
if (F_ISSET(&t->bt_cursor, CURS_INIT) && if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
!F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == index && t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == idx &&
__bt_curdel(t, key, h, index)) __bt_curdel(t, key, h, idx))
return (RET_ERROR); return (RET_ERROR);
/* If the entry uses overflow pages, make them available for reuse. */ /* If the entry uses overflow pages, make them available for reuse. */
to = bl = GETBLEAF(h, index); to = bl = GETBLEAF(h, idx);
if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR) if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR)
return (RET_ERROR); return (RET_ERROR);
if (bl->flags & P_BIGDATA && if (bl->flags & P_BIGDATA &&
@ -493,18 +489,18 @@ __bt_dleaf(t, key, h, index)
h->upper += nbytes; h->upper += nbytes;
/* Adjust the indices' offsets, shift the indices down. */ /* Adjust the indices' offsets, shift the indices down. */
offset = h->linp[index]; offset = h->linp[idx];
for (cnt = index, ip = &h->linp[0]; cnt--; ++ip) for (cnt = idx, ip = &h->linp[0]; cnt--; ++ip)
if (ip[0] < offset) if (ip[0] < offset)
ip[0] += nbytes; ip[0] += nbytes;
for (cnt = NEXTINDEX(h) - index; --cnt; ++ip) for (cnt = NEXTINDEX(h) - idx; --cnt; ++ip)
ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1];
h->lower -= sizeof(indx_t); h->lower -= sizeof(indx_t);
/* If the cursor is on this page, adjust it as necessary. */ /* If the cursor is on this page, adjust it as necessary. */
if (F_ISSET(&t->bt_cursor, CURS_INIT) && if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
!F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > index) t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > idx)
--t->bt_cursor.pg.index; --t->bt_cursor.pg.index;
return (RET_SUCCESS); return (RET_SUCCESS);
@ -518,17 +514,13 @@ __bt_dleaf(t, key, h, index)
* t: tree * t: tree
* key: referenced key (or NULL) * key: referenced key (or NULL)
* h: page * h: page
* index: index on page to delete * idx: index on page to delete
* *
* Returns: * Returns:
* RET_SUCCESS, RET_ERROR. * RET_SUCCESS, RET_ERROR.
*/ */
static int static int
__bt_curdel(t, key, h, index) __bt_curdel(BTREE *t, const DBT *key, PAGE *h, u_int idx)
BTREE *t;
const DBT *key;
PAGE *h;
u_int index;
{ {
CURSOR *c; CURSOR *c;
EPG e; EPG e;
@ -551,7 +543,7 @@ __bt_curdel(t, key, h, index)
*/ */
if (key == NULL) { if (key == NULL) {
e.page = h; e.page = h;
e.index = index; e.index = idx;
if ((status = __bt_ret(t, &e, if ((status = __bt_ret(t, &e,
&c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS) &c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS)
return (status); return (status);
@ -559,25 +551,25 @@ __bt_curdel(t, key, h, index)
key = &c->key; key = &c->key;
} }
/* Check previous key, if not at the beginning of the page. */ /* Check previous key, if not at the beginning of the page. */
if (index > 0) { if (idx > 0) {
e.page = h; e.page = h;
e.index = index - 1; e.index = idx - 1;
if (__bt_cmp(t, key, &e) == 0) { if (__bt_cmp(t, key, &e) == 0) {
F_SET(c, CURS_BEFORE); F_SET(c, CURS_BEFORE);
goto dup2; goto dup2;
} }
} }
/* Check next key, if not at the end of the page. */ /* Check next key, if not at the end of the page. */
if (index < NEXTINDEX(h) - 1) { if (idx < NEXTINDEX(h) - 1) {
e.page = h; e.page = h;
e.index = index + 1; e.index = idx + 1;
if (__bt_cmp(t, key, &e) == 0) { if (__bt_cmp(t, key, &e) == 0) {
F_SET(c, CURS_AFTER); F_SET(c, CURS_AFTER);
goto dup2; goto dup2;
} }
} }
/* Check previous key if at the beginning of the page. */ /* Check previous key if at the beginning of the page. */
if (index == 0 && h->prevpg != P_INVALID) { if (idx == 0 && h->prevpg != P_INVALID) {
if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
e.page = pg; e.page = pg;
@ -589,7 +581,7 @@ __bt_curdel(t, key, h, index)
mpool_put(t->bt_mp, pg, 0); mpool_put(t->bt_mp, pg, 0);
} }
/* Check next key if at the end of the page. */ /* Check next key if at the end of the page. */
if (index == NEXTINDEX(h) - 1 && h->nextpg != P_INVALID) { if (idx == NEXTINDEX(h) - 1 && h->nextpg != P_INVALID) {
if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
e.page = pg; e.page = pg;
@ -605,7 +597,7 @@ dup2: c->pg.pgno = e.page->pgno;
} }
} }
e.page = h; e.page = h;
e.index = index; e.index = idx;
if (curcopy || (status = if (curcopy || (status =
__bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) { __bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) {
F_SET(c, CURS_ACQUIRE); F_SET(c, CURS_ACQUIRE);

View File

@ -68,7 +68,7 @@ __bt_put(const DB *dbp, DBT *key, const DBT *data, u_int flags)
DBT tkey, tdata; DBT tkey, tdata;
EPG *e; EPG *e;
PAGE *h; PAGE *h;
indx_t index, nxtindex; indx_t idx, nxtindex;
pgno_t pg; pgno_t pg;
u_int32_t nbytes, tmp; u_int32_t nbytes, tmp;
int dflags, exact, status; int dflags, exact, status;
@ -149,7 +149,7 @@ storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR)
if (flags == R_CURSOR) { if (flags == R_CURSOR) {
if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL) if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
index = t->bt_cursor.pg.index; idx = t->bt_cursor.pg.index;
goto delete; goto delete;
} }
@ -161,7 +161,7 @@ storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR)
if ((e = __bt_search(t, key, &exact)) == NULL) if ((e = __bt_search(t, key, &exact)) == NULL)
return (RET_ERROR); return (RET_ERROR);
h = e->page; h = e->page;
index = e->index; idx = e->index;
/* /*
* Add the key/data pair to the tree. If an identical key is already * Add the key/data pair to the tree. If an identical key is already
@ -183,7 +183,7 @@ storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR)
* Note, the delete may empty the page, so we need to put a * Note, the delete may empty the page, so we need to put a
* new entry into the page immediately. * new entry into the page immediately.
*/ */
delete: if (__bt_dleaf(t, key, h, index) == RET_ERROR) { delete: if (__bt_dleaf(t, key, h, idx) == RET_ERROR) {
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
return (RET_ERROR); return (RET_ERROR);
} }
@ -199,35 +199,35 @@ delete: if (__bt_dleaf(t, key, h, index) == RET_ERROR) {
nbytes = NBLEAFDBT(key->size, data->size); nbytes = NBLEAFDBT(key->size, data->size);
if (h->upper - h->lower < nbytes + sizeof(indx_t)) { if (h->upper - h->lower < nbytes + sizeof(indx_t)) {
if ((status = __bt_split(t, h, key, if ((status = __bt_split(t, h, key,
data, dflags, nbytes, index)) != RET_SUCCESS) data, dflags, nbytes, idx)) != RET_SUCCESS)
return (status); return (status);
goto success; goto success;
} }
if (index < (nxtindex = NEXTINDEX(h))) if (idx < (nxtindex = NEXTINDEX(h)))
memmove(h->linp + index + 1, h->linp + index, memmove(h->linp + idx + 1, h->linp + idx,
(nxtindex - index) * sizeof(indx_t)); (nxtindex - idx) * sizeof(indx_t));
h->lower += sizeof(indx_t); h->lower += sizeof(indx_t);
h->linp[index] = h->upper -= nbytes; h->linp[idx] = h->upper -= nbytes;
dest = (char *)h + h->upper; dest = (char *)h + h->upper;
WR_BLEAF(dest, key, data, dflags); WR_BLEAF(dest, key, data, dflags);
/* If the cursor is on this page, adjust it as necessary. */ /* If the cursor is on this page, adjust it as necessary. */
if (F_ISSET(&t->bt_cursor, CURS_INIT) && if (F_ISSET(&t->bt_cursor, CURS_INIT) &&
!F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) &&
t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= index) t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= idx)
++t->bt_cursor.pg.index; ++t->bt_cursor.pg.index;
if (t->bt_order == NOT) { if (t->bt_order == NOT) {
if (h->nextpg == P_INVALID) { if (h->nextpg == P_INVALID) {
if (index == NEXTINDEX(h) - 1) { if (idx == NEXTINDEX(h) - 1) {
t->bt_order = FORWARD; t->bt_order = FORWARD;
t->bt_last.index = index; t->bt_last.index = idx;
t->bt_last.pgno = h->pgno; t->bt_last.pgno = h->pgno;
} }
} else if (h->prevpg == P_INVALID) { } else if (h->prevpg == P_INVALID) {
if (index == 0) { if (idx == 0) {
t->bt_order = BACK; t->bt_order = BACK;
t->bt_last.index = 0; t->bt_last.index = 0;
t->bt_last.pgno = h->pgno; t->bt_last.pgno = h->pgno;

View File

@ -64,7 +64,7 @@ EPG *
__bt_search(BTREE *t, const DBT *key, int *exactp) __bt_search(BTREE *t, const DBT *key, int *exactp)
{ {
PAGE *h; PAGE *h;
indx_t base, index, lim; indx_t base, idx, lim;
pgno_t pg; pgno_t pg;
int cmp; int cmp;
@ -76,7 +76,7 @@ __bt_search(BTREE *t, const DBT *key, int *exactp)
/* Do a binary search on the current page. */ /* Do a binary search on the current page. */
t->bt_cur.page = h; t->bt_cur.page = h;
for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) { for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) {
t->bt_cur.index = index = base + (lim >> 1); t->bt_cur.index = idx = base + (lim >> 1);
if ((cmp = __bt_cmp(t, key, &t->bt_cur)) == 0) { if ((cmp = __bt_cmp(t, key, &t->bt_cur)) == 0) {
if (h->flags & P_BLEAF) { if (h->flags & P_BLEAF) {
*exactp = 1; *exactp = 1;
@ -85,7 +85,7 @@ __bt_search(BTREE *t, const DBT *key, int *exactp)
goto next; goto next;
} }
if (cmp > 0) { if (cmp > 0) {
base = index + 1; base = idx + 1;
--lim; --lim;
} }
} }
@ -121,10 +121,10 @@ __bt_search(BTREE *t, const DBT *key, int *exactp)
* be a parent page for the key. If a split later occurs, the * be a parent page for the key. If a split later occurs, the
* inserted page will be to the right of the saved page. * inserted page will be to the right of the saved page.
*/ */
index = base ? base - 1 : base; idx = base ? base - 1 : base;
next: BT_PUSH(t, h->pgno, index); next: BT_PUSH(t, h->pgno, idx);
pg = GETBINTERNAL(h, index)->pgno; pg = GETBINTERNAL(h, idx)->pgno;
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
} }
} }

View File

@ -232,7 +232,7 @@ __bt_seqadv(BTREE *t, EPG *ep, int flags)
{ {
CURSOR *c; CURSOR *c;
PAGE *h; PAGE *h;
indx_t index; indx_t idx;
pgno_t pg; pgno_t pg;
int exact; int exact;
@ -270,15 +270,15 @@ __bt_seqadv(BTREE *t, EPG *ep, int flags)
*/ */
if (F_ISSET(c, CURS_AFTER)) if (F_ISSET(c, CURS_AFTER))
goto usecurrent; goto usecurrent;
index = c->pg.index; idx = c->pg.index;
if (++index == NEXTINDEX(h)) { if (++idx == NEXTINDEX(h)) {
pg = h->nextpg; pg = h->nextpg;
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
if (pg == P_INVALID) if (pg == P_INVALID)
return (RET_SPECIAL); return (RET_SPECIAL);
if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
index = 0; idx = 0;
} }
break; break;
case R_PREV: /* Previous record. */ case R_PREV: /* Previous record. */
@ -293,22 +293,22 @@ usecurrent: F_CLR(c, CURS_AFTER | CURS_BEFORE);
ep->index = c->pg.index; ep->index = c->pg.index;
return (RET_SUCCESS); return (RET_SUCCESS);
} }
index = c->pg.index; idx = c->pg.index;
if (index == 0) { if (idx == 0) {
pg = h->prevpg; pg = h->prevpg;
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
if (pg == P_INVALID) if (pg == P_INVALID)
return (RET_SPECIAL); return (RET_SPECIAL);
if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL)
return (RET_ERROR); return (RET_ERROR);
index = NEXTINDEX(h) - 1; idx = NEXTINDEX(h) - 1;
} else } else
--index; --idx;
break; break;
} }
ep->page = h; ep->page = h;
ep->index = index; ep->index = idx;
return (RET_SUCCESS); return (RET_SUCCESS);
} }
@ -421,13 +421,10 @@ __bt_first(BTREE *t, const DBT *key, EPG *erval, int *exactp)
* Parameters: * Parameters:
* t: the tree * t: the tree
* pgno: page number * pgno: page number
* index: page index * idx: page index
*/ */
void void
__bt_setcur(t, pgno, index) __bt_setcur(BTREE *t, pgno_t pgno, u_int idx)
BTREE *t;
pgno_t pgno;
u_int index;
{ {
/* Lose any already deleted key. */ /* Lose any already deleted key. */
if (t->bt_cursor.key.data != NULL) { if (t->bt_cursor.key.data != NULL) {
@ -439,6 +436,6 @@ __bt_setcur(t, pgno, index)
/* Update the cursor. */ /* Update the cursor. */
t->bt_cursor.pg.pgno = pgno; t->bt_cursor.pg.pgno = pgno;
t->bt_cursor.pg.index = index; t->bt_cursor.pg.index = idx;
F_SET(&t->bt_cursor, CURS_INIT); F_SET(&t->bt_cursor, CURS_INIT);
} }

View File

@ -138,16 +138,13 @@ rec_rdelete(BTREE *t, recno_t nrec)
* *
* Parameters: * Parameters:
* t: tree * t: tree
* index: index on current page to delete * idx: index on current page to delete
* *
* Returns: * Returns:
* RET_SUCCESS, RET_ERROR. * RET_SUCCESS, RET_ERROR.
*/ */
int int
__rec_dleaf(t, h, index) __rec_dleaf(BTREE *t, PAGE *h, u_int32_t idx)
BTREE *t;
PAGE *h;
u_int32_t index;
{ {
RLEAF *rl; RLEAF *rl;
indx_t *ip, cnt, offset; indx_t *ip, cnt, offset;
@ -165,7 +162,7 @@ __rec_dleaf(t, h, index)
* down, overwriting the deleted record and its index. If the record * down, overwriting the deleted record and its index. If the record
* uses overflow pages, make them available for reuse. * uses overflow pages, make them available for reuse.
*/ */
to = rl = GETRLEAF(h, index); to = rl = GETRLEAF(h, idx);
if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR) if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR)
return (RET_ERROR); return (RET_ERROR);
nbytes = NRLEAF(rl); nbytes = NRLEAF(rl);
@ -178,8 +175,8 @@ __rec_dleaf(t, h, index)
memmove(from + nbytes, from, (char *)to - from); memmove(from + nbytes, from, (char *)to - from);
h->upper += nbytes; h->upper += nbytes;
offset = h->linp[index]; offset = h->linp[idx];
for (cnt = &h->linp[index] - (ip = &h->linp[0]); cnt--; ++ip) for (cnt = &h->linp[idx] - (ip = &h->linp[0]); cnt--; ++ip)
if (ip[0] < offset) if (ip[0] < offset)
ip[0] += nbytes; ip[0] += nbytes;
for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip) for (cnt = &h->linp[NEXTINDEX(h)] - ip; --cnt; ++ip)

View File

@ -191,7 +191,7 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags)
DBT tdata; DBT tdata;
EPG *e; EPG *e;
PAGE *h; PAGE *h;
indx_t index, nxtindex; indx_t idx, nxtindex;
pgno_t pg; pgno_t pg;
u_int32_t nbytes; u_int32_t nbytes;
int dflags, status; int dflags, status;
@ -222,7 +222,7 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags)
return (RET_ERROR); return (RET_ERROR);
h = e->page; h = e->page;
index = e->index; idx = e->index;
/* /*
* Add the specified key/data pair to the tree. The R_IAFTER and * Add the specified key/data pair to the tree. The R_IAFTER and
@ -232,13 +232,13 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags)
*/ */
switch (flags) { switch (flags) {
case R_IAFTER: case R_IAFTER:
++index; ++idx;
break; break;
case R_IBEFORE: case R_IBEFORE:
break; break;
default: default:
if (nrec < t->bt_nrecs && if (nrec < t->bt_nrecs &&
__rec_dleaf(t, h, index) == RET_ERROR) { __rec_dleaf(t, h, idx) == RET_ERROR) {
mpool_put(t->bt_mp, h, 0); mpool_put(t->bt_mp, h, 0);
return (RET_ERROR); return (RET_ERROR);
} }
@ -252,18 +252,18 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags)
*/ */
nbytes = NRLEAFDBT(data->size); nbytes = NRLEAFDBT(data->size);
if (h->upper - h->lower < nbytes + sizeof(indx_t)) { if (h->upper - h->lower < nbytes + sizeof(indx_t)) {
status = __bt_split(t, h, NULL, data, dflags, nbytes, index); status = __bt_split(t, h, NULL, data, dflags, nbytes, idx);
if (status == RET_SUCCESS) if (status == RET_SUCCESS)
++t->bt_nrecs; ++t->bt_nrecs;
return (status); return (status);
} }
if (index < (nxtindex = NEXTINDEX(h))) if (idx < (nxtindex = NEXTINDEX(h)))
memmove(h->linp + index + 1, h->linp + index, memmove(h->linp + idx + 1, h->linp + idx,
(nxtindex - index) * sizeof(indx_t)); (nxtindex - idx) * sizeof(indx_t));
h->lower += sizeof(indx_t); h->lower += sizeof(indx_t);
h->linp[index] = h->upper -= nbytes; h->linp[idx] = h->upper -= nbytes;
dest = (char *)h + h->upper; dest = (char *)h + h->upper;
WR_RLEAF(dest, data, dflags); WR_RLEAF(dest, data, dflags);

View File

@ -61,7 +61,7 @@ __FBSDID("$FreeBSD$");
EPG * EPG *
__rec_search(BTREE *t, recno_t recno, enum SRCHOP op) __rec_search(BTREE *t, recno_t recno, enum SRCHOP op)
{ {
indx_t index; indx_t idx;
PAGE *h; PAGE *h;
EPGNO *parent; EPGNO *parent;
RINTERNAL *r; RINTERNAL *r;
@ -79,23 +79,23 @@ __rec_search(BTREE *t, recno_t recno, enum SRCHOP op)
t->bt_cur.index = recno - total; t->bt_cur.index = recno - total;
return (&t->bt_cur); return (&t->bt_cur);
} }
for (index = 0, top = NEXTINDEX(h);;) { for (idx = 0, top = NEXTINDEX(h);;) {
r = GETRINTERNAL(h, index); r = GETRINTERNAL(h, idx);
if (++index == top || total + r->nrecs > recno) if (++idx == top || total + r->nrecs > recno)
break; break;
total += r->nrecs; total += r->nrecs;
} }
BT_PUSH(t, pg, index - 1); BT_PUSH(t, pg, idx - 1);
pg = r->pgno; pg = r->pgno;
switch (op) { switch (op) {
case SDELETE: case SDELETE:
--GETRINTERNAL(h, (index - 1))->nrecs; --GETRINTERNAL(h, (idx - 1))->nrecs;
mpool_put(t->bt_mp, h, MPOOL_DIRTY); mpool_put(t->bt_mp, h, MPOOL_DIRTY);
break; break;
case SINSERT: case SINSERT:
++GETRINTERNAL(h, (index - 1))->nrecs; ++GETRINTERNAL(h, (idx - 1))->nrecs;
mpool_put(t->bt_mp, h, MPOOL_DIRTY); mpool_put(t->bt_mp, h, MPOOL_DIRTY);
break; break;
case SEARCH: case SEARCH: