diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2007-07-30 11:58:31 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2007-07-30 11:58:31 +0300 |
commit | cab228435bde1b5496522c03a4ce9840f2ef3701 (patch) | |
tree | 2c37b65d176e2de097603333f4de071c31eeff3d /db/tcl | |
parent | 2d07882d45e9e575c00f8f402d4c7271bb65cfe9 (diff) | |
download | librpm-tizen-cab228435bde1b5496522c03a4ce9840f2ef3701.tar.gz librpm-tizen-cab228435bde1b5496522c03a4ce9840f2ef3701.tar.bz2 librpm-tizen-cab228435bde1b5496522c03a4ce9840f2ef3701.zip |
Update internal BDB to version 4.6.18.
Diffstat (limited to 'db/tcl')
-rw-r--r-- | db/tcl/docs/db.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/env.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/historic.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/index.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/library.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/lock.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/log.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/mpool.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/rep.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/sequence.html | 1 | ||||
-rw-r--r-- | db/tcl/docs/test.html | 3 | ||||
-rw-r--r-- | db/tcl/docs/txn.html | 3 | ||||
-rw-r--r-- | db/tcl/tcl_compat.c | 7 | ||||
-rw-r--r-- | db/tcl/tcl_db.c | 118 | ||||
-rw-r--r-- | db/tcl/tcl_db_pkg.c | 193 | ||||
-rw-r--r-- | db/tcl/tcl_dbcursor.c | 33 | ||||
-rw-r--r-- | db/tcl/tcl_env.c | 150 | ||||
-rw-r--r-- | db/tcl/tcl_internal.c | 33 | ||||
-rw-r--r-- | db/tcl/tcl_lock.c | 20 | ||||
-rw-r--r-- | db/tcl/tcl_log.c | 9 | ||||
-rw-r--r-- | db/tcl/tcl_mp.c | 34 | ||||
-rw-r--r-- | db/tcl/tcl_rep.c | 197 | ||||
-rw-r--r-- | db/tcl/tcl_seq.c | 7 | ||||
-rw-r--r-- | db/tcl/tcl_txn.c | 14 | ||||
-rw-r--r-- | db/tcl/tcl_util.c | 7 |
25 files changed, 657 insertions, 199 deletions
diff --git a/db/tcl/docs/db.html b/db/tcl/docs/db.html index 91a5e6542..2e6b3d666 100644 --- a/db/tcl/docs/db.html +++ b/db/tcl/docs/db.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/env.html b/db/tcl/docs/env.html index cb73bed10..a42824129 100644 --- a/db/tcl/docs/env.html +++ b/db/tcl/docs/env.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/historic.html b/db/tcl/docs/historic.html index 72b40b489..0c3032d23 100644 --- a/db/tcl/docs/historic.html +++ b/db/tcl/docs/historic.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/index.html b/db/tcl/docs/index.html index 7acf4d1ed..edec91c68 100644 --- a/db/tcl/docs/index.html +++ b/db/tcl/docs/index.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/library.html b/db/tcl/docs/library.html index 35ce8cf15..df8123327 100644 --- a/db/tcl/docs/library.html +++ b/db/tcl/docs/library.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/lock.html b/db/tcl/docs/lock.html index d418519ff..a21c9ca8e 100644 --- a/db/tcl/docs/lock.html +++ b/db/tcl/docs/lock.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/log.html b/db/tcl/docs/log.html index 0cda2bc47..5cdd6d38f 100644 --- a/db/tcl/docs/log.html +++ b/db/tcl/docs/log.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/mpool.html b/db/tcl/docs/mpool.html index 59372aa34..f47658daf 100644 --- a/db/tcl/docs/mpool.html +++ b/db/tcl/docs/mpool.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/rep.html b/db/tcl/docs/rep.html index 2f1ee7a58..7534639fc 100644 --- a/db/tcl/docs/rep.html +++ b/db/tcl/docs/rep.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/sequence.html b/db/tcl/docs/sequence.html index a0b3df068..de150cc11 100644 --- a/db/tcl/docs/sequence.html +++ b/db/tcl/docs/sequence.html @@ -1,3 +1,4 @@ +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> diff --git a/db/tcl/docs/test.html b/db/tcl/docs/test.html index f714beb37..7c1dd3eba 100644 --- a/db/tcl/docs/test.html +++ b/db/tcl/docs/test.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <HTML> <HEAD> <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> diff --git a/db/tcl/docs/txn.html b/db/tcl/docs/txn.html index 27892d3ea..d483c66f0 100644 --- a/db/tcl/docs/txn.html +++ b/db/tcl/docs/txn.html @@ -1,5 +1,4 @@ -<!--Copyright 1999-2006 by Oracle Corporation.--> -<!--All rights reserved.--> +<!--Copyright 1999,2007 Oracle. All rights reserved.--> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> diff --git a/db/tcl/tcl_compat.c b/db/tcl/tcl_compat.c index 79c63aa8c..3ca82d80d 100644 --- a/db/tcl/tcl_compat.c +++ b/db/tcl/tcl_compat.c @@ -1,10 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_compat.c,v 12.4 2006/08/24 14:46:32 bostic Exp $ + * $Id: tcl_compat.c,v 12.7 2007/05/17 15:15:54 bostic Exp $ */ #include "db_config.h" @@ -12,7 +11,7 @@ #define DB_DBM_HSEARCH 1 #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" diff --git a/db/tcl/tcl_db.c b/db/tcl/tcl_db.c index 9de948ea6..b39b879bc 100644 --- a/db/tcl/tcl_db.c +++ b/db/tcl/tcl_db.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_db.c,v 12.23 2006/08/24 14:46:32 bostic Exp $ + * $Id: tcl_db.c,v 12.33 2007/06/21 17:46:59 bostic Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/db_page.h" @@ -645,6 +644,7 @@ tcl_DbStat(interp, objc, objv, dbp) MAKE_STAT_LIST("Magic", hsp->hash_magic); MAKE_STAT_LIST("Version", hsp->hash_version); MAKE_STAT_LIST("Page size", hsp->hash_pagesize); + MAKE_STAT_LIST("Page count", hsp->hash_pagecnt); MAKE_STAT_LIST("Number of keys", hsp->hash_nkeys); MAKE_STAT_LIST("Number of records", hsp->hash_ndata); MAKE_STAT_LIST("Fill factor", hsp->hash_ffactor); @@ -688,6 +688,7 @@ tcl_DbStat(interp, objc, objv, dbp) MAKE_STAT_LIST("Fixed record length", bsp->bt_re_len); MAKE_STAT_LIST("Record pad", bsp->bt_re_pad); MAKE_STAT_LIST("Page size", bsp->bt_pagesize); + MAKE_STAT_LIST("Page count", bsp->bt_pagecnt); if (flag != DB_FAST_STAT) { MAKE_STAT_LIST("Levels", bsp->bt_levels); MAKE_STAT_LIST("Internal pages", bsp->bt_int_pg); @@ -1035,6 +1036,7 @@ tcl_DbGet(interp, objc, objv, dbp, ispget) #ifdef CONFIG_TEST "-data_buf_size", "-multi", + "-nolease", "-read_committed", "-read_uncommitted", #endif @@ -1053,6 +1055,7 @@ tcl_DbGet(interp, objc, objv, dbp, ispget) #ifdef CONFIG_TEST DBGET_DATA_BUF_SIZE, DBGET_MULTI, + DBGET_NOLEASE, DBGET_READ_COMMITTED, DBGET_READ_UNCOMMITTED, #endif @@ -1141,6 +1144,9 @@ tcl_DbGet(interp, objc, objv, dbp, ispget) goto out; i++; break; + case DBGET_NOLEASE: + rmw |= DB_IGNORE_LEASE; + break; case DBGET_READ_COMMITTED: rmw |= DB_READ_COMMITTED; break; @@ -1584,10 +1590,10 @@ tcl_DbGet(interp, objc, objv, dbp, ispget) if (ispget) { _debug_check(); F_SET(&pkey, DB_DBT_MALLOC); - ret = dbc->c_pget(dbc, &key, &pkey, &data, cflag | rmw); + ret = dbc->pget(dbc, &key, &pkey, &data, cflag | rmw); } else { _debug_check(); - ret = dbc->c_get(dbc, &key, &data, cflag | rmw); + ret = dbc->get(dbc, &key, &data, cflag | rmw); } result = _ReturnSetup(interp, ret, DB_RETOK_DBCGET(ret), "db get (cursor)"); @@ -1636,9 +1642,9 @@ tcl_DbGet(interp, objc, objv, dbp, ispget) data = save; if (ispget) { F_SET(&pkey, DB_DBT_MALLOC); - ret = dbc->c_pget(dbc, &key, &pkey, &data, cflag | rmw); + ret = dbc->pget(dbc, &key, &pkey, &data, cflag | rmw); } else - ret = dbc->c_get(dbc, &key, &data, cflag | rmw); + ret = dbc->get(dbc, &key, &data, cflag | rmw); if (ret == 0 && prefix != NULL && memcmp(key.data, prefix, strlen(prefix)) != 0) { /* @@ -1649,7 +1655,7 @@ tcl_DbGet(interp, objc, objv, dbp, ispget) } } out1: - (void)dbc->c_close(dbc); + (void)dbc->close(dbc); if (result == TCL_OK) Tcl_SetObjResult(interp, retlist); out: @@ -1867,7 +1873,7 @@ tcl_DbDelete(interp, objc, objv, dbp) flag = DB_FIRST; else flag = DB_SET_RANGE; - ret = dbc->c_get(dbc, &key, &data, flag); + ret = dbc->get(dbc, &key, &data, flag); while (ret == 0 && memcmp(key.data, prefix, strlen(prefix)) == 0) { /* @@ -1876,7 +1882,7 @@ tcl_DbDelete(interp, objc, objv, dbp) * move ahead. */ _debug_check(); - ret = dbc->c_del(dbc, 0); + ret = dbc->del(dbc, 0); if (ret != 0) { result = _ReturnSetup(interp, ret, DB_RETOK_DBCDEL(ret), "db c_del"); @@ -1888,7 +1894,7 @@ tcl_DbDelete(interp, objc, objv, dbp) */ memset(&key, 0, sizeof(key)); memset(&data, 0, sizeof(data)); - ret = dbc->c_get(dbc, &key, &data, DB_NEXT); + ret = dbc->get(dbc, &key, &data, DB_NEXT); } if (ret == DB_NOTFOUND) ret = 0; @@ -1898,7 +1904,7 @@ tcl_DbDelete(interp, objc, objv, dbp) * have multiple nuls at the end, so we free using __os_free(). */ __os_free(dbp->dbenv, prefix); - (void)dbc->c_close(dbc); + (void)dbc->close(dbc); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "db del"); } out: @@ -2191,10 +2197,12 @@ tcl_second_call(dbp, pkey, data, skey) DBT *skey; { DBTCL_INFO *ip; + DBT *tskey; Tcl_Interp *interp; - Tcl_Obj *pobj, *dobj, *objv[3]; + Tcl_Obj *pobj, *dobj, *objv[3], *robj, **skeylist; size_t len; int ilen, result, ret; + u_int32_t i, nskeys; void *retbuf, *databuf; ip = (DBTCL_INFO *)dbp->api_internal; @@ -2224,22 +2232,62 @@ tcl_second_call(dbp, pkey, data, skey) return (EINVAL); } - retbuf = Tcl_GetByteArrayFromObj(Tcl_GetObjResult(interp), &ilen); - len = (size_t)ilen; + robj = Tcl_GetObjResult(interp); + if (robj->typePtr == NULL || strcmp(robj->typePtr->name, "list") != 0) { + nskeys = 1; + skeylist = &robj; + tskey = skey; + } else { + if ((result = Tcl_ListObjGetElements(interp, + robj, &ilen, &skeylist)) != TCL_OK) { + __db_errx(dbp->dbenv, + "Could not get list elements from Tcl callback"); + return (EINVAL); + } + nskeys = (u_int32_t)ilen; - /* - * retbuf is owned by Tcl; copy it into malloc'ed memory. - * We need to use __os_umalloc rather than ufree because this will - * be freed by DB using __os_ufree--the DB_DBT_APPMALLOC flag - * tells DB to free application-allocated memory. - */ - if ((ret = __os_umalloc(dbp->dbenv, len, &databuf)) != 0) - return (ret); - memcpy(databuf, retbuf, len); + /* + * It would be nice to check for nskeys == 0 and return + * DB_DONOTINDEX, but Tcl does not distinguish between an empty + * string and an empty list, so that would disallow empty + * secondary keys. + */ + if (nskeys == 0) { + nskeys = 1; + skeylist = &robj; + } + if (nskeys == 1) + tskey = skey; + else { + memset(skey, 0, sizeof(DBT)); + if ((ret = __os_umalloc(dbp->dbenv, + nskeys * sizeof(DBT), &skey->data)) != 0) + return (ret); + skey->size = nskeys; + F_SET(skey, DB_DBT_MULTIPLE | DB_DBT_APPMALLOC); + tskey = (DBT *)skey->data; + } + } + + for (i = 0; i < nskeys; i++, tskey++) { + retbuf = Tcl_GetByteArrayFromObj(skeylist[i], &ilen); + len = (size_t)ilen; - skey->data = databuf; - skey->size = len; - F_SET(skey, DB_DBT_APPMALLOC); + /* + * retbuf is owned by Tcl; copy it into malloc'ed memory. + * We need to use __os_umalloc rather than ufree because this + * will be freed by DB using __os_ufree--the DB_DBT_APPMALLOC + * flag tells DB to free application-allocated memory. + */ + if ((ret = __os_umalloc(dbp->dbenv, len, &databuf)) != 0) + return (ret); + memcpy(databuf, retbuf, len); + + memset(tskey, 0, sizeof(DBT)); + tskey->data = databuf; + tskey->size = len; + F_SET(tskey, DB_DBT_APPMALLOC); + } return (0); } @@ -2457,7 +2505,7 @@ tcl_DbGetjoin(interp, objc, objv, dbp) goto out; } key.data = ktmp; - ret = (listp[j])->c_get(listp[j], &key, &data, DB_SET); + ret = (listp[j])->get(listp[j], &key, &data, DB_SET); if ((result = _ReturnSetup(interp, ret, DB_RETOK_DBCGET(ret), "db cget")) == TCL_ERROR) goto out; @@ -2475,7 +2523,7 @@ tcl_DbGetjoin(interp, objc, objv, dbp) memset(&data, 0, sizeof(data)); key.flags |= DB_DBT_MALLOC; data.flags |= DB_DBT_MALLOC; - ret = dbc->c_get(dbc, &key, &data, 0); + ret = dbc->get(dbc, &key, &data, 0); /* * Build up our {name value} sublist */ @@ -2487,7 +2535,7 @@ tcl_DbGetjoin(interp, objc, objv, dbp) __os_ufree(dbp->dbenv, data.data); } } - (void)dbc->c_close(dbc); + (void)dbc->close(dbc); if (result == TCL_OK) Tcl_SetObjResult(interp, retlist); out: @@ -2495,7 +2543,7 @@ out: __os_free(dbp->dbenv, ktmp); while (j) { if (listp[j]) - (void)(listp[j])->c_close(listp[j]); + (void)(listp[j])->close(listp[j]); j--; } __os_free(dbp->dbenv, listp); @@ -2682,11 +2730,11 @@ tcl_DbCount(interp, objc, objv, dbp) /* * Move our cursor to the key. */ - ret = dbc->c_get(dbc, &key, &data, DB_SET); + ret = dbc->get(dbc, &key, &data, DB_SET); if (ret == DB_KEYEMPTY || ret == DB_NOTFOUND) count = 0; else { - ret = dbc->c_count(dbc, &count, 0); + ret = dbc->count(dbc, &count, 0); if (ret != 0) { result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "db c count"); @@ -2698,7 +2746,7 @@ tcl_DbCount(interp, objc, objv, dbp) out: if (ktmp != NULL && freekey) __os_free(dbp->dbenv, ktmp); - (void)dbc->c_close(dbc); + (void)dbc->close(dbc); return (result); } diff --git a/db/tcl/tcl_db_pkg.c b/db/tcl/tcl_db_pkg.c index 398507b4b..1d0dd130f 100644 --- a/db/tcl/tcl_db_pkg.c +++ b/db/tcl/tcl_db_pkg.c @@ -1,10 +1,9 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_db_pkg.c,v 12.36 2006/09/08 19:22:21 bostic Exp $ + * $Id: tcl_db_pkg.c,v 12.51 2007/07/09 17:38:45 bostic Exp $ */ #include "db_config.h" @@ -14,7 +13,7 @@ #endif #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/db_page.h" @@ -417,6 +416,7 @@ bdb_EnvOpen(interp, objc, objv, ip, env) "-region_init", "-rep", "-rep_client", + "-rep_lease", "-rep_master", "-rep_transport", "-server", @@ -425,12 +425,14 @@ bdb_EnvOpen(interp, objc, objv, ip, env) "-snapshot", "-thread", "-time_notgranted", + "-txn_nowait", "-txn_timeout", "-txn_timestamp", "-verbose", "-wrnosync", #endif "-cachesize", + "-cache_max", "-create", "-data_dir", "-encryptaes", @@ -489,6 +491,7 @@ bdb_EnvOpen(interp, objc, objv, ip, env) ENV_REGION_INIT, ENV_REP, ENV_REP_CLIENT, + ENV_REP_LEASE, ENV_REP_MASTER, ENV_REP_TRANSPORT, ENV_SERVER, @@ -497,12 +500,14 @@ bdb_EnvOpen(interp, objc, objv, ip, env) ENV_SNAPSHOT, ENV_THREAD, ENV_TIME_NOTGRANTED, + ENV_TXN_NOWAIT, ENV_TXN_TIMEOUT, ENV_TXN_TIME, ENV_VERBOSE, ENV_WRNOSYNC, #endif ENV_CACHESIZE, + ENV_CACHE_MAX, ENV_CREATE, ENV_DATA_DIR, ENV_ENCRYPT_AES, @@ -814,6 +819,9 @@ bdb_EnvOpen(interp, objc, objv, ip, env) DB_RETOK_STD(ret), "lock_max"); } break; + case ENV_TXN_NOWAIT: + FLD_SET(set_flags, DB_TXN_NOWAIT); + break; case ENV_TXN_TIME: case ENV_TXN_TIMEOUT: case ENV_LOCK_TIMEOUT: @@ -959,7 +967,8 @@ bdb_EnvOpen(interp, objc, objv, ip, env) if (result != TCL_OK) break; _debug_check(); - ret = (*env)->set_mp_max_write(*env, intarg, intarg2); + ret = (*env)->set_mp_max_write( + *env, intarg, (db_timeout_t)intarg2); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "set_mp_max_write"); break; @@ -1021,6 +1030,23 @@ bdb_EnvOpen(interp, objc, objv, ip, env) rep_flags = DB_REP_MASTER; FLD_SET(open_flags, DB_INIT_REP); break; + case ENV_REP_LEASE: + if (i >= objc) { + Tcl_WrongNumArgs(interp, 2, objv, + "-rep_lease {nsites timeout clockskew}"); + result = TCL_ERROR; + break; + } + result = Tcl_ListObjGetElements(interp, objv[i], + &myobjc, &myobjv); + if (result == TCL_OK) + i++; + else + break; + result = tcl_RepLease(interp, myobjc, myobjv, *env); + if (result == TCL_OK) + FLD_SET(open_flags, DB_INIT_REP); + break; case ENV_REP_TRANSPORT: if (i >= objc) { Tcl_WrongNumArgs(interp, 2, objv, @@ -1190,6 +1216,30 @@ bdb_EnvOpen(interp, objc, objv, ip, env) result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "set_cachesize"); break; + case ENV_CACHE_MAX: + result = Tcl_ListObjGetElements(interp, objv[i], + &myobjc, &myobjv); + if (result == TCL_OK) + i++; + else + break; + if (myobjc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, + "?-cache_max {gbytes bytes}?"); + result = TCL_ERROR; + break; + } + result = _GetUInt32(interp, myobjv[0], &gbytes); + if (result != TCL_OK) + break; + result = _GetUInt32(interp, myobjv[1], &bytes); + if (result != TCL_OK) + break; + _debug_check(); + ret = (*env)->set_cache_max(*env, gbytes, bytes); + result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), + "set_cache_max"); + break; case ENV_SHM_KEY: if (i >= objc) { Tcl_WrongNumArgs(interp, 2, objv, @@ -1379,6 +1429,7 @@ bdb_DbOpen(interp, objc, objv, ip, dbp) #ifdef CONFIG_TEST "-btcompare", "-dupcompare", + "-hashcompare", "-hashproc", "-lorder", "-minkey", @@ -1432,6 +1483,7 @@ bdb_DbOpen(interp, objc, objv, ip, dbp) #ifdef CONFIG_TEST TCL_DB_BTCOMPARE, TCL_DB_DUPCOMPARE, + TCL_DB_HASHCOMPARE, TCL_DB_HASHPROC, TCL_DB_LORDER, TCL_DB_MINKEY, @@ -1562,15 +1614,13 @@ bdb_DbOpen(interp, objc, objv, ip, dbp) (*dbp)->api_internal = ip; /* - * XXX Remove restriction when err stuff is not tied to env. + * XXX + * Remove restriction if error handling not tied to env. * - * The DB->set_err* functions actually overwrite in the - * environment. So, if we are explicitly using an env, - * don't overwrite what we have already set up. If we are - * not using one, then we set up since we get a private - * default env. + * The DB->set_err* functions overwrite the environment. So, if + * we are using an env, don't overwrite it; if not using an env, + * then configure error handling. */ - /* XXX - remove this conditional if/when err is not tied to env */ if (envp == NULL) { (*dbp)->set_errpfx((*dbp), ip->i_name); (*dbp)->set_errcall((*dbp), _ErrorFunc); @@ -1619,8 +1669,8 @@ bdb_DbOpen(interp, objc, objv, ip, dbp) * Tcl's object refcounting will--I hope--take care * of the memory management here. */ - ip->i_btcompare = objv[i++]; - Tcl_IncrRefCount(ip->i_btcompare); + ip->i_compare = objv[i++]; + Tcl_IncrRefCount(ip->i_compare); _debug_check(); ret = (*dbp)->set_bt_compare(*dbp, tcl_bt_compare); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), @@ -1645,6 +1695,28 @@ bdb_DbOpen(interp, objc, objv, ip, dbp) result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "set_dup_compare"); break; + case TCL_DB_HASHCOMPARE: + if (i >= objc) { + Tcl_WrongNumArgs(interp, 2, objv, + "-hashcompare compareproc"); + result = TCL_ERROR; + break; + } + + /* + * Store the object containing the procedure name. + * We don't need to crack it out now--we'll want + * to bundle it up to pass into Tcl_EvalObjv anyway. + * Tcl's object refcounting will--I hope--take care + * of the memory management here. + */ + ip->i_compare = objv[i++]; + Tcl_IncrRefCount(ip->i_compare); + _debug_check(); + ret = (*dbp)->set_h_compare(*dbp, tcl_bt_compare); + result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), + "set_h_compare"); + break; case TCL_DB_HASHPROC: if (i >= objc) { Tcl_WrongNumArgs(interp, 2, objv, @@ -2595,6 +2667,17 @@ bdb_DbRemove(interp, objc, objv) goto error; } + /* + * XXX + * Remove restriction if error handling not tied to env. + * + * The DB->set_err* functions overwrite the environment. So, if + * we are using an env, don't overwrite it; if not using an env, + * then configure error handling. + */ + dbp->set_errpfx(dbp, "DbRemove"); + dbp->set_errcall(dbp, _ErrorFunc); + if (passwd != NULL) { ret = dbp->set_encrypt(dbp, passwd, enc_flag); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), @@ -2815,6 +2898,17 @@ bdb_DbRename(interp, objc, objv) "db_create"); goto error; } + /* + * XXX + * Remove restriction if error handling not tied to env. + * + * The DB->set_err* functions overwrite the environment. So, if + * we are using an env, don't overwrite it; if not using an env, + * then configure error handling. + */ + dbp->set_errpfx(dbp, "DbRename"); + dbp->set_errcall(dbp, _ErrorFunc); + if (passwd != NULL) { ret = dbp->set_encrypt(dbp, passwd, enc_flag); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), @@ -2865,6 +2959,8 @@ bdb_DbVerify(interp, objc, objv) "-env", "-errfile", "-errpfx", + "-noorderchk", + "-orderchkonly", "-unref", "--", NULL @@ -2876,6 +2972,8 @@ bdb_DbVerify(interp, objc, objv) TCL_DBVRFY_ENV, TCL_DBVRFY_ERRFILE, TCL_DBVRFY_ERRPFX, + TCL_DBVRFY_NOORDERCHK, + TCL_DBVRFY_ORDERCHKONLY, TCL_DBVRFY_UNREF, TCL_DBVRFY_ENDARG }; @@ -2883,14 +2981,15 @@ bdb_DbVerify(interp, objc, objv) DB *dbp; FILE *errf; u_int32_t enc_flag, flags, set_flags; - int endarg, i, optindex, result, ret; - char *arg, *db, *errpfx, *passwd; + int endarg, i, optindex, result, ret, subdblen; + char *arg, *db, *errpfx, *passwd, *subdb; + u_char *subdbtmp; envp = NULL; dbp = NULL; passwd = NULL; result = TCL_OK; - db = errpfx = NULL; + db = errpfx = subdb = NULL; errf = NULL; flags = endarg = 0; enc_flag = set_flags = 0; @@ -2994,6 +3093,12 @@ bdb_DbVerify(interp, objc, objv) break; } break; + case TCL_DBVRFY_NOORDERCHK: + flags |= DB_NOORDERCHK; + break; + case TCL_DBVRFY_ORDERCHKONLY: + flags |= DB_ORDERCHKONLY; + break; case TCL_DBVRFY_UNREF: flags |= DB_UNREF; break; @@ -3015,9 +3120,32 @@ bdb_DbVerify(interp, objc, objv) /* * The remaining arg is the db filename. */ - if (i == (objc - 1)) + /* + * Any args we have left, (better be 1 or 2 left) are + * file names. If there is 1, a db name, if 2 a db and subdb name. + */ + if (i != objc) { + /* + * Dbs must be NULL terminated file names, but subdbs can + * be anything. Use Strings for the db name and byte + * arrays for the subdb. + */ db = Tcl_GetStringFromObj(objv[i++], NULL); - else { + if (strcmp(db, "") == 0) + db = NULL; + if (i != objc) { + subdbtmp = + Tcl_GetByteArrayFromObj(objv[i++], &subdblen); + if ((ret = __os_malloc(envp, + (size_t)subdblen + 1, &subdb)) != 0) { + Tcl_SetResult(interp, db_strerror(ret), + TCL_STATIC); + return (0); + } + memcpy(subdb, subdbtmp, (size_t)subdblen); + subdb[subdblen] = '\0'; + } + } else { Tcl_WrongNumArgs(interp, 2, objv, "?args? filename"); result = TCL_ERROR; goto error; @@ -3048,7 +3176,7 @@ bdb_DbVerify(interp, objc, objv) /* * The verify method is a destructor, NULL out the dbp. */ - ret = dbp->verify(dbp, db, NULL, NULL, flags); + ret = dbp->verify(dbp, db, subdb, NULL, flags); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "db verify"); dbp = NULL; error: @@ -3256,11 +3384,11 @@ bdb_MsgType(interp, objc, objv) static const char *msgnames[] = { "no_type", "alive", "alive_req", "all_req", "bulk_log", "bulk_page", - "dupmaster", "file", "file_fail", "file_req", "log", - "log_more", "log_req", "master_req", "newclient", + "dupmaster", "file", "file_fail", "file_req", "lease_grant", + "log", "log_more", "log_req", "master_req", "newclient", "newfile", "newmaster", "newsite", "page", "page_fail", "page_more", "page_req", - "rerequest", "update", "update_req", + "rerequest", "startsync", "update", "update_req", "verify", "verify_fail", "verify_req", "vote1", "vote2", NULL }; @@ -3381,6 +3509,18 @@ bdb_DbUpgrade(interp, objc, objv) goto error; } + /* + * XXX + * Remove restriction if error handling not tied to env. + * + * The DB->set_err* functions overwrite the environment. So, if + * we are using an env, don't overwrite it; if not using an env, + * then configure error handling. + */ + if (envp == NULL) { + dbp->set_errpfx(dbp, "DbUpgrade"); + dbp->set_errcall(dbp, _ErrorFunc); + } ret = dbp->upgrade(dbp, db, flags); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "db upgrade"); error: @@ -3401,7 +3541,7 @@ tcl_bt_compare(dbp, dbta, dbtb) const DBT *dbta, *dbtb; { return (tcl_compare_callback(dbp, dbta, dbtb, - ((DBTCL_INFO *)dbp->api_internal)->i_btcompare, "bt_compare")); + ((DBTCL_INFO *)dbp->api_internal)->i_compare, "bt_compare")); } static int @@ -3417,7 +3557,7 @@ tcl_dup_compare(dbp, dbta, dbtb) * tcl_compare_callback -- * Tcl callback for set_bt_compare and set_dup_compare. What this * function does is stuff the data fields of the two DBTs into Tcl ByteArray - * objects, then call the procedure stored in ip->i_btcompare on the two + * objects, then call the procedure stored in ip->i_compare on the two * objects. Then we return that procedure's result as the comparison. */ static int @@ -3612,7 +3752,8 @@ tcl_rep_send(dbenv, control, rec, lsnp, eid, flags) * this error should only happen if the Tcl callback is * somehow invalid, which is a fatal scripting bug. */ -err: __db_errx(dbenv, "Tcl rep_send failure"); +err: __db_errx(dbenv, "Tcl rep_send failure: %s", + Tcl_GetStringResult(interp)); return (EINVAL); } diff --git a/db/tcl/tcl_dbcursor.c b/db/tcl/tcl_dbcursor.c index 1e40afa83..ed45f4b5a 100644 --- a/db/tcl/tcl_dbcursor.c +++ b/db/tcl/tcl_dbcursor.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_dbcursor.c,v 12.11 2006/08/24 14:46:33 bostic Exp $ + * $Id: tcl_dbcursor.c,v 12.17 2007/05/17 15:15:54 bostic Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" @@ -100,7 +99,7 @@ dbc_Cmd(clientData, interp, objc, objv) return (TCL_ERROR); } _debug_check(); - ret = dbc->c_close(dbc); + ret = dbc->close(dbc); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "dbc close"); if (result == TCL_OK) { @@ -117,7 +116,7 @@ dbc_Cmd(clientData, interp, objc, objv) return (TCL_ERROR); } _debug_check(); - ret = dbc->c_del(dbc, 0); + ret = dbc->del(dbc, 0); result = _ReturnSetup(interp, ret, DB_RETOK_DBCDEL(ret), "dbc delete"); break; @@ -349,7 +348,7 @@ tcl_DbcPut(interp, objc, objv, dbc) goto out; } _debug_check(); - ret = dbc->c_put(dbc, &key, &data, flag); + ret = dbc->put(dbc, &key, &data, flag); result = _ReturnSetup(interp, ret, DB_RETOK_DBCPUT(ret), "dbc put"); if (ret == 0 && @@ -383,6 +382,7 @@ tcl_DbcGet(interp, objc, objv, dbc, ispget) "-key_buf_size", "-multi", "-multi_key", + "-nolease", "-read_committed", "-read_uncommitted", #endif @@ -397,6 +397,7 @@ tcl_DbcGet(interp, objc, objv, dbc, ispget) "-nextnodup", "-partial", "-prev", + "-prevdup", "-prevnodup", "-rmw", "-set", @@ -411,6 +412,7 @@ tcl_DbcGet(interp, objc, objv, dbc, ispget) DBCGET_KEY_BUF_SIZE, DBCGET_MULTI, DBCGET_MULTI_KEY, + DBCGET_NOLEASE, DBCGET_READ_COMMITTED, DBCGET_READ_UNCOMMITTED, #endif @@ -425,6 +427,7 @@ tcl_DbcGet(interp, objc, objv, dbc, ispget) DBCGET_NEXTNODUP, DBCGET_PART, DBCGET_PREV, + DBCGET_PREVDUP, DBCGET_PREVNODUP, DBCGET_RMW, DBCGET_SET, @@ -482,7 +485,8 @@ tcl_DbcGet(interp, objc, objv, dbc, ispget) i++; #define FLAG_CHECK2_STDARG \ - (DB_RMW | DB_MULTIPLE | DB_MULTIPLE_KEY | DB_READ_UNCOMMITTED) + (DB_RMW | DB_MULTIPLE | DB_MULTIPLE_KEY | DB_IGNORE_LEASE | \ + DB_READ_UNCOMMITTED) switch ((enum dbcgetopts)optindex) { #ifdef CONFIG_TEST @@ -520,6 +524,9 @@ tcl_DbcGet(interp, objc, objv, dbc, ispget) goto out; i++; break; + case DBCGET_NOLEASE: + flag |= DB_IGNORE_LEASE; + break; case DBCGET_READ_COMMITTED: flag |= DB_READ_COMMITTED; break; @@ -550,6 +557,10 @@ tcl_DbcGet(interp, objc, objv, dbc, ispget) FLAG_CHECK2(flag, FLAG_CHECK2_STDARG); flag |= DB_PREV; break; + case DBCGET_PREVDUP: + FLAG_CHECK2(flag, FLAG_CHECK2_STDARG); + flag |= DB_PREV_DUP; + break; case DBCGET_PREVNODUP: FLAG_CHECK2(flag, FLAG_CHECK2_STDARG); flag |= DB_PREV_NODUP; @@ -777,9 +788,9 @@ tcl_DbcGet(interp, objc, objv, dbc, ispget) _debug_check(); if (ispget) { F_SET(&pdata, DB_DBT_MALLOC); - ret = dbc->c_pget(dbc, &key, &data, &pdata, flag); + ret = dbc->pget(dbc, &key, &data, &pdata, flag); } else - ret = dbc->c_get(dbc, &key, &data, flag); + ret = dbc->get(dbc, &key, &data, flag); result = _ReturnSetup(interp, ret, DB_RETOK_DBCGET(ret), "dbc get"); if (result == TCL_ERROR) goto out; @@ -937,7 +948,7 @@ tcl_DbcDup(interp, objc, objv, dbc) "%s.c%d", dbip->i_name, dbip->i_dbdbcid); newdbcip = _NewInfo(interp, NULL, newname, I_DBC); if (newdbcip != NULL) { - ret = dbc->c_dup(dbc, &newdbc, flag); + ret = dbc->dup(dbc, &newdbc, flag); if (ret == 0) { dbip->i_dbdbcid++; newdbcip->i_parent = dbip; diff --git a/db/tcl/tcl_env.c b/db/tcl/tcl_env.c index ac18c40cf..b6b61f1ec 100644 --- a/db/tcl/tcl_env.c +++ b/db/tcl/tcl_env.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_env.c,v 12.29 2006/08/24 14:46:33 bostic Exp $ + * $Id: tcl_env.c,v 12.40 2007/06/21 22:28:47 sue Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/lock.h" @@ -76,6 +75,7 @@ env_Cmd(clientData, interp, objc, objv) "rep_elect", "rep_flush", "rep_get_config", + "rep_lease", "rep_limit", "rep_process_message", "rep_request", @@ -84,6 +84,7 @@ env_Cmd(clientData, interp, objc, objv) "rep_sync", "rep_transport", "repmgr", + "repmgr_stat", "rpcid", "set_flags", "test", @@ -98,6 +99,7 @@ env_Cmd(clientData, interp, objc, objv) "dbremove", "dbrename", "get_cachesize", + "get_cache_max", "get_data_dirs", "get_encrypt_flags", "get_errpfx", @@ -124,6 +126,7 @@ env_Cmd(clientData, interp, objc, objv) "get_tx_max", "get_tx_timestamp", "get_verbose", + "resize_cache", "set_data_dir", "txn", "txn_checkpoint", @@ -161,6 +164,7 @@ env_Cmd(clientData, interp, objc, objv) ENVREPELECT, ENVREPFLUSH, ENVREPGETCONFIG, + ENVREPLEASE, ENVREPLIMIT, ENVREPPROCMESS, ENVREPREQUEST, @@ -169,6 +173,7 @@ env_Cmd(clientData, interp, objc, objv) ENVREPSYNC, ENVREPTRANSPORT, ENVREPMGR, + ENVREPMGRSTAT, ENVRPCID, ENVSETFLAGS, ENVTEST, @@ -183,6 +188,7 @@ env_Cmd(clientData, interp, objc, objv) ENVDBREMOVE, ENVDBRENAME, ENVGETCACHESIZE, + ENVGETCACHEMAX, ENVGETDATADIRS, ENVGETENCRYPTFLAGS, ENVGETERRPFX, @@ -209,28 +215,27 @@ env_Cmd(clientData, interp, objc, objv) ENVGETTXMAX, ENVGETTXTIMESTAMP, ENVGETVERBOSE, + ENVRESIZECACHE, ENVSETDATADIR, ENVTXN, ENVTXNCKP }; DBTCL_INFO *envip; DB_ENV *dbenv; - Tcl_Obj *myobjv[3], *res; - char newname[MSG_SIZE]; - int cmdindex, i, intvalue1, intvalue2, ncache, result, ret; - u_int32_t bytes, gbytes, value; + Tcl_Obj **listobjv, *myobjv[3], *res; + db_timeout_t timeout; size_t size; - long shm_key; time_t timeval; + u_int32_t bytes, gbytes, value; + long shm_key; + int cmdindex, i, intvalue, listobjc, ncache, result, ret; const char *strval, **dirs; - char *strarg; + char *strarg, newname[MSG_SIZE]; #ifdef CONFIG_TEST DBTCL_INFO *logcip; DB_LOGC *logc; - Tcl_Obj **repobjv; u_int32_t lockid; long newval, otherval; - int repobjc; #endif Tcl_ResetResult(interp); @@ -425,6 +430,17 @@ env_Cmd(clientData, interp, objc, objv) } result = tcl_RepGetConfig(interp, dbenv, objv[2]); break; + case ENVREPLEASE: + if (objc != 3) { + Tcl_WrongNumArgs(interp, 2, objv, NULL); + return (TCL_ERROR); + } + result = Tcl_ListObjGetElements(interp, objv[2], + &listobjc, &listobjv); + if (result == TCL_OK) + result = tcl_RepLease(interp, + listobjc, listobjv, dbenv); + break; case ENVREPLIMIT: result = tcl_RepLimit(interp, objc, objv, dbenv); break; @@ -449,14 +465,17 @@ env_Cmd(clientData, interp, objc, objv) return (TCL_ERROR); } result = Tcl_ListObjGetElements(interp, objv[2], - &repobjc, &repobjv); + &listobjc, &listobjv); if (result == TCL_OK) result = tcl_RepTransport(interp, - repobjc, repobjv, dbenv, envip); + listobjc, listobjv, dbenv, envip); break; case ENVREPMGR: result = tcl_RepMgr(interp, objc, objv, dbenv); break; + case ENVREPMGRSTAT: + result = tcl_RepMgrStat(interp, objc, objv, dbenv); + break; case ENVRPCID: /* * No args for this. Error if there are some. @@ -592,6 +611,19 @@ env_Cmd(clientData, interp, objc, objv) res = Tcl_NewListObj(3, myobjv); } break; + case ENVGETCACHEMAX: + if (objc != 2) { + Tcl_WrongNumArgs(interp, 1, objv, NULL); + return (TCL_ERROR); + } + ret = dbenv->get_cache_max(dbenv, &gbytes, &bytes); + if ((result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), + "env get_cache_max")) == TCL_OK) { + myobjv[0] = Tcl_NewLongObj((long)gbytes); + myobjv[1] = Tcl_NewLongObj((long)bytes); + res = Tcl_NewListObj(2, myobjv); + } + break; case ENVGETDATADIRS: if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, NULL); @@ -655,10 +687,10 @@ env_Cmd(clientData, interp, objc, objv) Tcl_WrongNumArgs(interp, 1, objv, NULL); return (TCL_ERROR); } - ret = dbenv->get_lg_filemode(dbenv, &intvalue1); + ret = dbenv->get_lg_filemode(dbenv, &intvalue); if ((result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "env get_lg_filemode")) == TCL_OK) - res = Tcl_NewLongObj((long)intvalue1); + res = Tcl_NewLongObj((long)intvalue); break; case ENVGETLGMAX: if (objc != 2) { @@ -718,21 +750,21 @@ env_Cmd(clientData, interp, objc, objv) Tcl_WrongNumArgs(interp, 1, objv, NULL); return (TCL_ERROR); } - ret = dbenv->get_mp_max_openfd(dbenv, &intvalue1); + ret = dbenv->get_mp_max_openfd(dbenv, &intvalue); if ((result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "env get_mp_max_openfd")) == TCL_OK) - res = Tcl_NewIntObj(intvalue1); + res = Tcl_NewIntObj(intvalue); break; case ENVGETMPMAXWRITE: if (objc != 2) { Tcl_WrongNumArgs(interp, 1, objv, NULL); return (TCL_ERROR); } - ret = dbenv->get_mp_max_write(dbenv, &intvalue1, &intvalue2); + ret = dbenv->get_mp_max_write(dbenv, &intvalue, &timeout); if ((result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "env get_mp_max_write")) == TCL_OK) { - myobjv[0] = Tcl_NewIntObj(intvalue1); - myobjv[1] = Tcl_NewIntObj(intvalue2); + myobjv[0] = Tcl_NewIntObj(intvalue); + myobjv[1] = Tcl_NewIntObj((int)timeout); res = Tcl_NewListObj(2, myobjv); } break; @@ -818,6 +850,26 @@ env_Cmd(clientData, interp, objc, objv) case ENVGETVERBOSE: result = env_GetVerbose(interp, objc, objv, dbenv); break; + case ENVRESIZECACHE: + if ((result = Tcl_ListObjGetElements( + interp, objv[2], &listobjc, &listobjv)) != TCL_OK) + break; + if (objc != 3 || listobjc != 2) { + Tcl_WrongNumArgs(interp, 2, objv, + "?-resize_cache {gbytes bytes}?"); + result = TCL_ERROR; + break; + } + result = _GetUInt32(interp, listobjv[0], &gbytes); + if (result != TCL_OK) + break; + result = _GetUInt32(interp, listobjv[1], &bytes); + if (result != TCL_OK) + break; + ret = dbenv->set_cachesize(dbenv, gbytes, bytes, 0); + result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), + "resize_cache"); + break; case ENVSETDATADIR: /* * One args for this. Error if different. @@ -1067,6 +1119,8 @@ tcl_EnvRemove(interp, objc, objv, dbenv, envip) if (result != TCL_OK) goto error; } + e->set_errpfx(e, "EnvRemove"); + e->set_errcall(e, _ErrorFunc); } else { /* * We have to clean up any info associated with this env, @@ -1270,6 +1324,8 @@ tcl_EnvVerbose(interp, dbenv, which, onoff) { static const char *verbwhich[] = { "deadlock", + "fileops", + "fileops_all", "recovery", "register", "rep", @@ -1278,6 +1334,8 @@ tcl_EnvVerbose(interp, dbenv, which, onoff) }; enum verbwhich { ENVVERB_DEADLOCK, + ENVVERB_FILEOPS, + ENVVERB_FILEOPS_ALL, ENVVERB_RECOVERY, ENVVERB_REGISTER, ENVVERB_REPLICATION, @@ -1303,6 +1361,12 @@ tcl_EnvVerbose(interp, dbenv, which, onoff) case ENVVERB_DEADLOCK: wh = DB_VERB_DEADLOCK; break; + case ENVVERB_FILEOPS: + wh = DB_VERB_FILEOPS; + break; + case ENVVERB_FILEOPS_ALL: + wh = DB_VERB_FILEOPS_ALL; + break; case ENVVERB_RECOVERY: wh = DB_VERB_RECOVERY; break; @@ -1591,9 +1655,20 @@ tcl_EnvSetFlags(interp, dbenv, which, onoff) } /* - * PUBLIC: int tcl_EnvTest __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *)); - * * tcl_EnvTest -- + * The "$env test ..." command is a sort of catch-all for any sort of + * desired test hook manipulation. The "abort", "check" and "copy" subcommands + * all set one or another certain location in the DB_ENV handle to a specific + * value. (In the case of "check", the value is an integer passed in with the + * command itself. For the other two, the "value" is a predefined enum + * constant, specified by name.) + * The "$env test force ..." subcommand invokes other, more arbitrary + * manipulations. + * Although these functions may not all seem closely related, putting them + * all under the name "test" has the aesthetic appeal of keeping the rest of the + * API clean. + * + * PUBLIC: int tcl_EnvTest __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_ENV *)); */ int tcl_EnvTest(interp, objc, objv, dbenv) @@ -1606,12 +1681,14 @@ tcl_EnvTest(interp, objc, objv, dbenv) "abort", "check", "copy", + "force", NULL }; enum envtestcmd { ENVTEST_ABORT, ENVTEST_CHECK, - ENVTEST_COPY + ENVTEST_COPY, + ENVTEST_FORCE }; static const char *envtestat[] = { "electinit", @@ -1642,13 +1719,21 @@ tcl_EnvTest(interp, objc, objv, dbenv) ENVTEST_RECYCLE, ENVTEST_SUBDB_LOCKS }; + static const char *envtestforce[] = { + "noarchive_timeout", + NULL + }; + enum envtestforce { + ENVTEST_NOARCHIVE_TIMEOUT + }; int *loc, optindex, result, testval; result = TCL_OK; loc = NULL; if (objc != 4) { - Tcl_WrongNumArgs(interp, 2, objv, "abort|copy location"); + Tcl_WrongNumArgs(interp, + 2, objv, "abort|check|copy|force <args>"); return (TCL_ERROR); } @@ -1674,6 +1759,19 @@ tcl_EnvTest(interp, objc, objv, dbenv) case ENVTEST_COPY: loc = &dbenv->test_copy; break; + case ENVTEST_FORCE: + if (Tcl_GetIndexFromObj(interp, objv[3], envtestforce, "arg", + TCL_EXACT, &optindex) != TCL_OK) { + result = IS_HELP(objv[3]); + return (result); + } + /* + * In the future we might add more, and then we'd use a switch + * statement. + */ + DB_ASSERT(dbenv, + (enum envtestforce)optindex == ENVTEST_NOARCHIVE_TIMEOUT); + return (tcl_RepNoarchiveTimeout(interp, dbenv)); default: Tcl_SetResult(interp, "Illegal store location", TCL_STATIC); return (TCL_ERROR); @@ -2310,6 +2408,8 @@ env_GetVerbose(interp, objc, objv, dbenv) char *arg; } verbose_flags[] = { { DB_VERB_DEADLOCK, "deadlock" }, + { DB_VERB_FILEOPS, "fileops" }, + { DB_VERB_FILEOPS_ALL, "fileops_all" }, { DB_VERB_RECOVERY, "recovery" }, { DB_VERB_REGISTER, "register" }, { DB_VERB_REPLICATION, "rep" }, diff --git a/db/tcl/tcl_internal.c b/db/tcl/tcl_internal.c index d1071c71c..42543ad00 100644 --- a/db/tcl/tcl_internal.c +++ b/db/tcl/tcl_internal.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_internal.c,v 12.13 2006/08/24 14:46:33 bostic Exp $ + * $Id: tcl_internal.c,v 12.24 2007/05/17 17:18:05 bostic Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" @@ -151,8 +150,8 @@ _DeleteInfo(p) } if (p->i_errpfx != NULL) __os_free(NULL, p->i_errpfx); - if (p->i_btcompare != NULL) - Tcl_DecrRefCount(p->i_btcompare); + if (p->i_compare != NULL) + Tcl_DecrRefCount(p->i_compare); if (p->i_dupcompare != NULL) Tcl_DecrRefCount(p->i_dupcompare); if (p->i_hashproc != NULL) @@ -163,6 +162,8 @@ _DeleteInfo(p) Tcl_DecrRefCount(p->i_rep_eid); if (p->i_rep_send != NULL) Tcl_DecrRefCount(p->i_rep_send); + if (p->i_event != NULL) + Tcl_DecrRefCount(p->i_event); __os_free(NULL, p->i_name); __os_free(NULL, p); @@ -510,7 +511,7 @@ _EventFunc(dbenv, event, info) void *info; { #define TCLDB_EVENTITEMS 2 /* Event name and any info */ -#define TCLDB_SENDEVENT 2 +#define TCLDB_SENDEVENT 3 /* Event Tcl proc, env name, event objects. */ DBTCL_INFO *ip; Tcl_Interp *interp; Tcl_Obj *event_o, *origobj; @@ -522,6 +523,7 @@ _EventFunc(dbenv, event, info) if (ip->i_event == NULL) return; objv[0] = ip->i_event; + objv[1] = NewStringObj(ip->i_name, strlen(ip->i_name)); /* * Most events don't have additional info. Assume none @@ -540,6 +542,9 @@ _EventFunc(dbenv, event, info) case DB_EVENT_REP_CLIENT: myobjv[0] = NewStringObj("rep_client", strlen("rep_client")); break; + case DB_EVENT_REP_ELECTED: + myobjv[0] = NewStringObj("elected", strlen("elected")); + break; case DB_EVENT_REP_MASTER: myobjv[0] = NewStringObj("rep_master", strlen("rep_master")); break; @@ -550,6 +555,9 @@ _EventFunc(dbenv, event, info) myobjv[0] = NewStringObj("newmaster", strlen("newmaster")); myobjv[myobjc++] = Tcl_NewIntObj(*(int *)info); break; + case DB_EVENT_REP_PERM_FAILED: + myobjv[0] = NewStringObj("perm_failed", strlen("perm_failed")); + break; case DB_EVENT_REP_STARTUPDONE: myobjv[0] = NewStringObj("startupdone", strlen("startupdone")); break; @@ -567,7 +575,7 @@ _EventFunc(dbenv, event, info) event_o = Tcl_NewListObj(myobjc, myobjv); Tcl_IncrRefCount(event_o); - objv[1] = event_o; + objv[2] = event_o; /* * We really want to return the original result to the @@ -589,7 +597,7 @@ _EventFunc(dbenv, event, info) * For now, abort. */ __db_errx(dbenv, "Tcl event failure"); - abort(); + __os_abort(); } Tcl_SetObjResult(interp, origobj); @@ -695,6 +703,13 @@ _GetFlagsList(interp, flags, fnp) newlist = Tcl_NewObj(); /* + * If the Berkeley DB library wasn't compiled with statistics, then + * we may get a NULL reference. + */ + if (fnp == NULL) + return (newlist); + + /* * Append a Tcl_Obj containing each pertinent flag string to the * specified Tcl list. */ diff --git a/db/tcl/tcl_lock.c b/db/tcl/tcl_lock.c index bc73bf81b..7747afb14 100644 --- a/db/tcl/tcl_lock.c +++ b/db/tcl/tcl_lock.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_lock.c,v 12.6 2006/08/24 14:46:33 bostic Exp $ + * $Id: tcl_lock.c,v 12.12 2007/06/22 17:39:08 bostic Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" @@ -238,6 +237,7 @@ tcl_LockStat(interp, objc, objv, envp) * list pairs and free up the memory. */ res = Tcl_NewObj(); +#ifdef HAVE_STATISTICS /* * MAKE_STAT_LIST assumes 'res' and 'error' label. */ @@ -265,10 +265,22 @@ tcl_LockStat(interp, objc, objv, envp) MAKE_STAT_LIST("Deadlocks detected", sp->st_ndeadlocks); MAKE_STAT_LIST("Number of region lock waits", sp->st_region_wait); MAKE_STAT_LIST("Number of region lock nowaits", sp->st_region_nowait); + MAKE_STAT_LIST("Number of object allocation waits", sp->st_objs_wait); + MAKE_STAT_LIST("Number of object allocation nowaits", + sp->st_objs_nowait); + MAKE_STAT_LIST("Number of locker allocation waits", + sp->st_lockers_wait); + MAKE_STAT_LIST("Number of locker allocation nowaits", + sp->st_lockers_nowait); + MAKE_STAT_LIST("Number of lock allocation waits", sp->st_locks_wait); + MAKE_STAT_LIST( + "Number of lock allocation nowaits", sp->st_locks_nowait); + MAKE_STAT_LIST("Maximum hash bucket length", sp->st_hash_len); MAKE_STAT_LIST("Lock timeout value", sp->st_locktimeout); MAKE_STAT_LIST("Number of lock timeouts", sp->st_nlocktimeouts); MAKE_STAT_LIST("Transaction timeout value", sp->st_txntimeout); MAKE_STAT_LIST("Number of transaction timeouts", sp->st_ntxntimeouts); +#endif Tcl_SetObjResult(interp, res); error: __os_ufree(envp, sp); diff --git a/db/tcl/tcl_log.c b/db/tcl/tcl_log.c index 650f632c9..0bad89091 100644 --- a/db/tcl/tcl_log.c +++ b/db/tcl/tcl_log.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_log.c,v 12.10 2006/08/24 14:46:33 bostic Exp $ + * $Id: tcl_log.c,v 12.14 2007/05/17 15:15:54 bostic Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/log.h" @@ -370,6 +369,7 @@ tcl_LogStat(interp, objc, objv, envp) /* * MAKE_STAT_LIST assumes 'res' and 'error' label. */ +#ifdef HAVE_STATISTICS MAKE_STAT_LIST("Magic", sp->st_magic); MAKE_STAT_LIST("Log file Version", sp->st_version); MAKE_STAT_LIST("Region size", sp->st_regsize); @@ -395,6 +395,7 @@ tcl_LogStat(interp, objc, objv, envp) MAKE_STAT_LIST("Min commits in a log flush", sp->st_mincommitperflush); MAKE_STAT_LIST("Number of region lock waits", sp->st_region_wait); MAKE_STAT_LIST("Number of region lock nowaits", sp->st_region_nowait); +#endif Tcl_SetObjResult(interp, res); error: __os_ufree(envp, sp); diff --git a/db/tcl/tcl_mp.c b/db/tcl/tcl_mp.c index ce205728a..15adbe41c 100644 --- a/db/tcl/tcl_mp.c +++ b/db/tcl/tcl_mp.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_mp.c,v 12.7 2006/09/11 14:53:42 bostic Exp $ + * $Id: tcl_mp.c,v 12.14 2007/06/22 17:41:45 bostic Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" @@ -24,7 +23,7 @@ static int pg_Cmd __P((ClientData, Tcl_Interp *, int, Tcl_Obj * CONST*)); static int tcl_MpGet __P((Tcl_Interp *, int, Tcl_Obj * CONST*, DB_MPOOLFILE *, DBTCL_INFO *)); static int tcl_Pg __P((Tcl_Interp *, int, Tcl_Obj * CONST*, - void *, DB_MPOOLFILE *, DBTCL_INFO *, int)); + void *, DB_MPOOLFILE *, DBTCL_INFO *)); static int tcl_PgInit __P((Tcl_Interp *, int, Tcl_Obj * CONST*, void *, DBTCL_INFO *)); static int tcl_PgIsset __P((Tcl_Interp *, int, Tcl_Obj * CONST*, @@ -340,12 +339,14 @@ tcl_MpStat(interp, objc, objv, envp) * list pairs and free up the memory. */ res = Tcl_NewObj(); +#ifdef HAVE_STATISTICS /* * MAKE_STAT_LIST assumes 'res' and 'error' label. */ MAKE_STAT_LIST("Cache size (gbytes)", sp->st_gbytes); MAKE_STAT_LIST("Cache size (bytes)", sp->st_bytes); MAKE_STAT_LIST("Number of caches", sp->st_ncache); + MAKE_STAT_LIST("Maximum number of caches", sp->st_max_ncache); MAKE_STAT_LIST("Region size", sp->st_regsize); MAKE_STAT_LIST("Maximum memory-mapped file size", sp->st_mmapsize); MAKE_STAT_LIST("Maximum open file descriptors", sp->st_maxopenfd); @@ -416,6 +417,7 @@ tcl_MpStat(interp, objc, objv, envp) if (result != TCL_OK) goto error; } +#endif Tcl_SetObjResult(interp, res1); error: __os_ufree(envp, sp); @@ -730,7 +732,6 @@ pg_Cmd(clientData, interp, objc, objv) "pgnum", "pgsize", "put", - "set", NULL }; enum pgcmds { @@ -738,8 +739,7 @@ pg_Cmd(clientData, interp, objc, objv) PGISSET, PGNUM, PGSIZE, - PGPUT, - PGSET + PGPUT }; DB_MPOOLFILE *mp; int cmdindex, length, result; @@ -784,10 +784,8 @@ pg_Cmd(clientData, interp, objc, objv) case PGSIZE: res = Tcl_NewWideIntObj((Tcl_WideInt)pgip->i_pgsz); break; - case PGSET: case PGPUT: - result = tcl_Pg(interp, objc, objv, page, mp, pgip, - (enum pgcmds)cmdindex == PGSET ? 0 : 1); + result = tcl_Pg(interp, objc, objv, page, mp, pgip); break; case PGINIT: result = tcl_PgInit(interp, objc, objv, page, pgip); @@ -807,14 +805,13 @@ pg_Cmd(clientData, interp, objc, objv) } static int -tcl_Pg(interp, objc, objv, page, mp, pgip, putop) +tcl_Pg(interp, objc, objv, page, mp, pgip) Tcl_Interp *interp; /* Interpreter */ int objc; /* How many arguments? */ Tcl_Obj *CONST objv[]; /* The argument objects */ void *page; /* Page pointer */ DB_MPOOLFILE *mp; /* Mpool pointer */ DBTCL_INFO *pgip; /* Info pointer */ - int putop; /* Operation */ { static const char *pgopt[] = { "-discard", @@ -842,17 +839,12 @@ tcl_Pg(interp, objc, objv, page, mp, pgip, putop) } _debug_check(); - if (putop) - ret = mp->put(mp, page, flag); - else - ret = mp->set(mp, page, flag); + ret = mp->put(mp, page, DB_PRIORITY_UNCHANGED, flag); result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), "page"); - if (putop) { - (void)Tcl_DeleteCommand(interp, pgip->i_name); - _DeleteInfo(pgip); - } + (void)Tcl_DeleteCommand(interp, pgip->i_name); + _DeleteInfo(pgip); return (result); } diff --git a/db/tcl/tcl_rep.c b/db/tcl/tcl_rep.c index 036171a0c..c94d32ac7 100644 --- a/db/tcl/tcl_rep.c +++ b/db/tcl/tcl_rep.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_rep.c,v 12.25 2006/09/07 08:06:37 alexg Exp $ + * $Id: tcl_rep.c,v 12.40 2007/06/19 19:43:45 sue Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" @@ -174,11 +173,12 @@ tcl_RepElect(interp, objc, objv, dbenv) Tcl_Obj *CONST objv[]; /* The argument objects */ DB_ENV *dbenv; /* Environment pointer */ { - int eid, nsites, nvotes, pri, result, ret; - u_int32_t timeout; + int nsites, nvotes, pri, result, ret; + u_int32_t full_timeout, timeout; - if (objc != 6) { - Tcl_WrongNumArgs(interp, 6, objv, "nsites pri timeout"); + if (objc != 6 && objc != 7) { + Tcl_WrongNumArgs(interp, 6, objv, + "nsites nvotes pri timeout [full_timeout]"); return (TCL_ERROR); } @@ -190,6 +190,10 @@ tcl_RepElect(interp, objc, objv, dbenv) return (result); if ((result = _GetUInt32(interp, objv[5], &timeout)) != TCL_OK) return (result); + full_timeout = 0; + if (objc == 7) + if ((result = _GetUInt32(interp, objv[5], &timeout)) != TCL_OK) + return (result); _debug_check(); @@ -201,13 +205,13 @@ tcl_RepElect(interp, objc, objv, dbenv) return (_ReturnSetup(interp, ret, DB_RETOK_STD(ret), "env rep_elect (rep_set_timeout)")); - if ((ret = dbenv->rep_elect(dbenv, nsites, nvotes, &eid, 0)) != 0) + if (full_timeout != 0 && (ret = dbenv->rep_set_timeout(dbenv, + DB_REP_FULL_ELECTION_TIMEOUT, full_timeout)) != 0) return (_ReturnSetup(interp, ret, DB_RETOK_STD(ret), - "env rep_elect")); - - Tcl_SetObjResult(interp, Tcl_NewIntObj(eid)); + "env rep_elect (rep_set_timeout)")); - return (TCL_OK); + ret = dbenv->rep_elect(dbenv, nsites, nvotes, 0); + return (_ReturnSetup(interp, ret, DB_RETOK_STD(ret), "env rep_elect")); } #endif @@ -265,6 +269,54 @@ tcl_RepSync(interp, objc, objv, dbenv) return (_ReturnSetup(interp, ret, DB_RETOK_STD(ret), "env rep_sync")); } #endif + +#ifdef CONFIG_TEST +/* + * tcl_RepLease -- + * Call DB_ENV->rep_set_lease(). + * + * PUBLIC: int tcl_RepLease __P((Tcl_Interp *, int, Tcl_Obj * CONST *, + * PUBLIC: DB_ENV *)); + */ +int +tcl_RepLease(interp, objc, objv, dbenv) + Tcl_Interp *interp; /* Interpreter */ + int objc; /* How many arguments? */ + Tcl_Obj *CONST objv[]; /* The argument objects */ + DB_ENV *dbenv; +{ + int result, ret; + u_int32_t nsites, skew, timeout; + + if (objc != 3) { + Tcl_WrongNumArgs(interp, 1, objv, "{nsites timeout clockskew}"); + return (TCL_ERROR); + } + + if ((result = _GetUInt32(interp, objv[0], &nsites)) != TCL_OK) + return (result); + if ((result = _GetUInt32(interp, objv[1], &timeout)) != TCL_OK) + return (result); + if ((result = _GetUInt32(interp, objv[2], &skew)) != TCL_OK) + return (result); + ret = dbenv->rep_set_nsites(dbenv, (int)nsites); + result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), + "rep_set_nsites"); + if (result != TCL_OK) + return (result); + ret = dbenv->rep_set_timeout(dbenv, DB_REP_LEASE_TIMEOUT, + (db_timeout_t)timeout); + result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), + "rep_set_timeout"); + if (result != TCL_OK) + return (result); + _debug_check(); + ret = dbenv->rep_set_lease(dbenv, skew, 0); + return (_ReturnSetup(interp, ret, DB_RETOK_STD(ret), + "env rep_set_lease")); +} +#endif + #ifdef CONFIG_TEST /* * tcl_RepLimit -- @@ -343,6 +395,35 @@ tcl_RepRequest(interp, objc, objv, dbenv) #ifdef CONFIG_TEST /* + * tcl_RepNoarchiveTimeout -- + * Reset the master update timer, to allow immediate log archiving. + * + * PUBLIC: int tcl_RepNoarchiveTimeout + * PUBLIC: __P((Tcl_Interp *, DB_ENV *)); + */ +int +tcl_RepNoarchiveTimeout(interp, dbenv) + Tcl_Interp *interp; /* Interpreter */ + DB_ENV *dbenv; /* Environment pointer */ +{ + REGENV *renv; + REGINFO *infop; + + _debug_check(); + infop = dbenv->reginfo; + renv = infop->primary; + REP_SYSTEM_LOCK(dbenv); + F_CLR(renv, DB_REGENV_REPLOCKED); + renv->op_timestamp = 0; + REP_SYSTEM_UNLOCK(dbenv); + + return (_ReturnSetup(interp, + 0, DB_RETOK_STD(0), "env test force noarchive_timeout")); +} +#endif + +#ifdef CONFIG_TEST +/* * tcl_RepTransport -- * Call DB_ENV->rep_set_transport(). * @@ -459,10 +540,10 @@ tcl_RepStart(interp, objc, objv, dbenv) i++; switch ((enum tclrpstrt)optindex) { case TCL_RPSTRT_CLIENT: - flag |= DB_REP_CLIENT; + flag = DB_REP_CLIENT; break; case TCL_RPSTRT_MASTER: - flag |= DB_REP_MASTER; + flag = DB_REP_MASTER; break; } } @@ -525,7 +606,7 @@ tcl_RepProcessMessage(interp, objc, objv, dbenv) } rec.data = rtmp; _debug_check(); - ret = dbenv->rep_process_message(dbenv, &control, &rec, &eid, &permlsn); + ret = dbenv->rep_process_message(dbenv, &control, &rec, eid, &permlsn); /* * !!! * The TCL API diverges from the C++/Java APIs here. For us, it @@ -547,7 +628,6 @@ tcl_RepProcessMessage(interp, objc, objv, dbenv) * {HOLDELECTION 0} - HOLDELECTION, no other info needed. * {NEWMASTER #} - NEWMASTER and its ID. * {NEWSITE 0} - NEWSITE, no other info needed. - * {STARTUPDONE 0} - STARTUPDONE, no other info needed. * {IGNORE {LSN list}} - IGNORE and this msg's LSN. * {ISPERM {LSN list}} - ISPERM and the perm LSN. * {NOTPERM {LSN list}} - NOTPERM and this msg's LSN. @@ -584,11 +664,6 @@ tcl_RepProcessMessage(interp, objc, objv, dbenv) (u_char *)"ISPERM", (int)strlen("ISPERM")); myobjv[1] = lsnlist; break; - case DB_REP_NEWMASTER: - myobjv[0] = Tcl_NewByteArrayObj( - (u_char *)"NEWMASTER", (int)strlen("NEWMASTER")); - myobjv[1] = Tcl_NewIntObj(eid); - break; case DB_REP_NEWSITE: myobjv[0] = Tcl_NewByteArrayObj( (u_char *)"NEWSITE", (int)strlen("NEWSITE")); @@ -673,6 +748,7 @@ tcl_RepStat(interp, objc, objv, dbenv) * list pairs and free up the memory. */ res = Tcl_NewObj(); +#ifdef HAVE_STATISTICS /* * MAKE_STAT_* assumes 'res' and 'error' label. */ @@ -726,12 +802,15 @@ tcl_RepStat(interp, objc, objv, dbenv) MAKE_STAT_LIST("Election generation number", sp->st_election_gen); MAKE_STAT_LSN("Election max LSN", &sp->st_election_lsn); MAKE_STAT_LIST("Election sites", sp->st_election_nsites); - MAKE_STAT_LIST("Election votes", sp->st_election_nvotes); + MAKE_STAT_LIST("Election nvotes", sp->st_election_nvotes); MAKE_STAT_LIST("Election priority", sp->st_election_priority); MAKE_STAT_LIST("Election tiebreaker", sp->st_election_tiebreaker); MAKE_STAT_LIST("Election votes", sp->st_election_votes); MAKE_STAT_LIST("Election seconds", sp->st_election_sec); MAKE_STAT_LIST("Election usecs", sp->st_election_usec); + MAKE_STAT_LIST("Start-sync operations delayed", + sp->st_startsync_delayed); +#endif Tcl_SetObjResult(interp, res); error: @@ -879,7 +958,8 @@ tcl_RepMgr(interp, objc, objv, dbenv) result = _GetUInt32(interp, objv[i++], &uintarg); if (result == TCL_OK) { _debug_check(); - ret = dbenv->rep_set_nsites(dbenv, uintarg); + ret = dbenv-> + rep_set_nsites(dbenv, (int)uintarg); } break; case RMGR_PRI: @@ -947,8 +1027,6 @@ tcl_RepMgr(interp, objc, objv, dbenv) start_flag = DB_REP_CLIENT; else if (strcmp(arg, "elect") == 0) start_flag = DB_REP_ELECTION; - else if (strcmp(arg, "full_elect") == 0) - start_flag = DB_REP_FULL_ELECTION; else { Tcl_AddErrorInfo( interp, "start: illegal state"); @@ -1019,4 +1097,71 @@ tcl_RepMgr(interp, objc, objv, dbenv) error: return (result); } + +/* + * tcl_RepMgrStat -- + * Call DB_ENV->repmgr_stat(). + * + * PUBLIC: int tcl_RepMgrStat + * PUBLIC: __P((Tcl_Interp *, int, Tcl_Obj * CONST *, DB_ENV *)); + */ +int +tcl_RepMgrStat(interp, objc, objv, dbenv) + Tcl_Interp *interp; /* Interpreter */ + int objc; /* How many arguments? */ + Tcl_Obj *CONST objv[]; /* The argument objects */ + DB_ENV *dbenv; +{ + DB_REPMGR_STAT *sp; + Tcl_Obj *res; + u_int32_t flag; + int result, ret; + char *arg; + + flag = 0; + result = TCL_OK; + + if (objc > 3) { + Tcl_WrongNumArgs(interp, 2, objv, NULL); + return (TCL_ERROR); + } + if (objc == 3) { + arg = Tcl_GetStringFromObj(objv[2], NULL); + if (strcmp(arg, "-clear") == 0) + flag = DB_STAT_CLEAR; + else { + Tcl_SetResult(interp, + "db stat: unknown arg", TCL_STATIC); + return (TCL_ERROR); + } + } + + _debug_check(); + ret = dbenv->repmgr_stat(dbenv, &sp, flag); + result = _ReturnSetup(interp, ret, DB_RETOK_STD(ret), + "repmgr stat"); + if (result == TCL_ERROR) + return (result); + + /* + * Have our stats, now construct the name value + * list pairs and free up the memory. + */ + res = Tcl_NewObj(); +#ifdef HAVE_STATISTICS + /* + * MAKE_STAT_* assumes 'res' and 'error' label. + */ + MAKE_STAT_LIST("Acknowledgement failures", sp->st_perm_failed); + MAKE_STAT_LIST("Messages delayed", sp->st_msgs_queued); + MAKE_STAT_LIST("Messages discarded", sp->st_msgs_dropped); + MAKE_STAT_LIST("Connections dropped", sp->st_connection_drop); + MAKE_STAT_LIST("Failed re-connects", sp->st_connect_fail); +#endif + + Tcl_SetObjResult(interp, res); +error: + __os_ufree(dbenv, sp); + return (result); +} #endif diff --git a/db/tcl/tcl_seq.c b/db/tcl/tcl_seq.c index 2fc43f7d6..a77a0d908 100644 --- a/db/tcl/tcl_seq.c +++ b/db/tcl/tcl_seq.c @@ -1,17 +1,16 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 2004-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 2004,2007 Oracle. All rights reserved. * - * $Id: tcl_seq.c,v 12.6 2006/08/24 14:46:33 bostic Exp $ + * $Id: tcl_seq.c,v 12.9 2007/05/17 15:15:54 bostic Exp $ */ #include "db_config.h" #ifdef HAVE_64BIT_TYPES #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" diff --git a/db/tcl/tcl_txn.c b/db/tcl/tcl_txn.c index a3712172f..a1d918a7c 100644 --- a/db/tcl/tcl_txn.c +++ b/db/tcl/tcl_txn.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_txn.c,v 12.16 2006/09/11 14:53:42 bostic Exp $ + * $Id: tcl_txn.c,v 12.22 2007/05/17 15:15:54 bostic Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" @@ -141,6 +140,7 @@ tcl_Txn(interp, objc, objv, envp, envip) "-read_committed", "-read_uncommitted", "-txn_timeout", + "-txn_wait", #endif "-nosync", "-nowait", @@ -156,6 +156,7 @@ tcl_Txn(interp, objc, objv, envp, envip) TXNREAD_COMMITTED, TXNREAD_UNCOMMITTED, TXNTIMEOUT, + TXNWAIT, #endif TXNNOSYNC, TXNNOWAIT, @@ -217,6 +218,9 @@ get_timeout: if (i >= objc) { case TXNREAD_UNCOMMITTED: flag |= DB_READ_UNCOMMITTED; break; + case TXNWAIT: + flag |= DB_TXN_WAIT; + break; #endif case TXNNOSYNC: flag |= DB_TXN_NOSYNC; @@ -405,6 +409,7 @@ tcl_TxnStat(interp, objc, objv, envp) /* * MAKE_STAT_LIST assumes 'res' and 'error' label. */ +#ifdef HAVE_STATISTICS MAKE_STAT_LIST("Region size", sp->st_regsize); MAKE_STAT_LSN("LSN of last checkpoint", &sp->st_last_ckp); MAKE_STAT_LIST("Time of last checkpoint", sp->st_time_ckp); @@ -435,6 +440,7 @@ tcl_TxnStat(interp, objc, objv, envp) break; } } +#endif Tcl_SetObjResult(interp, res); error: __os_ufree(envp, sp); diff --git a/db/tcl/tcl_util.c b/db/tcl/tcl_util.c index 90935f27e..14304ec9f 100644 --- a/db/tcl/tcl_util.c +++ b/db/tcl/tcl_util.c @@ -1,16 +1,15 @@ /*- * See the file LICENSE for redistribution information. * - * Copyright (c) 1999-2006 - * Oracle Corporation. All rights reserved. + * Copyright (c) 1999,2007 Oracle. All rights reserved. * - * $Id: tcl_util.c,v 12.5 2006/08/24 14:46:33 bostic Exp $ + * $Id: tcl_util.c,v 12.8 2007/05/17 15:15:54 bostic Exp $ */ #include "db_config.h" #include "db_int.h" -#ifndef NO_SYSTEM_INCLUDES +#ifdef HAVE_SYSTEM_INCLUDE_FILES #include <tcl.h> #endif #include "dbinc/tcl_db.h" |