diff options
Diffstat (limited to 'db2')
52 files changed, 451 insertions, 345 deletions
diff --git a/db2/Makefile b/db2/Makefile index a7521b6..a75dc5a 100644 --- a/db2/Makefile +++ b/db2/Makefile @@ -19,7 +19,7 @@ # # Sub-makefile for libdb. # -# The code is lifted straight from the db 2.3.4 distribution +# The code is lifted straight from the db 2.3.6 distribution # with minimal changes. # @@ -90,6 +90,7 @@ $(objpfx)db_checkpoint: $(objpfx)libdb.so$(libdb.so-version) $(objpfx)db_deadlock: $(objpfx)libdb.so$(libdb.so-version) $(objpfx)db_dump: $(objpfx)libdb.so$(libdb.so-version) $(objpfx)db_load: $(objpfx)libdb.so$(libdb.so-version) +$(objpfx)db_printlog: $(objpfx)libdb.so$(libdb.so-version) $(objpfx)db_recover: $(objpfx)libdb.so$(libdb.so-version) $(objpfx)db_stat: $(objpfx)libdb.so$(libdb.so-version) else @@ -100,6 +101,7 @@ $(objpfx)db_checkpoint: $(objpfx)libdb.a $(objpfx)db_deadlock: $(objpfx)libdb.a $(objpfx)db_dump: $(objpfx)libdb.a $(objpfx)db_load: $(objpfx)libdb.a +$(objpfx)db_printlog: $(objpfx)libdb.a $(objpfx)db_recover: $(objpfx)libdb.a $(objpfx)db_stat: $(objpfx)libdb.a endif diff --git a/db2/btree/bt_close.c b/db2/btree/bt_close.c index 4e80634..7044599 100644 --- a/db2/btree/bt_close.c +++ b/db2/btree/bt_close.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_close.c 10.22 (Sleepycat) 8/23/97"; +static const char sccsid[] = "@(#)bt_close.c 10.23 (Sleepycat) 9/2/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -157,14 +157,12 @@ __bam_upstat(dbp) if (F_ISSET(dbp, DB_AM_INMEM | DB_AM_RDONLY)) return; - /* Lock the page. */ - if (__bam_lget(dbp, 0, pgno, DB_LOCK_WRITE, &mlock) != 0) - return; - flags = 0; pgno = PGNO_METADATA; - /* Get the page. */ + /* Lock and retrieve the page. */ + if (__bam_lget(dbp, 0, pgno, DB_LOCK_WRITE, &mlock) != 0) + return; if (__bam_pget(dbp, (PAGE **)&meta, &pgno, 0) == 0) { /* Log the change. */ if (DB_LOGGING(dbp) && diff --git a/db2/btree/bt_compare.c b/db2/btree/bt_compare.c index e802fd2..a68b1fa 100644 --- a/db2/btree/bt_compare.c +++ b/db2/btree/bt_compare.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_compare.c 10.3 (Sleepycat) 7/19/97"; +static const char sccsid[] = "@(#)bt_compare.c 10.4 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -103,7 +103,7 @@ __bam_cmp(dbp, k1, e) bo = NULL; if (TYPE(h) == P_LBTREE) { bk = GET_BKEYDATA(h, e->indx); - if (bk->type == B_OVERFLOW) + if (B_TYPE(bk->type) == B_OVERFLOW) bo = (BOVERFLOW *)bk; else { memset(&k2, 0, sizeof(k2)); @@ -112,7 +112,7 @@ __bam_cmp(dbp, k1, e) } } else { bi = GET_BINTERNAL(h, e->indx); - if (bi->type == B_OVERFLOW) + if (B_TYPE(bi->type) == B_OVERFLOW) bo = (BOVERFLOW *)(bi->data); else { memset(&k2, 0, sizeof(k2)); diff --git a/db2/btree/bt_conv.c b/db2/btree/bt_conv.c index 537e2f9..c9d5d1b 100644 --- a/db2/btree/bt_conv.c +++ b/db2/btree/bt_conv.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_conv.c 10.3 (Sleepycat) 8/9/97"; +static const char sccsid[] = "@(#)bt_conv.c 10.4 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -69,6 +69,8 @@ __bam_mswap(pg) u_int8_t *p; p = (u_int8_t *)pg; + + /* Swap the meta-data information. */ SWAP32(p); /* lsn.file */ SWAP32(p); /* lsn.offset */ SWAP32(p); /* pgno */ @@ -79,5 +81,19 @@ __bam_mswap(pg) SWAP32(p); /* minkey */ SWAP32(p); /* free */ SWAP32(p); /* flags */ + + /* Swap the statistics. */ + p = (u_int8_t *)&((BTMETA *)pg)->stat; + SWAP32(p); /* bt_freed */ + SWAP32(p); /* bt_pfxsaved */ + SWAP32(p); /* bt_split */ + SWAP32(p); /* bt_rootsplit */ + SWAP32(p); /* bt_fastsplit */ + SWAP32(p); /* bt_added */ + SWAP32(p); /* bt_deleted */ + SWAP32(p); /* bt_get */ + SWAP32(p); /* bt_cache_hit */ + SWAP32(p); /* bt_cache_miss */ + return (0); } diff --git a/db2/btree/bt_cursor.c b/db2/btree/bt_cursor.c index 592ec9b..efae556 100644 --- a/db2/btree/bt_cursor.c +++ b/db2/btree/bt_cursor.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_cursor.c 10.26 (Sleepycat) 8/24/97"; +static const char sccsid[] = "@(#)bt_cursor.c 10.27 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -201,9 +201,9 @@ __bam_c_del(dbc, flags) /* Set the intent-to-delete flag on the page and in all cursors. */ if (cp->dpgno == PGNO_INVALID) - GET_BKEYDATA(h, indx + O_INDX)->deleted = 1; + B_DSET(GET_BKEYDATA(h, indx + O_INDX)->type); else - GET_BKEYDATA(h, indx)->deleted = 1; + B_DSET(GET_BKEYDATA(h, indx)->type); (void)__bam_ca_delete(dbp, pgno, indx, NULL); ret = memp_fput(dbp->mpf, h, DB_MPOOL_DIRTY); @@ -643,7 +643,7 @@ __bam_c_first(dbp, cp) /* If it's an empty page or a deleted record, go to the next one. */ if (NUM_ENT(cp->page) == 0 || - GET_BKEYDATA(cp->page, cp->indx + O_INDX)->deleted) + B_DISSET(GET_BKEYDATA(cp->page, cp->indx + O_INDX)->type)) if ((ret = __bam_c_next(dbp, cp, 0)) != 0) return (ret); @@ -653,7 +653,7 @@ __bam_c_first(dbp, cp) /* If it's a deleted record, go to the next one. */ if (cp->dpgno != PGNO_INVALID && - GET_BKEYDATA(cp->page, cp->dindx)->deleted) + B_DISSET(GET_BKEYDATA(cp->page, cp->dindx)->type)) if ((ret = __bam_c_next(dbp, cp, 0)) != 0) return (ret); return (0); @@ -694,7 +694,7 @@ __bam_c_last(dbp, cp) /* If it's an empty page or a deleted record, go to the previous one. */ if (NUM_ENT(cp->page) == 0 || - GET_BKEYDATA(cp->page, cp->indx + O_INDX)->deleted) + B_DISSET(GET_BKEYDATA(cp->page, cp->indx + O_INDX)->type)) if ((ret = __bam_c_prev(dbp, cp)) != 0) return (ret); @@ -704,7 +704,7 @@ __bam_c_last(dbp, cp) /* If it's a deleted record, go to the previous one. */ if (cp->dpgno != PGNO_INVALID && - GET_BKEYDATA(cp->page, cp->dindx)->deleted) + B_DISSET(GET_BKEYDATA(cp->page, cp->dindx)->type)) if ((ret = __bam_c_prev(dbp, cp)) != 0) return (ret); return (0); @@ -793,9 +793,9 @@ __bam_c_next(dbp, cp, initial_move) /* Ignore deleted records. */ if (dbp->type == DB_BTREE && ((cp->dpgno == PGNO_INVALID && - GET_BKEYDATA(cp->page, indx + O_INDX)->deleted) || + B_DISSET(GET_BKEYDATA(cp->page, indx + O_INDX)->type)) || (cp->dpgno != PGNO_INVALID && - GET_BKEYDATA(cp->page, indx)->deleted))) { + B_DISSET(GET_BKEYDATA(cp->page, indx)->type)))) { indx += adjust; continue; } @@ -908,9 +908,9 @@ __bam_c_prev(dbp, cp) indx -= adjust; if (dbp->type == DB_BTREE && ((cp->dpgno == PGNO_INVALID && - GET_BKEYDATA(cp->page, indx + O_INDX)->deleted) || + B_DISSET(GET_BKEYDATA(cp->page, indx + O_INDX)->type)) || (cp->dpgno != PGNO_INVALID && - GET_BKEYDATA(cp->page, indx)->deleted))) + B_DISSET(GET_BKEYDATA(cp->page, indx)->type)))) continue; /* @@ -997,7 +997,7 @@ __bam_c_search(dbp, cp, key, flags, isrecno, exactp) /* If it's a deleted record, go to the next or previous one. */ if (cp->dpgno != PGNO_INVALID && - GET_BKEYDATA(cp->page, cp->dindx)->deleted) + B_DISSET(GET_BKEYDATA(cp->page, cp->dindx)->type)) if (flags == S_KEYLAST) { if ((ret = __bam_c_prev(dbp, cp)) != 0) return (ret); @@ -1027,7 +1027,7 @@ __bam_ovfl_chk(dbp, cp, indx, to_end) /* Check for an overflow entry. */ bo = GET_BOVERFLOW(cp->page, indx); - if (bo->type != B_DUPLICATE) + if (B_TYPE(bo->type) != B_DUPLICATE) return (0); /* diff --git a/db2/btree/bt_delete.c b/db2/btree/bt_delete.c index e7ec4df..9892954 100644 --- a/db2/btree/bt_delete.c +++ b/db2/btree/bt_delete.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_delete.c 10.18 (Sleepycat) 8/24/97"; +static const char sccsid[] = "@(#)bt_delete.c 10.21 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -107,7 +107,7 @@ __bam_delete(argdbp, txn, key, flags) break; for (; cnt > 0; --cnt, ++t->lstat.bt_deleted) if (__bam_ca_delete(dbp, h->pgno, indx, NULL) != 0) { - GET_BKEYDATA(h, indx + O_INDX)->deleted = 1; + B_DSET(GET_BKEYDATA(h, indx + O_INDX)->type); indx += P_INDX; } else if ((ret = __bam_ditem(dbp, h, indx)) != 0 || (ret = __bam_ditem(dbp, h, indx)) != 0) @@ -180,7 +180,7 @@ __ram_delete(argdbp, txn, key, flags) stack = 1; /* If the record has already been deleted, we couldn't have found it. */ - if (GET_BKEYDATA(h, indx)->deleted) { + if (B_DISSET(GET_BKEYDATA(h, indx)->type)) { ret = DB_KEYEMPTY; goto done; } @@ -193,14 +193,13 @@ __ram_delete(argdbp, txn, key, flags) if ((ret = __bam_ditem(dbp, h, indx)) != 0) goto err; - bk.deleted = 1; - bk.type = B_KEYDATA; + B_TSET(bk.type, B_KEYDATA, 1); bk.len = 0; memset(&hdr, 0, sizeof(hdr)); hdr.data = &bk; hdr.size = SSZA(BKEYDATA, data); memset(&data, 0, sizeof(data)); - data.data = (char *) ""; + data.data = (char *)""; data.size = 0; if ((ret = __db_pitem(dbp, h, indx, BKEYDATA_SIZE(0), &hdr, &data)) != 0) @@ -263,7 +262,7 @@ __bam_ditem(dbp, h, indx) switch (TYPE(h)) { case P_IBTREE: bi = GET_BINTERNAL(h, indx); - switch (bi->type) { + switch (B_TYPE(bi->type)) { case B_DUPLICATE: case B_OVERFLOW: nbytes = BINTERNAL_SIZE(bi->len); @@ -298,14 +297,14 @@ __bam_ditem(dbp, h, indx) /* FALLTHROUGH */ case P_LRECNO: bk = GET_BKEYDATA(h, indx); - switch (bk->type) { + switch (B_TYPE(bk->type)) { case B_DUPLICATE: case B_OVERFLOW: nbytes = BOVERFLOW_SIZE; offpage: /* Delete duplicate/offpage chains. */ bo = GET_BOVERFLOW(h, indx); - if (bo->type == B_DUPLICATE) { + if (B_TYPE(bo->type) == B_DUPLICATE) { if ((ret = __db_ddup(dbp, bo->pgno, __bam_free)) != 0) return (ret); diff --git a/db2/btree/bt_put.c b/db2/btree/bt_put.c index 632c3d1..0f0b1e7 100644 --- a/db2/btree/bt_put.c +++ b/db2/btree/bt_put.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_put.c 10.23 (Sleepycat) 8/22/97"; +static const char sccsid[] = "@(#)bt_put.c 10.24 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -120,7 +120,7 @@ retry: /* */ replace = 0; if (exact && flags == DB_NOOVERWRITE) { - if (!GET_BKEYDATA(h, indx + O_INDX)->deleted) { + if (!B_DISSET(GET_BKEYDATA(h, indx + O_INDX)->type)) { ret = DB_KEYEXIST; goto err; } @@ -436,16 +436,14 @@ __bam_iitem(dbp, hp, indxp, key, data, op, flags) */ bigkey = bigdata = 0; if (LF_ISSET(BI_NEWKEY) && key->size > t->bt_ovflsize) { - kbo.deleted = 0; - kbo.type = B_OVERFLOW; + B_TSET(kbo.type, B_OVERFLOW, 0); kbo.tlen = key->size; if ((ret = __db_poff(dbp, key, &kbo.pgno, __bam_new)) != 0) goto err; bigkey = 1; } if (data->size > t->bt_ovflsize) { - dbo.deleted = 0; - dbo.type = B_OVERFLOW; + B_TSET(dbo.type, B_OVERFLOW, 0); dbo.tlen = data->size; if ((ret = __db_poff(dbp, data, &dbo.pgno, __bam_new)) != 0) goto err; @@ -472,7 +470,7 @@ __bam_iitem(dbp, hp, indxp, key, data, op, flags) if (op == DB_CURRENT) { bk = GET_BKEYDATA(h, indx + (TYPE(h) == P_LBTREE ? O_INDX : 0)); - if (bk->type == B_OVERFLOW) + if (B_TYPE(bk->type) == B_OVERFLOW) have_bytes = BOVERFLOW_PSIZE; else have_bytes = BKEYDATA_PSIZE(bk->len); @@ -492,7 +490,7 @@ __bam_iitem(dbp, hp, indxp, key, data, op, flags) * alignment) and do a delete/insert otherwise. */ if (op == DB_CURRENT && !bigdata && - bk->type == B_KEYDATA && have_bytes == need_bytes) + B_TYPE(bk->type) == B_KEYDATA && have_bytes == need_bytes) dcopy = 1; if (have_bytes < need_bytes) needed += need_bytes - have_bytes; @@ -622,9 +620,8 @@ __bam_iitem(dbp, hp, indxp, key, data, op, flags) __data.size = data->size; if (LF_ISSET(BI_DELETED)) { + B_TSET(__bk.type, B_KEYDATA, 1); __bk.len = __data.size; - __bk.deleted = 1; - __bk.type = B_KEYDATA; __hdr.data = &__bk; __hdr.size = SSZA(BKEYDATA, data); ret = __db_pitem(dbp, h, indx, @@ -687,10 +684,10 @@ __bam_ndup(dbp, h, indx) if (indx >= NUM_ENT(h) || h->inp[first] != h->inp[indx]) break; bk = GET_BKEYDATA(h, indx); - sz += bk->type == B_KEYDATA ? + sz += B_TYPE(bk->type) == B_KEYDATA ? BKEYDATA_PSIZE(bk->len) : BOVERFLOW_PSIZE; bk = GET_BKEYDATA(h, indx + O_INDX); - sz += bk->type == B_KEYDATA ? + sz += B_TYPE(bk->type) == B_KEYDATA ? BKEYDATA_PSIZE(bk->len) : BOVERFLOW_PSIZE; } @@ -716,7 +713,7 @@ __bam_ndup(dbp, h, indx) /* Copy the entry to the new page. */ bk = GET_BKEYDATA(h, indx); hdr.data = bk; - hdr.size = bk->type == B_KEYDATA ? + hdr.size = B_TYPE(bk->type) == B_KEYDATA ? BKEYDATA_SIZE(bk->len) : BOVERFLOW_SIZE; if ((ret = __db_pitem(dbp, cp, cpindx, hdr.size, &hdr, NULL)) != 0) @@ -743,8 +740,7 @@ __bam_ndup(dbp, h, indx) } /* Put in a new data item that points to the duplicates page. */ - bo.deleted = 0; - bo.type = B_DUPLICATE; + B_TSET(bo.type, B_DUPLICATE, 0); bo.pgno = cp->pgno; bo.tlen = 0; @@ -828,14 +824,14 @@ __bam_partial(dbp, dbt, h, indx) */ if (indx < NUM_ENT(h)) { bk = GET_BKEYDATA(h, indx + (TYPE(h) == P_LBTREE ? O_INDX : 0)); - if (bk->type == B_OVERFLOW) { + if (B_TYPE(bk->type) == B_OVERFLOW) { bo = (BOVERFLOW *)bk; nbytes = bo->tlen; } else nbytes = bk->len; } else { bk = &tbk; - bk->type = B_KEYDATA; + B_TSET(bk->type, B_KEYDATA, 0); nbytes = bk->len = 0; } nbytes += dbt->doff + dbt->size + dbt->dlen; @@ -856,7 +852,7 @@ __bam_partial(dbp, dbt, h, indx) memset(t->bt_rdata.data, 0, nbytes); tlen = 0; - if (bk->type == B_OVERFLOW) { + if (B_TYPE(bk->type) == B_OVERFLOW) { /* Take up to doff bytes from the record. */ memset(©, 0, sizeof(copy)); if ((ret = __db_goff(dbp, ©, bo->tlen, diff --git a/db2/btree/bt_rec.c b/db2/btree/bt_rec.c index d4bc7f6..bf48e01 100644 --- a/db2/btree/bt_rec.c +++ b/db2/btree/bt_rec.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_rec.c 10.11 (Sleepycat) 8/22/97"; +static const char sccsid[] = "@(#)bt_rec.c 10.13 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -60,7 +60,7 @@ __bam_pg_alloc_recover(logp, dbtp, lsnp, redo, info) * Fix up the allocated page. If we're redoing the operation, we have * to get the page (creating it if it doesn't exist), and update its * LSN. If we're undoing the operation, we have to reset the page's - * LSN and put it on the free list. + * LSN and put it on the free list. * * Fix up the metadata page. If we're redoing the operation, we have * to get the metadata page and update its LSN and its free pointer. @@ -749,13 +749,13 @@ __bam_cdel_recover(logp, dbtp, lsnp, redo, info) cmp_p = log_compare(&LSN(pagep), &argp->lsn); if (cmp_p == 0 && redo) { /* Need to redo update described. */ - GET_BKEYDATA(pagep, argp->indx + O_INDX)->deleted = 1; + B_DSET(GET_BKEYDATA(pagep, argp->indx + O_INDX)->type); LSN(pagep) = *lsnp; modified = 1; } else if (cmp_n == 0 && !redo) { /* Need to undo update described. */ - GET_BKEYDATA(pagep, argp->indx + O_INDX)->deleted = 0; + B_DCLR(GET_BKEYDATA(pagep, argp->indx + O_INDX)->type); LSN(pagep) = argp->lsn; modified = 1; diff --git a/db2/btree/bt_recno.c b/db2/btree/bt_recno.c index cd8872a..42ef9cc 100644 --- a/db2/btree/bt_recno.c +++ b/db2/btree/bt_recno.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_recno.c 10.12 (Sleepycat) 8/25/97"; +static const char sccsid[] = "@(#)bt_recno.c 10.15 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -246,7 +246,7 @@ __ram_get(argdbp, txn, key, data, flags) indx = t->bt_csp->indx; /* If the record has already been deleted, we couldn't have found it. */ - if (GET_BKEYDATA(h, indx)->deleted) { + if (B_DISSET(GET_BKEYDATA(h, indx)->type)) { ret = DB_KEYEMPTY; goto done; } @@ -981,7 +981,7 @@ __ram_writeback(dbp) if ((ret = __db_write(fd, pad, rp->re_len, &nw)) != 0) goto err; - if (nw != (ssize_t) rp->re_len) { + if (nw != (ssize_t)rp->re_len) { ret = EIO; goto err; } diff --git a/db2/btree/bt_search.c b/db2/btree/bt_search.c index d5f20d4..fa3e018 100644 --- a/db2/btree/bt_search.c +++ b/db2/btree/bt_search.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_search.c 10.6 (Sleepycat) 8/22/97"; +static const char sccsid[] = "@(#)bt_search.c 10.7 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -258,17 +258,17 @@ match: *exactp = 1; */ if (LF_ISSET(S_DELNO)) { if (LF_ISSET(S_DUPLAST)) - while (GET_BKEYDATA(h, indx + O_INDX)->deleted && + while (B_DISSET(GET_BKEYDATA(h, indx + O_INDX)->type) && indx > 0 && h->inp[indx] == h->inp[indx - P_INDX]) indx -= P_INDX; else - while (GET_BKEYDATA(h, indx + O_INDX)->deleted && + while (B_DISSET(GET_BKEYDATA(h, indx + O_INDX)->type) && indx < (db_indx_t)(NUM_ENT(h) - P_INDX) && h->inp[indx] == h->inp[indx + P_INDX]) indx += P_INDX; - if (GET_BKEYDATA(h, indx + O_INDX)->deleted) + if (B_DISSET(GET_BKEYDATA(h, indx + O_INDX)->type)) goto notfound; } diff --git a/db2/btree/bt_split.c b/db2/btree/bt_split.c index 89cfcb5..25cfacc 100644 --- a/db2/btree/bt_split.c +++ b/db2/btree/bt_split.c @@ -44,7 +44,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_split.c 10.12 (Sleepycat) 8/24/97"; +static const char sccsid[] = "@(#)bt_split.c 10.14 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -394,8 +394,7 @@ __bam_broot(dbp, rootp, lp, rp) * level of the tree is never used, so it doesn't need to be filled in. */ bi.len = 0; - bi.deleted = 0; - bi.type = B_KEYDATA; + B_TSET(bi.type, B_KEYDATA, 0); bi.pgno = lp->pgno; if (F_ISSET(dbp, DB_BT_RECNUM)) { bi.nrecs = __bam_total(lp); @@ -405,7 +404,7 @@ __bam_broot(dbp, rootp, lp, rp) hdr.data = &bi; hdr.size = SSZA(BINTERNAL, data); memset(&data, 0, sizeof(data)); - data.data = (char *) ""; + data.data = (char *)""; data.size = 0; if ((ret = __db_pitem(dbp, rootp, 0, BINTERNAL_SIZE(0), &hdr, &data)) != 0) @@ -417,8 +416,7 @@ __bam_broot(dbp, rootp, lp, rp) child_bi = GET_BINTERNAL(rp, 0); bi.len = child_bi->len; - bi.deleted = 0; - bi.type = child_bi->type; + B_TSET(bi.type, child_bi->type, 0); bi.pgno = rp->pgno; if (F_ISSET(dbp, DB_BT_RECNUM)) { bi.nrecs = __bam_total(rp); @@ -433,18 +431,17 @@ __bam_broot(dbp, rootp, lp, rp) return (ret); /* Increment the overflow ref count. */ - if (child_bi->type == B_OVERFLOW && (ret = + if (B_TYPE(child_bi->type) == B_OVERFLOW && (ret = __db_ioff(dbp, ((BOVERFLOW *)(child_bi->data))->pgno)) != 0) return (ret); break; case P_LBTREE: /* Copy the first key of the child page onto the root page. */ child_bk = GET_BKEYDATA(rp, 0); - switch (child_bk->type) { + switch (B_TYPE(child_bk->type)) { case B_KEYDATA: bi.len = child_bk->len; - bi.deleted = 0; - bi.type = child_bk->type; + B_TSET(bi.type, child_bk->type, 0); bi.pgno = rp->pgno; if (F_ISSET(dbp, DB_BT_RECNUM)) { bi.nrecs = __bam_total(rp); @@ -461,8 +458,7 @@ __bam_broot(dbp, rootp, lp, rp) case B_DUPLICATE: case B_OVERFLOW: bi.len = BOVERFLOW_SIZE; - bi.deleted = 0; - bi.type = child_bk->type; + B_TSET(bi.type, child_bk->type, 0); bi.pgno = rp->pgno; if (F_ISSET(dbp, DB_BT_RECNUM)) { bi.nrecs = __bam_total(rp); @@ -477,7 +473,7 @@ __bam_broot(dbp, rootp, lp, rp) return (ret); /* Increment the overflow ref count. */ - if (child_bk->type == B_OVERFLOW && (ret = + if (B_TYPE(child_bk->type) == B_OVERFLOW && (ret = __db_ioff(dbp, ((BOVERFLOW *)child_bk)->pgno)) != 0) return (ret); break; @@ -594,8 +590,7 @@ __bam_pinsert(dbp, parent, lchild, rchild) /* Add a new record for the right page. */ bi.len = child_bi->len; - bi.deleted = 0; - bi.type = child_bi->type; + B_TSET(bi.type, child_bi->type, 0); bi.pgno = rchild->pgno; bi.nrecs = nrecs; memset(&hdr, 0, sizeof(hdr)); @@ -609,13 +604,13 @@ __bam_pinsert(dbp, parent, lchild, rchild) return (ret); /* Increment the overflow ref count. */ - if (child_bi->type == B_OVERFLOW && (ret = + if (B_TYPE(child_bi->type) == B_OVERFLOW && (ret = __db_ioff(dbp, ((BOVERFLOW *)(child_bi->data))->pgno)) != 0) return (ret); break; case P_LBTREE: child_bk = GET_BKEYDATA(rchild, 0); - switch (child_bk->type) { + switch (B_TYPE(child_bk->type)) { case B_KEYDATA: nbytes = BINTERNAL_PSIZE(child_bk->len); nksize = child_bk->len; @@ -624,7 +619,7 @@ __bam_pinsert(dbp, parent, lchild, rchild) if (ppage->prev_pgno == PGNO_INVALID && off <= 1) goto noprefix; tmp_bk = GET_BKEYDATA(lchild, NUM_ENT(lchild) - P_INDX); - if (tmp_bk->type != B_KEYDATA) + if (B_TYPE(tmp_bk->type) != B_KEYDATA) goto noprefix; memset(&a, 0, sizeof(a)); a.size = tmp_bk->len; @@ -643,8 +638,7 @@ noprefix: nksize = child_bk->len; return (DB_NEEDSPLIT); bi.len = nksize; - bi.deleted = 0; - bi.type = child_bk->type; + B_TSET(bi.type, child_bk->type, 0); bi.pgno = rchild->pgno; bi.nrecs = nrecs; memset(&hdr, 0, sizeof(hdr)); @@ -665,8 +659,7 @@ noprefix: nksize = child_bk->len; return (DB_NEEDSPLIT); bi.len = BOVERFLOW_SIZE; - bi.deleted = 0; - bi.type = child_bk->type; + B_TSET(bi.type, child_bk->type, 0); bi.pgno = rchild->pgno; bi.nrecs = nrecs; memset(&hdr, 0, sizeof(hdr)); @@ -680,7 +673,7 @@ noprefix: nksize = child_bk->len; return (ret); /* Increment the overflow ref count. */ - if (child_bk->type == B_OVERFLOW && (ret = + if (B_TYPE(child_bk->type) == B_OVERFLOW && (ret = __db_ioff(dbp, ((BOVERFLOW *)child_bk)->pgno)) != 0) return (ret); break; @@ -796,21 +789,21 @@ __bam_psplit(dbp, cp, lp, rp, cleft) for (nbytes = 0, off = 0; off < top && nbytes < half; ++off) switch (TYPE(pp)) { case P_IBTREE: - if (GET_BINTERNAL(pp, off)->type == B_KEYDATA) + if (B_TYPE(GET_BINTERNAL(pp, off)->type) == B_KEYDATA) nbytes += BINTERNAL_SIZE(GET_BINTERNAL(pp, off)->len); else nbytes += BINTERNAL_SIZE(BOVERFLOW_SIZE); break; case P_LBTREE: - if (GET_BKEYDATA(pp, off)->type == B_KEYDATA) + if (B_TYPE(GET_BKEYDATA(pp, off)->type) == B_KEYDATA) nbytes += BKEYDATA_SIZE(GET_BKEYDATA(pp, off)->len); else nbytes += BOVERFLOW_SIZE; ++off; - if (GET_BKEYDATA(pp, off)->type == B_KEYDATA) + if (B_TYPE(GET_BKEYDATA(pp, off)->type) == B_KEYDATA) nbytes += BKEYDATA_SIZE(GET_BKEYDATA(pp, off)->len); else @@ -832,9 +825,9 @@ sort: splitp = off; * it's a big key, try and find something close by that's not. */ if (TYPE(pp) == P_IBTREE) - isbigkey = GET_BINTERNAL(pp, off)->type != B_KEYDATA; + isbigkey = B_TYPE(GET_BINTERNAL(pp, off)->type) != B_KEYDATA; else if (TYPE(pp) == P_LBTREE) - isbigkey = GET_BKEYDATA(pp, off)->type != B_KEYDATA; + isbigkey = B_TYPE(GET_BKEYDATA(pp, off)->type) != B_KEYDATA; else isbigkey = 0; if (isbigkey) @@ -842,8 +835,8 @@ sort: splitp = off; off = splitp + cnt * adjust; if (off < (db_indx_t)NUM_ENT(pp) && ((TYPE(pp) == P_IBTREE && - GET_BINTERNAL(pp, off)->type == B_KEYDATA) || - GET_BKEYDATA(pp, off)->type == B_KEYDATA)) { + B_TYPE(GET_BINTERNAL(pp,off)->type) == B_KEYDATA) || + B_TYPE(GET_BKEYDATA(pp, off)->type) == B_KEYDATA)) { splitp = off; break; } @@ -851,8 +844,8 @@ sort: splitp = off; continue; off = splitp - cnt * adjust; if (TYPE(pp) == P_IBTREE ? - GET_BINTERNAL(pp, off)->type == B_KEYDATA : - GET_BKEYDATA(pp, off)->type == B_KEYDATA) { + B_TYPE(GET_BINTERNAL(pp, off)->type) == B_KEYDATA : + B_TYPE(GET_BKEYDATA(pp, off)->type) == B_KEYDATA) { splitp = off; break; } @@ -915,7 +908,7 @@ __bam_copy(dbp, pp, cp, nxt, stop) for (dup = off = 0; nxt < stop; ++nxt, ++NUM_ENT(cp), ++off) { switch (TYPE(pp)) { case P_IBTREE: - if (GET_BINTERNAL(pp, nxt)->type == B_KEYDATA) + if (B_TYPE(GET_BINTERNAL(pp, nxt)->type) == B_KEYDATA) nbytes = BINTERNAL_SIZE(GET_BINTERNAL(pp, nxt)->len); else @@ -933,7 +926,7 @@ __bam_copy(dbp, pp, cp, nxt, stop) } /* FALLTHROUGH */ case P_LRECNO: - if (GET_BKEYDATA(pp, nxt)->type == B_KEYDATA) + if (B_TYPE(GET_BKEYDATA(pp, nxt)->type) == B_KEYDATA) nbytes = BKEYDATA_SIZE(GET_BKEYDATA(pp, nxt)->len); else diff --git a/db2/btree/bt_stat.c b/db2/btree/bt_stat.c index ba71ea6..ab3bc4c 100644 --- a/db2/btree/bt_stat.c +++ b/db2/btree/bt_stat.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)bt_stat.c 10.11 (Sleepycat) 8/19/97"; +static const char sccsid[] = "@(#)bt_stat.c 10.12 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -140,6 +140,11 @@ __bam_stat(argdbp, spp, db_malloc, flags) (void)memp_fput(dbp->mpf, meta, 0); (void)__BT_TLPUT(dbp, lock); + /* Determine the last page of the database. */ + if ((ret = memp_fget(dbp->mpf, &lastpgno, DB_MPOOL_LAST, &h)) != 0) + goto err; + (void)memp_fput(dbp->mpf, h, 0); + /* Get the root page. */ pgno = PGNO_ROOT; if ((ret = __bam_lget(dbp, 0, PGNO_ROOT, DB_LOCK_READ, &lock)) != 0) @@ -152,13 +157,7 @@ __bam_stat(argdbp, spp, db_malloc, flags) /* Get the levels from the root page. */ sp->bt_levels = h->level; - /* - * Determine the last page of the database, then walk it, counting - * things. - */ - if ((ret = memp_fget(dbp->mpf, &lastpgno, DB_MPOOL_LAST, &h)) != 0) - goto err; - (void)memp_fput(dbp->mpf, h, 0); + /* Walk the page list, counting things. */ for (;;) { switch (TYPE(h)) { case P_INVALID: diff --git a/db2/common/db_appinit.c b/db2/common/db_appinit.c index 01891c6..51d9262 100644 --- a/db2/common/db_appinit.c +++ b/db2/common/db_appinit.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_appinit.c 10.27 (Sleepycat) 8/23/97"; +static const char sccsid[] = "@(#)db_appinit.c 10.33 (Sleepycat) 8/28/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -43,7 +43,7 @@ static int __db_tmp_open __P((DB_ENV *, char *, int *)); * db_version -- * Return verision information. */ -const char * +char * db_version(majverp, minverp, patchp) int *majverp, *minverp, *patchp; { @@ -53,7 +53,7 @@ db_version(majverp, minverp, patchp) *minverp = DB_VERSION_MINOR; if (patchp != NULL) *patchp = DB_VERSION_PATCH; - return (DB_VERSION_STRING); + return ((char *)DB_VERSION_STRING); } /* @@ -68,7 +68,7 @@ db_appinit(db_home, db_config, dbenv, flags) int flags; { FILE *fp; - int i_lock, i_log, i_mpool, i_txn, ret; + int ret; char *lp, **p, buf[MAXPATHLEN * 2]; /* Validate arguments. */ @@ -94,7 +94,6 @@ db_appinit(db_home, db_config, dbenv, flags) return (__db_ferr(dbenv, "db_appinit", 1)); fp = NULL; - i_lock = i_log = i_mpool = i_txn = 0; /* Set the database home. */ if ((ret = __db_home(dbenv, db_home, flags)) != 0) @@ -117,6 +116,7 @@ db_appinit(db_home, db_config, dbenv, flags) goto err; } (void)fclose(fp); + fp = NULL; } } @@ -152,34 +152,22 @@ db_appinit(db_home, db_config, dbenv, flags) #define DB_DEFPERM (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP) /* Initialize the subsystems. */ - if (LF_ISSET(DB_INIT_LOCK)) { - if ((ret = lock_open(NULL, - LF_ISSET(DB_CREATE | DB_THREAD), - DB_DEFPERM, dbenv, &dbenv->lk_info)) != 0) - goto err; - i_lock = 1; - } - if (LF_ISSET(DB_INIT_LOG)) { - if ((ret = log_open(NULL, - LF_ISSET(DB_CREATE | DB_THREAD), - DB_DEFPERM, dbenv, &dbenv->lg_info)) != 0) - goto err; - i_log = 1; - } - if (LF_ISSET(DB_INIT_MPOOL)) { - if ((ret = memp_open(NULL, + if (LF_ISSET(DB_INIT_LOCK) && (ret = lock_open(NULL, + LF_ISSET(DB_CREATE | DB_THREAD), + DB_DEFPERM, dbenv, &dbenv->lk_info)) != 0) + goto err; + if (LF_ISSET(DB_INIT_LOG) && (ret = log_open(NULL, + LF_ISSET(DB_CREATE | DB_THREAD), + DB_DEFPERM, dbenv, &dbenv->lg_info)) != 0) + goto err; + if (LF_ISSET(DB_INIT_MPOOL) && (ret = memp_open(NULL, LF_ISSET(DB_CREATE | DB_MPOOL_PRIVATE | DB_NOMMAP | DB_THREAD), - DB_DEFPERM, dbenv, &dbenv->mp_info)) != 0) - goto err; - i_mpool = 1; - } - if (LF_ISSET(DB_INIT_TXN)) { - if ((ret = txn_open(NULL, - LF_ISSET(DB_CREATE | DB_THREAD | DB_TXN_NOSYNC), - DB_DEFPERM, dbenv, &dbenv->tx_info)) != 0) - goto err; - i_txn = 1; - } + DB_DEFPERM, dbenv, &dbenv->mp_info)) != 0) + goto err; + if (LF_ISSET(DB_INIT_TXN) && (ret = txn_open(NULL, + LF_ISSET(DB_CREATE | DB_THREAD | DB_TXN_NOSYNC), + DB_DEFPERM, dbenv, &dbenv->tx_info)) != 0) + goto err; /* Initialize recovery. */ if (LF_ISSET(DB_INIT_TXN)) { @@ -195,7 +183,7 @@ db_appinit(db_home, db_config, dbenv, flags) goto err; } - /* Now run recovery if necessary. */ + /* Run recovery if necessary. */ if (LF_ISSET(DB_RECOVER | DB_RECOVER_FATAL) && (ret = __db_apprec(dbenv, LF_ISSET(DB_RECOVER | DB_RECOVER_FATAL))) != 0) goto err; @@ -204,14 +192,6 @@ db_appinit(db_home, db_config, dbenv, flags) err: if (fp != NULL) (void)fclose(fp); - if (i_lock) - (void)lock_close(dbenv->lk_info); - if (i_log) - (void)log_close(dbenv->lg_info); - if (i_mpool) - (void)memp_close(dbenv->mp_info); - if (i_txn) - (void)txn_close(dbenv->tx_info); (void)db_appexit(dbenv); return (ret); diff --git a/db2/common/db_apprec.c b/db2/common/db_apprec.c index b22b0c5..2e94673 100644 --- a/db2/common/db_apprec.c +++ b/db2/common/db_apprec.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_apprec.c 10.15 (Sleepycat) 7/27/97"; +static const char sccsid[] = "@(#)db_apprec.c 10.16 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -19,6 +19,7 @@ static const char sccsid[] = "@(#)db_apprec.c 10.15 (Sleepycat) 7/27/97"; #include <time.h> #include <string.h> +#include <stdlib.h> #endif #include "db_int.h" @@ -30,6 +31,12 @@ static const char sccsid[] = "@(#)db_apprec.c 10.15 (Sleepycat) 7/27/97"; #include "txn.h" #include "common_ext.h" +#define FREE_DBT(L, D) { \ + if (F_ISSET((L), DB_AM_THREAD) && (D).data != NULL) \ + free((D).data); \ + (D).data = NULL; \ + } \ + /* * __db_apprec -- * Perform recovery. @@ -45,30 +52,34 @@ __db_apprec(dbenv, flags) DB_LOG *lp; DB_LSN ckp_lsn, first_lsn, lsn, tmp_lsn; time_t now; - int first_flag, ret, tret; + int first_flag, ret; void *txninfo; - ZERO_LSN(ckp_lsn); - /* Initialize the transaction list. */ if ((ret = __db_txnlist_init(&txninfo)) != 0) return (ret); /* - * Read forward through the log opening the appropriate files - * so that we can call recovery routines. In general, we start - * at the last checkpoint prior to the last checkpointed LSN. - * For catastrophic recovery, we begin at the first LSN that - * appears in any log file (log figures this out for us when - * we pass it the DB_FIRST flag). + * Read forward through the log, opening the appropriate files so that + * we can call recovery routines. In general, we start at the last + * checkpoint prior to the last checkpointed LSN. For catastrophic + * recovery, we begin at the first LSN that appears in any log file + * (log_get figures this out for us when we pass it the DB_FIRST flag). */ lp = dbenv->lg_info; if (LF_ISSET(DB_RECOVER_FATAL)) first_flag = DB_FIRST; - else - first_flag = __log_findckp(lp, &lsn) != 0 ? DB_FIRST : DB_SET; + else { + if ((ret = __log_findckp(lp, &lsn)) == DB_NOTFOUND) + return (0); + first_flag = DB_SET; + } + /* If we're a threaded application, we have to allocate space. */ memset(&data, 0, sizeof(data)); + if (F_ISSET(lp, DB_AM_THREAD)) + F_SET(&data, DB_DBT_MALLOC); + if ((ret = log_get(lp, &lsn, &data, first_flag)) != 0) { __db_err(dbenv, "Failure: unable to get log record"); if (first_flag == DB_SET) @@ -80,35 +91,55 @@ __db_apprec(dbenv, flags) } first_lsn = lsn; - for (; ret == 0; - ret = log_get(dbenv->lg_info, &lsn, &data, DB_NEXT)) - if ((tret = __db_dispatch(lp, - &data, &lsn, TXN_OPENFILES, txninfo)) < 0) { - ret = tret; + for (;;) { + ret = __db_dispatch(lp, &data, &lsn, TXN_OPENFILES, txninfo); + FREE_DBT(lp, data); + if (ret != 0 && ret != DB_TXN_CKP) goto msgerr; + if ((ret = + log_get(dbenv->lg_info, &lsn, &data, DB_NEXT)) != 0) { + if (ret != DB_NOTFOUND) + goto err; + break; } + } + FREE_DBT(lp, data); + /* + * Initialize the ckp_lsn to 0,0. If we never find a valid + * checkpoint in the log, then leaving ckp_lsn at 0,0 is correct. + */ + ZERO_LSN(ckp_lsn); for (ret = log_get(lp, &lsn, &data, DB_LAST); ret == 0 && log_compare(&lsn, &first_lsn) > 0; ret = log_get(lp,&lsn, &data, DB_PREV)) { tmp_lsn = lsn; - tret = - __db_dispatch(lp, &data, &lsn, TXN_BACKWARD_ROLL, txninfo); - if (IS_ZERO_LSN(ckp_lsn) && tret > 0) - ckp_lsn = tmp_lsn; - if (tret < 0) { - ret = tret; + ret = __db_dispatch(lp, + &data, &lsn, TXN_BACKWARD_ROLL, txninfo); + FREE_DBT(lp, data); + if (ret == DB_TXN_CKP) { + if (IS_ZERO_LSN(ckp_lsn)) + ckp_lsn = tmp_lsn; + ret = 0; + } else if (ret != 0) goto msgerr; - } } + FREE_DBT(lp, data); + if (ret != 0 && ret != DB_NOTFOUND) + goto err; for (ret = log_get(lp, &lsn, &data, DB_NEXT); - ret == 0; ret = log_get(lp, &lsn, &data, DB_NEXT)) - if ((tret = __db_dispatch(lp, - &data, &lsn, TXN_FORWARD_ROLL, txninfo)) < 0) { - ret = tret; + ret == 0; ret = log_get(lp, &lsn, &data, DB_NEXT)) { + ret = __db_dispatch(lp, &data, &lsn, TXN_FORWARD_ROLL, txninfo); + FREE_DBT(lp, data); + if (ret == DB_TXN_CKP) + ret = 0; + else if (ret != 0) goto msgerr; - } + } + FREE_DBT(lp, data); + if (ret != DB_NOTFOUND) + goto err; /* Now close all the db files that are open. */ __log_close_files(lp); @@ -118,11 +149,11 @@ __db_apprec(dbenv, flags) * and the current time. Then take a checkpoint. */ (void)time(&now); - dbenv->tx_info->region->last_txnid = ((__db_txnhead *)txninfo)->maxid; dbenv->tx_info->region->last_ckp = ckp_lsn; - dbenv->tx_info->region->time_ckp = (u_int32_t) now; - txn_checkpoint(dbenv->tx_info, 0, 0); + dbenv->tx_info->region->time_ckp = (u_int32_t)now; + if ((ret = txn_checkpoint(dbenv->tx_info, 0, 0)) != 0) + goto err; if (dbenv->db_verbose) { __db_err(lp->dbenv, "Recovery complete at %s", ctime(&now)); @@ -139,5 +170,6 @@ __db_apprec(dbenv, flags) msgerr: __db_err(dbenv, "Recovery function for LSN %lu %lu failed", (u_long)lsn.file, (u_long)lsn.offset); -err: return (ret); +err: FREE_DBT(lp, data); + return (ret); } diff --git a/db2/common/db_byteorder.c b/db2/common/db_byteorder.c index d49883e..a8d7715 100644 --- a/db2/common/db_byteorder.c +++ b/db2/common/db_byteorder.c @@ -17,6 +17,13 @@ static const char sccsid[] = "@(#)db_byteorder.c 10.3 (Sleepycat) 6/21/97"; #include <errno.h> #endif +#ifdef HAVE_ENDIAN_H +# include <endian.h> +# if BYTE_ORDER == BIG_ENDIAN +# define WORDS_BIGENDIAN 1 +# endif +#endif + #include "db_int.h" #include "common_ext.h" diff --git a/db2/common/db_err.c b/db2/common/db_err.c index 3dc4ca0..f3e7b40 100644 --- a/db2/common/db_err.c +++ b/db2/common/db_err.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_err.c 10.16 (Sleepycat) 8/24/97"; +static const char sccsid[] = "@(#)db_err.c 10.18 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -221,7 +221,7 @@ __db_panic(dbp) * __db_fchk -- * General flags checking routine. * - * PUBLIC: int __db_fchk __P((DB_ENV *, char *, int, int)); + * PUBLIC: int __db_fchk __P((DB_ENV *, const char *, int, int)); */ int __db_fchk(dbenv, name, flags, ok_flags) @@ -237,7 +237,7 @@ __db_fchk(dbenv, name, flags, ok_flags) * __db_fcchk -- * General combination flags checking routine. * - * PUBLIC: int __db_fcchk __P((DB_ENV *, char *, int, int, int)); + * PUBLIC: int __db_fcchk __P((DB_ENV *, const char *, int, int, int)); */ int __db_fcchk(dbenv, name, flags, flag1, flag2) @@ -521,7 +521,7 @@ __db_syncchk(dbp, flags) * __db_ferr -- * Common flag errors. * - * PUBLIC: int __db_ferr __P((const DB_ENV *, char *, int)); + * PUBLIC: int __db_ferr __P((const DB_ENV *, const char *, int)); */ int __db_ferr(dbenv, name, combo) diff --git a/db2/common/db_region.c b/db2/common/db_region.c index 51f8f44..86d79a8 100644 --- a/db2/common/db_region.c +++ b/db2/common/db_region.c @@ -43,7 +43,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_region.c 10.12 (Sleepycat) 7/26/97"; +static const char sccsid[] = "@(#)db_region.c 10.13 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -229,7 +229,7 @@ __db_ropen(dbenv, appname, path, file, flags, fdp, retp) goto err2; /* Check to make sure the first block has been written. */ - if ((size_t) size1 < sizeof(RLAYOUT)) { + if ((size_t)size1 < sizeof(RLAYOUT)) { ret = EAGAIN; goto err2; } diff --git a/db2/config.h b/db2/config.h index ed1246d..27dbdaa 100644 --- a/db2/config.h +++ b/db2/config.h @@ -2,7 +2,6 @@ /* config.h.in. Generated automatically from configure.in by autoheader. */ /* ...but edited by hand to be used in GNU libc. */ -#include <endian.h> #include <sys/stat.h> /* To get _STATBUF_ST_BLKSIZE. */ /* Define to empty if the keyword does not work. */ @@ -28,11 +27,8 @@ /* Define if you have the ANSI C header files. */ #define STDC_HEADERS 1 -/* Define if your processor stores words with the most significant - byte first (like Motorola and SPARC, unlike Intel and VAX). */ -#if __BYTE_ORDER == BIG_ENDIAN -# define WORDS_BIGENDIAN 1 -#endif +/* Say we have endian.h. */ +#define HAVE_ENDIAN_H 1 /* Define to `int' if <sys/types.h> doesn't define. */ /* #undef ssize_t */ @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)db.h.src 10.67 (Sleepycat) 8/25/97 + * @(#)db.h.src 10.71 (Sleepycat) 9/4/97 */ #ifndef _DB_H_ @@ -67,8 +67,8 @@ #define DB_VERSION_MAJOR 2 #define DB_VERSION_MINOR 3 -#define DB_VERSION_PATCH 4 -#define DB_VERSION_STRING "Sleepycat Software: DB 2.3.4: (8/20/97)" +#define DB_VERSION_PATCH 6 +#define DB_VERSION_STRING "Sleepycat Software: DB 2.3.6: (9/4/97)" typedef u_int32_t db_pgno_t; /* Page number type. */ typedef u_int16_t db_indx_t; /* Page offset type. */ @@ -329,6 +329,7 @@ struct __db_info { #define DB_NEEDSPLIT ( -9) /* Page needs to be split. */ #define DB_REGISTERED (-10) /* Entry was previously registered. */ #define DB_SWAPBYTES (-11) /* Database needs byte swapping. */ +#define DB_TXN_CKP (-12) /* Encountered ckp record in log. */ struct __db_ilock { /* Internal DB access method lock. */ db_pgno_t pgno; /* Page being locked. */ @@ -479,7 +480,7 @@ extern "C" { int db_appinit __P((const char *, char * const *, DB_ENV *, int)); int db_appexit __P((DB_ENV *)); int db_open __P((const char *, DBTYPE, int, int, DB_ENV *, DB_INFO *, DB **)); -const char *db_version __P((int *, int *, int *)); +char *db_version __P((int *, int *, int *)); #if defined(__cplusplus) }; #endif diff --git a/db2/db/db.c b/db2/db/db.c index df3a9d2..8dad5fe 100644 --- a/db2/db/db.c +++ b/db2/db/db.c @@ -44,7 +44,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db.c 10.37 (Sleepycat) 8/23/97"; +static const char sccsid[] = "@(#)db.c 10.38 (Sleepycat) 9/2/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -248,9 +248,6 @@ db_open(fname, type, flags, mode, dbenv, dbinfo, dbpp) * that fail, we simply retry without the O_CREAT flag, which * will require that the meta-data page exist. */ -#undef OKFLAGS -#define OKFLAGS \ - DB_CREATE | DB_NOMMAP | DB_RDONLY | DB_THREAD | DB_TRUNCATE retry_cnt = 0; open_retry: if (LF_ISSET(DB_CREATE)) { if ((ret = __db_fdopen(real_name, flags | DB_EXCL, @@ -308,13 +305,20 @@ open_retry: if (LF_ISSET(DB_CREATE)) { } /* * The only way we can reach here with the DB_CREATE - * flag set is if we created the file. If we didn't - * create the file, there's a chance that someone else - * is busily doing so. Sleep and give them a chance, - * because we need the metadata page their going to - * write. + * flag set is if we created the file. If that's not + * the case, then a) someone else created the file + * but has not yet written out the meta-data page, or + * b) we truncated the file (DB_TRUNCATE) leaving it + * zero-length. In the case of a), we want to sleep + * and give the file creator some time to write the + * metadata page. In the case of b), charge forward. + * Note, there is a race in the case of two processes + * opening the file with the DB_TRUNCATE flag set at + * roughly the same time, and they could theoretically + * hurt each other, although it's pretty unlikely. */ - if (!LF_ISSET(DB_CREATE) && retry_cnt++ < 3) { + if (retry_cnt++ < 3 && + !LF_ISSET(DB_CREATE | DB_TRUNCATE)) { __db_sleep(1, 0); goto open_retry; } diff --git a/db2/db/db_conv.c b/db2/db/db_conv.c index 39527c6..6608005 100644 --- a/db2/db/db_conv.c +++ b/db2/db/db_conv.c @@ -44,7 +44,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_conv.c 10.4 (Sleepycat) 8/15/97"; +static const char sccsid[] = "@(#)db_conv.c 10.5 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -145,7 +145,7 @@ __db_convert(pg, pp, pgin) M_16_SWAP(h->inp[i]); bk = GET_BKEYDATA(h, i); - switch (bk->type) { + switch (B_TYPE(bk->type)) { case B_KEYDATA: M_16_SWAP(bk->len); break; @@ -167,7 +167,7 @@ __db_convert(pg, pp, pgin) M_16_SWAP(h->inp[i]); bi = GET_BINTERNAL(h, i); - switch (bi->type) { + switch (B_TYPE(bi->type)) { case B_KEYDATA: M_16_SWAP(bi->len); M_32_SWAP(bi->pgno); diff --git a/db2/db/db_dup.c b/db2/db/db_dup.c index 8d364d5..66c6c261 100644 --- a/db2/db/db_dup.c +++ b/db2/db/db_dup.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_dup.c 10.8 (Sleepycat) 7/20/97"; +static const char sccsid[] = "@(#)db_dup.c 10.9 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -65,8 +65,7 @@ __db_dput(dbp, dbt, pp, indxp, newfunc) if (dbt->size > 0.25 * dbp->pgsize) { if ((ret = __db_poff(dbp, dbt, &pgno, newfunc)) != 0) return (ret); - bo.deleted = 0; - bo.type = B_OVERFLOW; + B_TSET(bo.type, B_OVERFLOW, 0); bo.tlen = dbt->size; bo.pgno = pgno; hdr_dbt.data = &bo; @@ -125,7 +124,7 @@ __db_drem(dbp, pp, indx, freefunc) pagep = *pp; /* Check if we are freeing a big item. */ - if (GET_BKEYDATA(pagep, indx)->type == B_OVERFLOW) { + if (B_TYPE(GET_BKEYDATA(pagep, indx)->type) == B_OVERFLOW) { if ((ret = __db_doff(dbp, GET_BOVERFLOW(pagep, indx)->pgno, freefunc)) != 0) return (ret); @@ -255,7 +254,7 @@ __db_dsplit(dbp, hp, indxp, size, newfunc) lastsum = sum; did_indx = 1; } - if (GET_BKEYDATA(h, i)->type == B_KEYDATA) + if (B_TYPE(GET_BKEYDATA(h, i)->type) == B_KEYDATA) sum += BKEYDATA_SIZE(GET_BKEYDATA(h, i)->len); else sum += BOVERFLOW_SIZE; @@ -300,7 +299,7 @@ __db_dsplit(dbp, hp, indxp, size, newfunc) for (nindex = 0, oindex = i + 1; oindex < NUM_ENT(h); oindex++) { bk = GET_BKEYDATA(h, oindex); - if (bk->type == B_KEYDATA) + if (B_TYPE(bk->type) == B_KEYDATA) s = BKEYDATA_SIZE(bk->len); else s = BOVERFLOW_SIZE; @@ -316,7 +315,7 @@ __db_dsplit(dbp, hp, indxp, size, newfunc) */ for (nindex = 0, oindex = 0; oindex <= i; oindex++) { bk = GET_BKEYDATA(h, oindex); - if (bk->type == B_KEYDATA) + if (B_TYPE(bk->type) == B_KEYDATA) s = BKEYDATA_SIZE(bk->len); else s = BOVERFLOW_SIZE; @@ -474,8 +473,7 @@ __db_pitem(dbp, pagep, indx, nbytes, hdr, data) return (ret); if (hdr == NULL) { - bk.deleted = 0; - bk.type = B_KEYDATA; + B_TSET(bk.type, B_KEYDATA, 0); bk.len = data == NULL ? 0 : data->size; thdr.data = &bk; diff --git a/db2/db/db_pr.c b/db2/db/db_pr.c index c103b10..f86fd67 100644 --- a/db2/db/db_pr.c +++ b/db2/db/db_pr.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_pr.c 10.14 (Sleepycat) 8/17/97"; +static const char sccsid[] = "@(#)db_pr.c 10.16 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -461,12 +461,12 @@ __db_prpage(h, all) case P_LBTREE: bk = GET_BKEYDATA(h, i); deleted = i % 2 == 0 && - GET_BKEYDATA(h, i + O_INDX)->deleted; + B_DISSET(GET_BKEYDATA(h, i + O_INDX)->type); break; case P_LRECNO: case P_DUPLICATE: bk = GET_BKEYDATA(h, i); - deleted = GET_BKEYDATA(h, i)->deleted; + deleted = B_DISSET(GET_BKEYDATA(h, i)->type); break; default: fprintf(fp, @@ -525,7 +525,7 @@ __db_prpage(h, all) case P_IBTREE: fprintf(fp, "count: %4lu pgno: %4lu ", (u_long)bi->nrecs, (u_long)bi->pgno); - switch (bi->type) { + switch (B_TYPE(bi->type)) { case B_KEYDATA: __db_pr(bi->data, bi->len); break; @@ -535,7 +535,7 @@ __db_prpage(h, all) break; default: fprintf(fp, "ILLEGAL BINTERNAL TYPE: %lu\n", - (u_long)bi->type); + (u_long)B_TYPE(bi->type)); ret = EINVAL; break; } @@ -547,7 +547,7 @@ __db_prpage(h, all) case P_LBTREE: case P_LRECNO: case P_DUPLICATE: - switch (bk->type) { + switch (B_TYPE(bk->type)) { case B_KEYDATA: __db_pr(bk->data, bk->len); break; @@ -558,7 +558,7 @@ __db_prpage(h, all) default: fprintf(fp, "ILLEGAL DUPLICATE/LBTREE/LRECNO TYPE: %lu\n", - (u_long)bk->type); + (u_long)B_TYPE(bk->type)); ret = EINVAL; break; } @@ -630,11 +630,11 @@ __db_isbad(h, die) break; case P_IBTREE: bi = GET_BINTERNAL(h, i); - if (bi->type != B_KEYDATA && - bi->type != B_DUPLICATE && - bi->type != B_OVERFLOW) { + if (B_TYPE(bi->type) != B_KEYDATA && + B_TYPE(bi->type) != B_DUPLICATE && + B_TYPE(bi->type) != B_OVERFLOW) { fprintf(fp, "ILLEGAL BINTERNAL TYPE: %lu\n", - (u_long)bi->type); + (u_long)B_TYPE(bi->type)); goto bad; } break; @@ -644,12 +644,12 @@ __db_isbad(h, die) break; case P_DUPLICATE: bk = GET_BKEYDATA(h, i); - if (bk->type != B_KEYDATA && - bk->type != B_DUPLICATE && - bk->type != B_OVERFLOW) { + if (B_TYPE(bk->type) != B_KEYDATA && + B_TYPE(bk->type) != B_DUPLICATE && + B_TYPE(bk->type) != B_OVERFLOW) { fprintf(fp, "ILLEGAL DUPLICATE/LBTREE/LRECNO TYPE: %lu\n", - (u_long)bk->type); + (u_long)B_TYPE(bk->type)); goto bad; } break; @@ -713,18 +713,18 @@ __db_proff(vp) void *vp; { FILE *fp; - BOVERFLOW *p; + BOVERFLOW *bo; fp = __db_prinit(NULL); - p = vp; - switch (p->type) { + bo = vp; + switch (B_TYPE(bo->type)) { case B_OVERFLOW: fprintf(fp, "overflow: total len: %4lu page: %4lu\n", - (u_long)p->tlen, (u_long)p->pgno); + (u_long)bo->tlen, (u_long)bo->pgno); break; case B_DUPLICATE: - fprintf(fp, "duplicate: page: %4lu\n", (u_long)p->pgno); + fprintf(fp, "duplicate: page: %4lu\n", (u_long)bo->pgno); break; } } diff --git a/db2/db/db_ret.c b/db2/db/db_ret.c index ddeb26e..baf0665 100644 --- a/db2/db/db_ret.c +++ b/db2/db/db_ret.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_ret.c 10.5 (Sleepycat) 7/12/97"; +static const char sccsid[] = "@(#)db_ret.c 10.6 (Sleepycat) 9/3/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -63,7 +63,7 @@ __db_ret(dbp, h, indx, dbt, memp, memsize) case P_LBTREE: case P_LRECNO: bk = GET_BKEYDATA(h, indx); - if (bk->type == B_OVERFLOW) { + if (B_TYPE(bk->type) == B_OVERFLOW) { bo = (BOVERFLOW *)bk; return (__db_goff(dbp, dbt, bo->tlen, bo->pgno, memp, memsize)); diff --git a/db2/db185/db185.c b/db2/db185/db185.c index 933f55c..8e53a1b 100644 --- a/db2/db185/db185.c +++ b/db2/db185/db185.c @@ -38,7 +38,7 @@ static int db185_seq __P((const DB185 *, DBT185 *, DBT185 *, u_int)); static int db185_sync __P((const DB185 *, u_int)); DB185 * -__dbopen(file, oflags, mode, type, openinfo) +dbopen(file, oflags, mode, type, openinfo) const char *file; int oflags, mode; DBTYPE type; @@ -203,7 +203,6 @@ einval: free(db185p); errno = EINVAL; return (NULL); } -weak_alias (__dbopen, dbopen) static int db185_close(db185p) diff --git a/db2/dbm/dbm.c b/db2/dbm/dbm.c index 8daa980..fb21ade 100644 --- a/db2/dbm/dbm.c +++ b/db2/dbm/dbm.c @@ -47,7 +47,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)dbm.c 10.5 (Sleepycat) 7/19/97"; +static const char sccsid[] = "@(#)dbm.c 10.6 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -65,6 +65,12 @@ static const char sccsid[] = "@(#)dbm.c 10.5 (Sleepycat) 7/19/97"; #include "db_page.h" #include "hash.h" +/* Provide prototypes here since there are none in db.h. */ +int dbm_clearerr __P((DBM *)); +int dbm_dirfno __P((DBM *)); +int dbm_error __P((DBM *)); +int dbm_pagfno __P((DBM *)); + /* * * This package provides dbm and ndbm compatible interfaces to DB. @@ -75,12 +81,6 @@ static DBM *__cur_db; static void __db_no_open __P((void)); -/* Provide prototypes here since there are none in db.h. */ -int dbm_error __P((DBM *)); -int dbm_clearerr __P((DBM *)); -int dbm_dirfno __P((DBM *)); -int dbm_pagfno __P((DBM *)); - int dbminit(file) char *file; diff --git a/db2/hash/hash_dup.c b/db2/hash/hash_dup.c index 059eec6..c9590fa 100644 --- a/db2/hash/hash_dup.c +++ b/db2/hash/hash_dup.c @@ -42,7 +42,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)hash_dup.c 10.5 (Sleepycat) 7/27/97"; +static const char sccsid[] = "@(#)hash_dup.c 10.6 (Sleepycat) 9/3/97"; #endif /* not lint */ /* @@ -277,8 +277,7 @@ __ham_dup_convert(hashp, hcp) dndx = 0; memcpy(&ho, P_ENTRY(hcp->pagep, H_DATAINDEX(hcp->bndx)), HOFFPAGE_SIZE); - bo.deleted = 0; - bo.type = ho.type; + B_TSET(bo.type, ho.type, 0); bo.pgno = ho.pgno; bo.tlen = ho.tlen; dbt.size = BOVERFLOW_SIZE; diff --git a/db2/include/db_am.h b/db2/include/db_am.h index 3289eec..5814ff8 100644 --- a/db2/include/db_am.h +++ b/db2/include/db_am.h @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)db_am.h 10.5 (Sleepycat) 8/22/97 + * @(#)db_am.h 10.6 (Sleepycat) 8/27/97 */ #ifndef _DB_AM_H #define _DB_AM_H @@ -30,7 +30,7 @@ file_dbp = mdbp = NULL; \ if ((ret = func(dbtp->data, &argp)) != 0) \ goto out; \ - if (__db_fileid_to_db(logp, &mdbp, argp->fileid)) { \ + if ((ret = __db_fileid_to_db(logp, &mdbp, argp->fileid)) != 0) {\ if (ret == DB_DELETED) \ ret = 0; \ goto out; \ diff --git a/db2/include/db_page.h b/db2/include/db_page.h index 9e78682..cde7ff9 100644 --- a/db2/include/db_page.h +++ b/db2/include/db_page.h @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)db_page.h 10.10 (Sleepycat) 8/18/97 + * @(#)db_page.h 10.11 (Sleepycat) 9/3/97 */ #ifndef _DB_PAGE_H_ @@ -400,6 +400,24 @@ typedef struct _hoffdup { #define B_OVERFLOW 3 /* Overflow key/data item. */ /* + * We have to store a deleted entry flag in the page. The reason is complex, + * but the simple version is that we can't delete on-page items referenced by + * a cursor -- the return order of subsequent insertions might be wrong. The + * delete flag is an overload of the top bit of the type byte. + */ +#define B_DELETE (0x80) +#define B_DCLR(t) (t) &= ~B_DELETE +#define B_DSET(t) (t) |= B_DELETE +#define B_DISSET(t) ((t) & B_DELETE) + +#define B_TYPE(t) ((t) & ~B_DELETE) +#define B_TSET(t, type, deleted) { \ + (t) = (type); \ + if (deleted) \ + B_DSET(t); \ +} + +/* * The first type is B_KEYDATA, represented by the BKEYDATA structure: * * +-----------------------------------+ @@ -408,8 +426,7 @@ typedef struct _hoffdup { */ typedef struct _bkeydata { db_indx_t len; /* 00-01: Key/data item length. */ - u_int deleted :1; /* 02: Page type and delete flag. */ - u_int type :7; + u_int8_t type; /* 02: Page type AND DELETE FLAG. */ u_int8_t data[1]; /* Variable length key/data item. */ } BKEYDATA; @@ -438,8 +455,7 @@ typedef struct _bkeydata { */ typedef struct _boverflow { db_indx_t unused1; /* 00-01: Padding, unused. */ - u_int deleted :1; /* 02: Page type and delete flag. */ - u_int type :7; + u_int8_t type; /* 02: Page type AND DELETE FLAG. */ u_int8_t unused2; /* 03: Padding, unused. */ db_pgno_t pgno; /* 04-07: Next page number. */ u_int32_t tlen; /* 08-11: Total length of item. */ @@ -479,9 +495,8 @@ typedef struct _boverflow { * +-----------------------------------+ */ typedef struct _binternal { - db_indx_t len; /* 00-01: Key/data item length. */ - u_int deleted :1; /* 02: Page type and delete flag. */ - u_int type :7; + db_indx_t len; /* 00-01: Key/data item length. */ + u_int8_t type; /* 02: Page type AND DELETE FLAG. */ u_int8_t unused; /* 03: Padding, unused. */ db_pgno_t pgno; /* 04-07: Page number of referenced page. */ db_recno_t nrecs; /* 08-11: Subtree record count. */ diff --git a/db2/include/mp.h b/db2/include/mp.h index 4872596..1fe0c75 100644 --- a/db2/include/mp.h +++ b/db2/include/mp.h @@ -4,7 +4,7 @@ * Copyright (c) 1996, 1997 * Sleepycat Software. All rights reserved. * - * @(#)mp.h 10.14 (Sleepycat) 8/18/97 + * @(#)mp.h 10.15 (Sleepycat) 8/29/97 */ struct __bh; typedef struct __bh BH; @@ -161,9 +161,12 @@ struct __db_mpoolfile { void *addr; /* Address of mmap'd region. */ size_t len; /* Length of mmap'd region. */ -#define MP_PATH_ALLOC 0x01 /* Path is allocated memory. */ -#define MP_PATH_TEMP 0x02 /* Backing file is a temporary. */ -#define MP_READONLY 0x04 /* File is readonly. */ +/* These fields need to be protected for multi-threaded support. */ +#define MP_PATH_ALLOC 0x001 /* Path is allocated memory. */ +#define MP_PATH_TEMP 0x002 /* Backing file is a temporary. */ +#define MP_READONLY 0x004 /* File is readonly. */ +#define MP_UPGRADE 0x008 /* File descriptor is readwrite. */ +#define MP_UPGRADE_FAIL 0x010 /* Upgrade wasn't possible. */ u_int32_t flags; }; diff --git a/db2/log/log.c b/db2/log/log.c index 1684ce8..d3e5183 100644 --- a/db2/log/log.c +++ b/db2/log/log.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log.c 10.24 (Sleepycat) 8/16/97"; +static const char sccsid[] = "@(#)log.c 10.25 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES diff --git a/db2/log/log_findckp.c b/db2/log/log_findckp.c index 67fe9c9..df75e20 100644 --- a/db2/log/log_findckp.c +++ b/db2/log/log_findckp.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log_findckp.c 10.10 (Sleepycat) 7/30/97"; +static const char sccsid[] = "@(#)log_findckp.c 10.11 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -119,7 +119,7 @@ __log_findckp(lp, lsnp) return (ret); if (F_ISSET(lp, DB_AM_THREAD)) free(data.data); - } + } *lsnp = last_ckp; if (verbose) diff --git a/db2/log/log_get.c b/db2/log/log_get.c index 37eb5cb..54a58c7 100644 --- a/db2/log/log_get.c +++ b/db2/log/log_get.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log_get.c 10.16 (Sleepycat) 8/19/97"; +static const char sccsid[] = "@(#)log_get.c 10.17 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -115,8 +115,8 @@ __log_get(dblp, alsn, dbt, flags, silent) size_t len; ssize_t nr; int cnt, ret; - const char *fail; char *np, *tbuf; + const char *fail; void *p, *shortp; lp = dblp->lp; diff --git a/db2/log/log_rec.c b/db2/log/log_rec.c index dbc5960..f49a7f1 100644 --- a/db2/log/log_rec.c +++ b/db2/log/log_rec.c @@ -40,7 +40,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)log_rec.c 10.11 (Sleepycat) 8/20/97"; +static const char sccsid[] = "@(#)log_rec.c 10.13 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -59,7 +59,7 @@ static const char sccsid[] = "@(#)log_rec.c 10.11 (Sleepycat) 8/20/97"; #include "db_dispatch.h" #include "common_ext.h" -static int __log_open_file __P((DB_LOG *, +static int __log_open_file __P((DB_LOG *, u_int8_t *, char *, DBTYPE, u_int32_t)); /* @@ -132,10 +132,16 @@ __log_unregister_recover(logp, dbtp, lsnp, redo, info) if ((ret = __log_unregister_read(dbtp->data, &argp)) != 0) goto out; + /* + * If the file is deleted, then we can just ignore this close. + * Otherwise, we'd better have a valid dbp that we should either + * close or whose reference count should be decremented. + */ LOCK_LOGTHREAD(logp); - if (logp->dbentry[argp->id].dbp == NULL) - ret = EINVAL; - else if (--logp->dbentry[argp->id].refcount == 0) { + if (logp->dbentry[argp->id].dbp == NULL) { + if (!logp->dbentry[argp->id].deleted) + ret = EINVAL; + } else if (--logp->dbentry[argp->id].refcount == 0) { ret = logp->dbentry[argp->id].dbp->close( logp->dbentry[argp->id].dbp, 0); logp->dbentry[argp->id].dbp = NULL; diff --git a/db2/mp/mp_bh.c b/db2/mp/mp_bh.c index e1b68ce..3d0d053 100644 --- a/db2/mp/mp_bh.c +++ b/db2/mp/mp_bh.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_bh.c 10.12 (Sleepycat) 8/20/97"; +static const char sccsid[] = "@(#)mp_bh.c 10.15 (Sleepycat) 8/29/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -24,6 +24,8 @@ static const char sccsid[] = "@(#)mp_bh.c 10.12 (Sleepycat) 8/20/97"; #include "mp.h" #include "common_ext.h" +static int __memp_upgrade __P((DB_MPOOL *, DB_MPOOLFILE *, MPOOLFILE *)); + /* * __memp_bhwrite -- * Write the page associated with a given bucket header. @@ -48,14 +50,20 @@ __memp_bhwrite(dbmp, mfp, bhp, restartp, wrotep) *wrotep = 0; /* - * Walk the process' DB_MPOOLFILE list and try and find a file - * descriptor for this file. + * Walk the process' DB_MPOOLFILE list and find a file descriptor for + * the file. We also check that the descriptor is open for writing. + * If we find a descriptor on the file that's not open for writing, we + * try and upgrade it to make it writeable. */ LOCKHANDLE(dbmp, &dbmp->mutex); for (dbmfp = TAILQ_FIRST(&dbmp->dbmfq); dbmfp != NULL; dbmfp = TAILQ_NEXT(dbmfp, q)) - if (dbmfp->mfp == mfp) + if (dbmfp->mfp == mfp) { + if (F_ISSET(dbmfp, MP_READONLY) && + __memp_upgrade(dbmp, dbmfp, mfp)) + return (0); break; + } UNLOCKHANDLE(dbmp, &dbmp->mutex); if (dbmfp != NULL) goto found; @@ -80,6 +88,10 @@ __memp_bhwrite(dbmp, mfp, bhp, restartp, wrotep) /* * Try and open the file; ignore any error, assume it's a permissions * problem. + * + * XXX + * There's no negative cache here, so we may repeatedly try and open + * files that we have previously tried (and failed) to open. */ dbt.size = mfp->pgcookie_len; dbt.data = ADDR(dbmp, mfp->pgcookie_off); @@ -435,3 +447,42 @@ __memp_bhfree(dbmp, mfp, bhp, free_mem) if (free_mem) __db_shalloc_free(dbmp->addr, bhp); } + +/* + * __memp_upgrade -- + * Upgrade a file descriptor from readonly to readwrite. + */ +static int +__memp_upgrade(dbmp, dbmfp, mfp) + DB_MPOOL *dbmp; + DB_MPOOLFILE *dbmfp; + MPOOLFILE *mfp; +{ + int fd; + + /* + * !!! + * We expect the handle to already be locked. + */ + + /* Check to see if we've already upgraded. */ + if (F_ISSET(dbmfp, MP_UPGRADE)) + return (0); + + /* Check to see if we've already failed. */ + if (F_ISSET(dbmfp, MP_UPGRADE_FAIL)) + return (1); + + /* Try the open. */ + if (__db_fdopen(ADDR(dbmp, mfp->path_off), 0, 0, 0, &fd) != 0) { + F_SET(dbmfp, MP_UPGRADE_FAIL); + return (1); + } + + /* Swap the descriptors and set the upgrade flag. */ + (void)close(dbmfp->fd); + dbmfp->fd = fd; + F_SET(dbmfp, MP_UPGRADE); + + return (0); +} diff --git a/db2/mp/mp_fopen.c b/db2/mp/mp_fopen.c index 7703847..1a770bf 100644 --- a/db2/mp/mp_fopen.c +++ b/db2/mp/mp_fopen.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_fopen.c 10.24 (Sleepycat) 8/20/97"; +static const char sccsid[] = "@(#)mp_fopen.c 10.25 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -110,7 +110,7 @@ __memp_fopen(dbmp, path, ret = EINVAL; goto err; } - dbmfp->path = (char *) TEMPORARY; + dbmfp->path = (char *)TEMPORARY; F_SET(dbmfp, MP_PATH_TEMP); } else { /* Calculate the real name for this file. */ diff --git a/db2/mp/mp_pr.c b/db2/mp/mp_pr.c index 94eabf5..7794cfa 100644 --- a/db2/mp/mp_pr.c +++ b/db2/mp/mp_pr.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_pr.c 10.12 (Sleepycat) 7/29/97"; +static const char sccsid[] = "@(#)mp_pr.c 10.13 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES diff --git a/db2/mp/mp_sync.c b/db2/mp/mp_sync.c index 4f12056..65b2a18 100644 --- a/db2/mp/mp_sync.c +++ b/db2/mp/mp_sync.c @@ -7,7 +7,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)mp_sync.c 10.8 (Sleepycat) 7/2/97"; +static const char sccsid[] = "@(#)mp_sync.c 10.9 (Sleepycat) 8/29/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -167,8 +167,12 @@ memp_fsync(dbmfp) size_t mf_offset; int pincnt, restart, ret, wrote; - /* We don't sync temporary files -- what's the use? */ - if (F_ISSET(dbmfp, MP_PATH_TEMP)) + /* + * If this handle doesn't have a file descriptor that's open for + * writing, or if the file is a temporary, there's no reason to + * proceed further. + */ + if (F_ISSET(dbmfp, MP_READONLY | MP_PATH_TEMP)) return (0); dbmp = dbmfp->dbmp; @@ -199,7 +203,7 @@ retry: pincnt = 0; goto retry; } - UNLOCKREGION(dbmp); +err: UNLOCKREGION(dbmp); -err: return (ret == 0 ? (pincnt ? DB_INCOMPLETE : 0) : ret); + return (ret == 0 ? (pincnt ? DB_INCOMPLETE : 0) : ret); } diff --git a/db2/mutex/x86.gcc b/db2/mutex/x86.gcc index 886a681..566b9c4 100644 --- a/db2/mutex/x86.gcc +++ b/db2/mutex/x86.gcc @@ -1,12 +1,12 @@ /* - * @(#)x86.gcc 10.2 (Sleepycat) 6/21/97 + * @(#)x86.gcc 10.3 (Sleepycat) 8/27/97 * * For gcc/x86, 0 is clear, 1 is set. */ #define TSL_SET(tsl) ({ \ register tsl_t *__l = (tsl); \ int __r; \ - asm volatile("movl $1,%%eax; xchgb %1,%%al; xorl $1,%%eax" \ + asm volatile("movl $1,%%eax; lock; xchgb %1,%%al; xorl $1,%%eax"\ : "=&a" (__r), "=m" (*__l) \ : "1" (*__l) \ ); \ diff --git a/db2/os/db_os_dir.c b/db2/os/db_os_dir.c index 23a6a45..6dabd62 100644 --- a/db2/os/db_os_dir.c +++ b/db2/os/db_os_dir.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_os_dir.c 10.7 (Sleepycat) 8/23/97"; +static const char sccsid[] = "@(#)db_os_dir.c 10.8 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -45,7 +45,7 @@ static const char sccsid[] = "@(#)db_os_dir.c 10.7 (Sleepycat) 8/23/97"; * __db_dir -- * Return a list of the files in a directory. * - * PUBLIC: int __db_dir __P((DB_ENV *, char *, char ***, int *)); + * PUBLIC: int __db_dir __P((DB_ENV *, const char *, char ***, int *)); */ int __db_dir(dbenv, dir, namesp, cntp) @@ -61,7 +61,7 @@ __db_dir(dbenv, dir, namesp, cntp) long dirhandle; int finished; - if ((dirhandle = _findfirst(dir,&fdata)) == -1) { + if ((dirhandle = _findfirst(dir, &fdata)) == -1) { __db_err(dbenv, "%s: %s", dir, strerror(errno)); return (errno); } diff --git a/db2/os/db_os_fid.c b/db2/os/db_os_fid.c index 8fa55fa..960d580 100644 --- a/db2/os/db_os_fid.c +++ b/db2/os/db_os_fid.c @@ -8,7 +8,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)db_os_fid.c 10.7 (Sleepycat) 8/21/97"; +static const char sccsid[] = "@(#)db_os_fid.c 10.8 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -39,9 +39,9 @@ __db_fileid(dbenv, fname, timestamp, fidp) int timestamp; u_int8_t *fidp; { + size_t i; time_t now; u_int8_t *p; - unsigned int i; #ifdef _WIN32 /* diff --git a/db2/progs/db_archive/db_archive.c b/db2/progs/db_archive/db_archive.c index 136cf2c..a9c6c28 100644 --- a/db2/progs/db_archive/db_archive.c +++ b/db2/progs/db_archive/db_archive.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_archive.c 10.12 (Sleepycat) 7/25/97"; +static const char sccsid[] = "@(#)db_archive.c 10.15 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -34,12 +34,13 @@ static const char sccsid[] = "@(#)db_archive.c 10.12 (Sleepycat) 7/25/97"; DB_ENV *db_init __P((char *, int)); void onint __P((int)); +int main __P((int, char *[])); void siginit __P((void)); void usage __P((void)); -int main __P((int, char *[])); int interrupted; -const char *progname = "db_archive"; /* Program name. */ +const char + *progname = "db_archive"; /* Program name. */ int main(argc, argv) diff --git a/db2/progs/db_checkpoint/db_checkpoint.c b/db2/progs/db_checkpoint/db_checkpoint.c index 586b4b9..4f9b79a 100644 --- a/db2/progs/db_checkpoint/db_checkpoint.c +++ b/db2/progs/db_checkpoint/db_checkpoint.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_checkpoint.c 10.9 (Sleepycat) 7/4/97"; +static const char sccsid[] = "@(#)db_checkpoint.c 10.11 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -39,14 +39,15 @@ char *check __P((DB_ENV *, long, long)); int checkpoint __P((DB_ENV *, char *, int)); DB_ENV *db_init __P((char *)); int logpid __P((char *, int)); +int main __P((int, char *[])); void onint __P((int)); void siginit __P((void)); void usage __P((void)); -int main __P((int, char *[])); int interrupted; time_t now; /* Checkpoint time. */ -const char *progname = "db_checkpoint"; /* Program name. */ +const char + *progname = "db_checkpoint"; /* Program name. */ int main(argc, argv) diff --git a/db2/progs/db_deadlock/db_deadlock.c b/db2/progs/db_deadlock/db_deadlock.c index 9437e35..09004f5 100644 --- a/db2/progs/db_deadlock/db_deadlock.c +++ b/db2/progs/db_deadlock/db_deadlock.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_deadlock.c 10.13 (Sleepycat) 7/20/97"; +static const char sccsid[] = "@(#)db_deadlock.c 10.14 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -33,14 +33,15 @@ static const char sccsid[] = "@(#)db_deadlock.c 10.13 (Sleepycat) 7/20/97"; #define BAD_KILLID 0xffffffff DB_ENV *db_init __P((char *, int)); +int logpid __P((char *, int)); +int main __P((int, char *[])); void onint __P((int)); void siginit __P((void)); void usage __P((void)); -int logpid __P((char *, int)); -int main __P((int, char *[])); int interrupted; -const char *progname = "db_deadlock"; /* Program name. */ +const char + *progname = "db_deadlock"; /* Program name. */ int main(argc, argv) diff --git a/db2/progs/db_dump/db_dump.c b/db2/progs/db_dump/db_dump.c index d60aa9b..a0f60c6 100644 --- a/db2/progs/db_dump/db_dump.c +++ b/db2/progs/db_dump/db_dump.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_dump.c 10.13 (Sleepycat) 8/19/97"; +static const char sccsid[] = "@(#)db_dump.c 10.16 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -19,10 +19,10 @@ static const char sccsid[] = "@(#)db_dump.c 10.13 (Sleepycat) 8/19/97"; #include <ctype.h> #include <errno.h> -#include <getopt.h> #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <unistd.h> #endif #include "db_int.h" @@ -35,11 +35,12 @@ void configure __P((char *)); DB_ENV *db_init __P((char *)); void dbt_dump __P((DBT *)); void dbt_print __P((DBT *)); +int main __P((int, char *[])); void pheader __P((DB *, int)); void usage __P((void)); -int main __P((int, char *[])); -const char *progname = "db_dump"; /* Program name. */ +const char + *progname = "db_dump"; /* Program name. */ int main(argc, argv) diff --git a/db2/progs/db_dump185/db_dump185.c b/db2/progs/db_dump185/db_dump185.c index f3c1187..6e2d95b 100644 --- a/db2/progs/db_dump185/db_dump185.c +++ b/db2/progs/db_dump185/db_dump185.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_dump185.c 10.5 (Sleepycat) 7/2/97"; +static const char sccsid[] = "@(#)db_dump185.c 10.7 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -20,10 +20,10 @@ static const char sccsid[] = "@(#)db_dump185.c 10.5 (Sleepycat) 7/2/97"; #include <ctype.h> #include <errno.h> #include <fcntl.h> -#include <getopt.h> #include <stdlib.h> #include <stdio.h> #include <string.h> +#include <unistd.h> #endif #include "db_185.h" @@ -149,14 +149,15 @@ typedef struct _btree { u_int32_t flags; } BTREE; -void db_185_btree __P((DB *, int)); -void db_185_hash __P((DB *, int)); -void dbt_dump __P((DBT *)); -void dbt_print __P((DBT *)); -void usage __P((void)); -int main __P((int, char *[])); +void db_185_btree __P((DB *, int)); +void db_185_hash __P((DB *, int)); +void dbt_dump __P((DBT *)); +void dbt_print __P((DBT *)); +int main __P((int, char *[])); +void usage __P((void)); -const char *progname = "db_dump185"; /* Program name. */ +const char + *progname = "db_dump185"; /* Program name. */ int main(argc, argv) diff --git a/db2/progs/db_load/db_load.c b/db2/progs/db_load/db_load.c index cc90e7b..6f69216 100644 --- a/db2/progs/db_load/db_load.c +++ b/db2/progs/db_load/db_load.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_load.c 10.9 (Sleepycat) 8/19/97"; +static const char sccsid[] = "@(#)db_load.c 10.12 (Sleepycat) 8/28/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -19,11 +19,11 @@ static const char sccsid[] = "@(#)db_load.c 10.9 (Sleepycat) 8/19/97"; #include <sys/stat.h> #include <errno.h> -#include <getopt.h> #include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> +#include <unistd.h> #endif #include "db_int.h" @@ -35,11 +35,12 @@ DB_ENV *db_init __P((char *)); int dbt_rdump __P((DBT *)); int dbt_rprint __P((DBT *)); int digitize __P((int)); +int main __P((int, char *[])); void rheader __P((DBTYPE *, int *, DB_INFO *)); void usage __P((void)); -int main __P((int, char *[])); -const char *progname = "db_load"; /* Program name. */ +const char + *progname = "db_load"; /* Program name. */ int main(argc, argv) @@ -273,7 +274,7 @@ rheader(dbtypep, pflagp, dbinfop) for (lineno = 1;; ++lineno) { if (fscanf(stdin, "%[^=]=%s\n", name, value) != 2) - errx(1, "line %lu: unexpected line", lineno); + errx(1, "line %lu: unexpected format", lineno); if (strcmp(name, "HEADER") == 0) break; diff --git a/db2/progs/db_printlog/db_printlog.c b/db2/progs/db_printlog/db_printlog.c index 12c3655..6bbd118 100644 --- a/db2/progs/db_printlog/db_printlog.c +++ b/db2/progs/db_printlog/db_printlog.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_printlog.c 10.8 (Sleepycat) 7/15/97"; +static const char sccsid[] = "@(#)db_printlog.c 10.10 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -35,11 +35,13 @@ static const char sccsid[] = "@(#)db_printlog.c 10.8 (Sleepycat) 7/15/97"; #include "clib_ext.h" DB_ENV *db_init __P((char *)); +int main __P((int, char *[])); void onint __P((int)); void usage __P((void)); int interrupted; -char *progname = "db_printlog"; /* Program name. */ +const char + *progname = "db_printlog"; /* Program name. */ int main(argc, argv) @@ -114,7 +116,7 @@ main(argc, argv) (void)raise(SIGINT); /* NOTREACHED */ } - exit (eval); + return (eval); } /* diff --git a/db2/progs/db_recover/db_recover.c b/db2/progs/db_recover/db_recover.c index 4ac5925..d17c4b0 100644 --- a/db2/progs/db_recover/db_recover.c +++ b/db2/progs/db_recover/db_recover.c @@ -11,16 +11,16 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_recover.c 10.12 (Sleepycat) 7/27/97"; +static const char sccsid[] = "@(#)db_recover.c 10.14 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES #include <sys/types.h> #include <errno.h> -#include <getopt.h> #include <stdlib.h> #include <time.h> +#include <unistd.h> #endif #include "db_int.h" @@ -29,10 +29,11 @@ static const char sccsid[] = "@(#)db_recover.c 10.12 (Sleepycat) 7/27/97"; #include "clib_ext.h" DB_ENV *db_init __P((char *, int, int)); -void usage __P((void)); int main __P((int, char *[])); +void usage __P((void)); -const char *progname = "db_recover"; /* Program name. */ +const char + *progname = "db_recover"; /* Program name. */ int main(argc, argv) diff --git a/db2/progs/db_stat/db_stat.c b/db2/progs/db_stat/db_stat.c index 5c7044d..1a989f4 100644 --- a/db2/progs/db_stat/db_stat.c +++ b/db2/progs/db_stat/db_stat.c @@ -11,7 +11,7 @@ static const char copyright[] = "@(#) Copyright (c) 1997\n\ Sleepycat Software Inc. All rights reserved.\n"; -static const char sccsid[] = "@(#)db_stat.c 8.17 (Sleepycat) 8/24/97"; +static const char sccsid[] = "@(#)db_stat.c 8.20 (Sleepycat) 8/27/97"; #endif #ifndef NO_SYSTEM_INCLUDES @@ -36,16 +36,17 @@ typedef enum { T_NOTSET, T_DB, T_MPOOL, T_TXN } test_t; void bstat __P((DB *)); DB_ENV *db_init __P((char *, test_t)); void hstat __P((DB *)); +int main __P((int, char *[])); void mstat __P((DB_ENV *)); -void prflags __P((u_int32_t, const FN *)); void onint __P((int)); +void prflags __P((u_int32_t, const FN *)); void tstat __P((DB_ENV *)); int txn_compare __P((const void *, const void *)); void usage __P((void)); -int main __P((int, char *[])); int interrupted; -const char *progname = "db_stat"; /* Program name. */ +const char + *progname = "db_stat"; /* Program name. */ int main(argc, argv) @@ -297,7 +298,7 @@ tstat(dbenv) DB_ENV *dbenv; { DB_TXN_STAT *tstat; - unsigned int i; + u_int32_t i; const char *p; if (txn_stat(dbenv->tx_info, &tstat, NULL)) diff --git a/db2/txn/txn.c b/db2/txn/txn.c index b20697b..cb700dc 100644 --- a/db2/txn/txn.c +++ b/db2/txn/txn.c @@ -43,7 +43,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)txn.c 10.20 (Sleepycat) 8/24/97"; +static const char sccsid[] = "@(#)txn.c 10.24 (Sleepycat) 9/3/97"; #endif /* not lint */ @@ -80,12 +80,11 @@ static const char sccsid[] = "@(#)txn.c 10.20 (Sleepycat) 8/24/97"; #include "common_ext.h" static int __txn_check_running __P((const DB_TXN *)); - -static int __txn_create __P((DB_ENV *, const char *, u_int)); -static int __txn_grow_region __P((DB_TXNMGR *)); -static int __txn_validate_region __P((DB_TXNMGR *)); -static int __txn_end __P((DB_TXN *, int)); -static int __txn_undo __P((DB_TXN *)); +static int __txn_create __P((DB_ENV *, const char *, u_int)); +static int __txn_end __P((DB_TXN *, int)); +static int __txn_grow_region __P((DB_TXNMGR *)); +static int __txn_undo __P((DB_TXN *)); +static int __txn_validate_region __P((DB_TXNMGR *)); /* * Create and initialize a transaction region in shared memory. @@ -622,6 +621,7 @@ txn_checkpoint(mgr, kbytes, minutes) if (minutes != 0 || kbytes != 0) return (0); +do_ckp: if (IS_ZERO_LSN(ckp_lsn)) { dblp = mgr->dbenv->lg_info; LOCK_LOGREGION(dblp); @@ -633,7 +633,6 @@ txn_checkpoint(mgr, kbytes, minutes) * We have to find an LSN such that all transactions begun * before that LSN are complete. */ -do_ckp: LOCK_TXNREGION(mgr); if (!IS_ZERO_LSN(mgr->region->pending_ckp)) @@ -755,8 +754,7 @@ txn_stat(mgr, statp, db_malloc) { DB_TXN_STAT *stats; size_t nbytes; - u_int32_t nactive; - unsigned int i, ndx; + u_int32_t i, nactive, ndx; LOCK_TXNREGION(mgr); nactive = mgr->region->nbegins - diff --git a/db2/txn/txn_rec.c b/db2/txn/txn_rec.c index 1fe720a..c172d87 100644 --- a/db2/txn/txn_rec.c +++ b/db2/txn/txn_rec.c @@ -40,7 +40,7 @@ #include "config.h" #ifndef lint -static const char sccsid[] = "@(#)txn_rec.c 10.4 (Sleepycat) 7/2/97"; +static const char sccsid[] = "@(#)txn_rec.c 10.5 (Sleepycat) 8/27/97"; #endif /* not lint */ #ifndef NO_SYSTEM_INCLUDES @@ -127,5 +127,5 @@ __txn_ckp_recover(logp, dbtp, lsnp, redo, info) *lsnp = argp->last_ckp; free(argp); - return (1); + return (DB_TXN_CKP); } |