本文整理汇总了C++中DBC::c_del方法的典型用法代码示例。如果您正苦于以下问题:C++ DBC::c_del方法的具体用法?C++ DBC::c_del怎么用?C++ DBC::c_del使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DBC
的用法示例。
在下文中一共展示了DBC::c_del方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: userToSubname_deletecol
int userToSubname_deletecol(struct userToSubnameDbFormat *userToSubnameDb,char subname[]) {
DBC *cursorp;
DBT key, data;
int ret;
debug("userToSubname_deletecol: deleting \"%s\"", subname);
/* Get a cursor */
(*userToSubnameDb).dbp->cursor((*userToSubnameDb).dbp, NULL, &cursorp, 0);
//resetter minne
memset(&key, 0, sizeof(DBT));
memset(&data, 0, sizeof(DBT));
/* Iterate over the database, retrieving each record in turn. */
while ((ret = cursorp->c_get(cursorp, &key, &data, DB_NEXT)) == 0) {
/* Do interesting things with the DBTs here. */
if (!strcmp(subname, data.data))
{
debug("Deleting %s->%s (ret=%i)", (char*)key.data, (char*)data.data, cursorp->c_del(cursorp, 0));
}
else
{
debug("Keeping %s->%s", (char*)key.data, (char*)data.data);
}
}
/* Close the cursor */
if (cursorp != NULL) {
cursorp->c_close(cursorp);
}
return 1;
}
示例2: db_del_kv
/* Silently does nothing if the key/value isn't found.
Can't use auto-commit here! */
int db_del_kv(DB *db, DB_TXN *tid,
unsigned char *key, u_int32_t key_size,
unsigned char *value, u_int32_t value_size) {
DBT DBTKey, DBTValue;
DBC *cursor;
int ret, c_ret;
memset(&DBTKey, 0, sizeof(DBT));
DBTKey.data = key;
DBTKey.size = key_size;
memset(&DBTValue, 0, sizeof(DBT));
DBTValue.data = value;
DBTValue.size = value_size;
if ((ret = db->cursor(db, tid, &cursor, 0)) != 0)
return ret;
if ((ret = cursor->c_get(cursor, &DBTKey, &DBTValue, DB_GET_BOTH)) != 0)
goto fail;
ret = cursor->c_del(cursor, 0);
fail:
if ((c_ret = cursor->c_close(cursor)) != 0)
return c_ret;
return ret;
}
示例3: auth_db_clean
void auth_db_clean(int sig) {
DBC *dbc;
DBT key, data;
int ret;
time_t now=time(NULL);
time_t max=(time_t)conffile_param_int("timeout");
logger(LOG_NOTICE, "cleaning db file\n");
// apparently i should use DB_WRITECURSOR as a flag here
// but the version 3 db barfs on me when i do that
if((ret = db->cursor(db, NULL, &dbc, 0)) != 0) {
db->err(db, ret, "opening cursor");
exit(22);
}
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
while((ret = dbc->c_get(dbc, &key, &data, DB_NEXT)) ==0) {
time_t then = (time_t)data.data;
if(now - then > max) {
if((ret = dbc->c_del(dbc, 0)) != 0) {
db->err(db, ret, "deleting key");
exit(22);
}
}
}
logger(LOG_DEBUG,"Finished cleaning cycle\n");
}
示例4: dbiCursorDel
static int dbiCursorDel(dbiCursor dbc, DBT * key, DBT * data, unsigned int flags)
{
int rc = EINVAL;
int sane = (key->data != NULL && key->size > 0);
if (dbc && sane) {
DBC * cursor = dbc->cursor;
int _printit;
rpmdb rdb = dbc->dbi->dbi_rpmdb;
rpmswEnter(&rdb->db_delops, 0);
/* XXX TODO: insure that cursor is positioned with duplicates */
rc = cursor->c_get(cursor, key, data, DB_SET);
/* XXX DB_NOTFOUND can be returned */
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
rc = cvtdberr(dbc->dbi, "dbcursor->c_get", rc, _printit);
if (rc == 0) {
rc = cursor->c_del(cursor, flags);
rc = cvtdberr(dbc->dbi, "dbcursor->c_del", rc, _debug);
}
rpmswExit(&rdb->db_delops, data->size);
}
return rc;
}
示例5: if
static void
run_expiry()
{
DBC *dbcp;
int rc;
time_t now;
unsigned int count = 0;
/* Cursor operations can hold several locks and therefore deadlock
so don't run expiry if deadlock detection does not work
http://www.oracle.com/technology/documentation/berkeley-db/db/ref/lock/notxn.html */
if (db == 0 || deadlock_detect == 0)
return;
if (time(&now) == (time_t)-1) {
syslog(LOG_ERR, "time failed during run_expiry");
return;
}
muffle_error++;
if (rc = db->cursor(db, 0, &dbcp, 0))
log_db_error("db->cursor failed during expiry run", rc);
else {
DBT key = { 0 };
while ((rc = dbcp->c_get(dbcp, &key, &dbdata, DB_NEXT | DB_RMW)) == 0) {
time_t ref_time;
double age_max, age;
if (triplet_data.pass_count) {
ref_time = triplet_data.access_time;
age_max = pass_max_idle;
}
else {
ref_time = triplet_data.create_time;
age_max = bloc_max_idle;
}
age = difftime(now, ref_time);
if (age > age_max) {
if (opt_verbose)
syslog(LOG_INFO, "Expiring %s %s after %.0f seconds idle",
key.data,
triplet_data.pass_count ? "pass" : "block", age);
if (rc = dbcp->c_del(dbcp, 0))
log_db_error("dbcp->c_del failed", rc);
else
count++;
}
}
if (rc == DB_LOCK_DEADLOCK)
syslog(LOG_DEBUG, "skipping concurrent expiry avoids "
"deadlocks and unnecessary work");
else if (rc != DB_NOTFOUND)
log_db_error("dbcp->c_get failed", rc);
if (rc = dbcp->c_close(dbcp))
log_db_error("dbcp->c_close failed", rc);
}
muffle_error--;
if (count)
syslog(LOG_NOTICE, "Expired %u triplets", count);
}
示例6: mail_cache_db_clean_up
int mail_cache_db_clean_up(struct mail_cache_db * cache_db,
chash * exist)
{
DB * dbp;
int r;
DBC * dbcp;
DBT db_key;
DBT db_data;
dbp = cache_db->internal_database;
#if DB_VERSION_MAJOR == 2 && DB_VERSION_MINOR < 6
r = dbp->cursor(dbp, NULL, &dbcp);
#else
r = dbp->cursor(dbp, NULL, &dbcp, 0);
#endif
if (r != 0)
return -1;
memset(&db_key, 0, sizeof(db_key));
memset(&db_data, 0, sizeof(db_data));
while (1) {
chashdatum hash_key;
chashdatum hash_data;
r = dbcp->c_get(dbcp, &db_key, &db_data, DB_NEXT);
if (r != 0)
break;
hash_key.data = db_key.data;
hash_key.len = db_key.size;
r = chash_get(exist, &hash_key, &hash_data);
if (r < 0) {
r = dbcp->c_del(dbcp, 0);
if (r != 0)
return -1;
}
}
r = dbcp->c_close(dbcp);
if (r != 0)
return -1;
return 0;
}
示例7: del
int Dbc::del(u_int32_t flags_arg)
{
DBC *cursor = this;
int err;
if ((err = cursor->c_del(cursor, flags_arg)) != 0) {
// DB_KEYEMPTY is a "normal" return, so should not be
// thrown as an error
//
if (err != DB_KEYEMPTY) {
DB_ERROR("Db::del", err);
return err;
}
}
return 0;
}
示例8: walk_db
local void walk_db(int (*func)(DBT *key, DBT *val), int write)
{
DBC *cursor;
DBT key, val;
if (db->cursor(db, NULL, &cursor, write ? DB_WRITECURSOR : 0))
{
if (write)
fputs("couldn't get db cursor for writing. is the db read-only?\n", stderr);
else
fputs("couldn't get db cursor.\n", stderr);
return;
}
memset(&key, 0, sizeof(key));
memset(&val, 0, sizeof(val));
while (cursor->c_get(cursor, &key, &val, DB_NEXT) == 0)
if (func(&key, &val))
cursor->c_del(cursor, 0);
cursor->c_close(cursor);
}
示例9: if
static VALUE
bdb_intern_shift_pop(VALUE obj, int depart, int len)
{
bdb_DB *dbst;
DB_TXN *txnid;
DBC *dbcp;
DBT key, data;
int i, ret, flags;
db_recno_t recno;
VALUE res;
rb_secure(4);
INIT_TXN(txnid, obj, dbst);
#if HAVE_DB_CURSOR_4
bdb_test_error(dbst->dbp->cursor(dbst->dbp, txnid, &dbcp, 0));
#else
bdb_test_error(dbst->dbp->cursor(dbst->dbp, txnid, &dbcp));
#endif
SET_PARTIAL(dbst, data);
flags = TEST_INIT_LOCK(dbst);
res = rb_ary_new2(len);
for (i = 0; i < len; i++) {
MEMZERO(&key, DBT, 1);
INIT_RECNO(dbst, key, recno);
MEMZERO(&data, DBT, 1);
data.flags = DB_DBT_MALLOC;
bdb_cache_error(dbcp->c_get(dbcp, &key, &data, depart | flags),
dbcp->c_close(dbcp), ret);
if (ret == DB_NOTFOUND) break;
rb_ary_push(res, bdb_test_load(obj, &data, FILTER_VALUE));
bdb_cache_error(dbcp->c_del(dbcp, 0), dbcp->c_close(dbcp), ret);
if (dbst->len > 0) dbst->len--;
}
dbcp->c_close(dbcp);
if (RARRAY_LEN(res) == 0) return Qnil;
else if (RARRAY_LEN(res) == 1) return RARRAY_PTR(res)[0];
else return res;
}
示例10: _bdb_delete_cursor
//.........这里部分代码省略.........
s.s = (char*)CON_TABLE(_h);
s.len = strlen(CON_TABLE(_h));
_tbc = bdblib_get_table(BDB_CON_CONNECTION(_h), &s);
if(!_tbc)
{ LM_WARN("table does not exist!\n");
return -3;
}
_tp = _tbc->dtp;
if(!_tp)
{ LM_WARN("table not loaded!\n");
return -4;
}
#ifdef BDB_EXTRA_DEBUG
LM_DBG("DELETE by cursor in %.*s\n", _tp->name.len, _tp->name.s );
#endif
if(_k)
{ lkey = bdb_get_colmap(_tp, _k, _n);
if(!lkey)
{ ret = -1;
goto error;
}
}
/* create an empty db_res_t which gets returned even if no result */
_r = db_new_result();
if (!_r)
{ LM_ERR("no memory for result \n");
}
RES_ROW_N(_r) = 0;
/* fill in the col part of db_res_t */
if ((ret = bdb_get_columns(_tp, _r, 0, 0)) != 0)
{ LM_ERR("Error while getting column names\n");
goto error;
}
db = _tp->db;
memset(&key, 0, sizeof(DBT));
memset(kbuf, 0, klen);
memset(&data, 0, sizeof(DBT));
memset(dbuf, 0, MAX_ROW_SIZE);
data.data = dbuf;
data.ulen = MAX_ROW_SIZE;
data.flags = DB_DBT_USERMEM;
/* Acquire a cursor for the database. */
if ((ret = db->cursor(db, NULL, &dbcp, DB_WRITECURSOR)) != 0)
{ LM_ERR("Error creating cursor\n");
}
while ((ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT)) == 0)
{
if(!strncasecmp((char*)key.data,"METADATA",8))
continue;
/*fill in the row part of db_res_t */
if ((ret=bdb_convert_row( _r, dbuf, 0)) < 0)
{ LM_ERR("Error while converting row\n");
goto error;
}
if(bdb_row_match(_k, _op, _v, _n, _r, lkey ))
{
#ifdef BDB_EXTRA_DEBUG
LM_DBG("DELETE ROW by KEY: [%.*s]\n", (int) key.size,
(char *)key.data);
#endif
if((ret = dbcp->c_del(dbcp, 0)) != 0)
{
/* Berkeley DB error handler */
LM_CRIT("DB->get error: %s.\n", db_strerror(ret));
bdblib_recover(_tp,ret);
}
}
memset(dbuf, 0, MAX_ROW_SIZE);
bdb_free_rows( _r);
}
ret = 0;
error:
if(dbcp)
dbcp->c_close(dbcp);
if(_r)
bdb_free_result(_r);
if(lkey)
pkg_free(lkey);
return ret;
}
示例11: bdb_delete
/*
* Delete a row from table
*
* To delete ALL rows:
* do Not specify any keys, or values, and _n <=0
*
*/
int bdb_delete(db_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v, int _n)
{
tbl_cache_p _tbc = NULL;
table_p _tp = NULL;
char kbuf[MAX_ROW_SIZE];
int i, j, ret, klen;
int *lkey=NULL;
DBT key;
DB *db;
DBC *dbcp;
str s;
i = j = ret = 0;
klen=MAX_ROW_SIZE;
if (_op)
return ( _bdb_delete_cursor(_h, _k, _op, _v, _n) );
if ((!_h) || !CON_TABLE(_h))
return -1;
s.s = (char*)CON_TABLE(_h);
s.len = strlen(CON_TABLE(_h));
_tbc = bdblib_get_table(BDB_CON_CONNECTION(_h), &s);
if(!_tbc)
{ LM_WARN("table does not exist!\n");
return -3;
}
_tp = _tbc->dtp;
if(!_tp)
{ LM_WARN("table not loaded!\n");
return -4;
}
#ifdef BDB_EXTRA_DEBUG
LM_DBG("DELETE in %.*s\n", _tp->name.len, _tp->name.s );
#endif
db = _tp->db;
memset(&key, 0, sizeof(DBT));
memset(kbuf, 0, klen);
if(!_k || !_v || _n<=0)
{
/* Acquire a cursor for the database. */
if ((ret = db->cursor(db, NULL, &dbcp, DB_WRITECURSOR) ) != 0)
{ LM_ERR("Error creating cursor\n");
goto error;
}
while ((ret = dbcp->c_get(dbcp, &key, NULL, DB_NEXT)) == 0)
{
if(!strncasecmp((char*)key.data,"METADATA",8))
continue;
#ifdef BDB_EXTRA_DEBUG
LM_DBG("KEY: [%.*s]\n"
, (int) key.size
, (char *)key.data);
#endif
ret = dbcp->c_del(dbcp, 0);
}
dbcp->c_close(dbcp);
return 0;
}
lkey = bdb_get_colmap(_tp, _k, _n);
if(!lkey) return -5;
/* make the key */
if ( (ret = bdblib_valtochar(_tp, lkey, kbuf, &klen, _v, _n, BDB_KEY)) != 0 )
{ LM_ERR("Error in bdblib_makekey\n");
ret = -6;
goto error;
}
key.data = kbuf;
key.ulen = MAX_ROW_SIZE;
key.flags = DB_DBT_USERMEM;
key.size = klen;
if ((ret = db->del(db, NULL, &key, 0)) == 0)
{
bdblib_log(JLOG_DELETE, _tp, kbuf, klen);
#ifdef BDB_EXTRA_DEBUG
LM_DBG("DELETED ROW \n KEY: %s \n", (char *)key.data);
#endif
}
else
{ /*Berkeley DB error handler*/
//.........这里部分代码省略.........
示例12: sizeof
static int
bdb_tool_idl_flush_one( void *v1, void *arg )
{
bdb_tool_idl_cache *ic = v1;
DB *db = arg;
struct bdb_info *bdb = bdb_tool_info;
bdb_tool_idl_cache_entry *ice;
DBC *curs;
DBT key, data;
int i, rc;
ID id, nid;
/* Freshly allocated, ignore it */
if ( !ic->head && ic->count <= BDB_IDL_DB_SIZE ) {
return 0;
}
rc = db->cursor( db, NULL, &curs, 0 );
if ( rc )
return -1;
DBTzero( &key );
DBTzero( &data );
bv2DBT( &ic->kstr, &key );
data.size = data.ulen = sizeof( ID );
data.flags = DB_DBT_USERMEM;
data.data = &nid;
rc = curs->c_get( curs, &key, &data, DB_SET );
/* If key already exists and we're writing a range... */
if ( rc == 0 && ic->count > BDB_IDL_DB_SIZE ) {
/* If it's not currently a range, must delete old info */
if ( nid ) {
/* Skip lo */
while ( curs->c_get( curs, &key, &data, DB_NEXT_DUP ) == 0 )
curs->c_del( curs, 0 );
nid = 0;
/* Store range marker */
curs->c_put( curs, &key, &data, DB_KEYFIRST );
} else {
/* Skip lo */
rc = curs->c_get( curs, &key, &data, DB_NEXT_DUP );
/* Get hi */
rc = curs->c_get( curs, &key, &data, DB_NEXT_DUP );
/* Delete hi */
curs->c_del( curs, 0 );
}
BDB_ID2DISK( ic->last, &nid );
curs->c_put( curs, &key, &data, DB_KEYLAST );
rc = 0;
} else if ( rc && rc != DB_NOTFOUND ) {
rc = -1;
} else if ( ic->count > BDB_IDL_DB_SIZE ) {
/* range, didn't exist before */
nid = 0;
rc = curs->c_put( curs, &key, &data, DB_KEYLAST );
if ( rc == 0 ) {
BDB_ID2DISK( ic->first, &nid );
rc = curs->c_put( curs, &key, &data, DB_KEYLAST );
if ( rc == 0 ) {
BDB_ID2DISK( ic->last, &nid );
rc = curs->c_put( curs, &key, &data, DB_KEYLAST );
}
}
if ( rc ) {
rc = -1;
}
} else {
int n;
/* Just a normal write */
rc = 0;
for ( ice = ic->head, n=0; ice; ice = ice->next, n++ ) {
int end;
if ( ice->next ) {
end = IDBLOCK;
} else {
end = ic->count & (IDBLOCK-1);
if ( !end )
end = IDBLOCK;
}
for ( i=0; i<end; i++ ) {
if ( !ice->ids[i] ) continue;
BDB_ID2DISK( ice->ids[i], &nid );
rc = curs->c_put( curs, &key, &data, DB_NODUPDATA );
if ( rc ) {
if ( rc == DB_KEYEXIST ) {
rc = 0;
continue;
}
rc = -1;
break;
}
}
//.........这里部分代码省略.........
示例13: assert
static void
run_expiry()
{
DB_ENV *dbenv;
DB *db;
DB_TXN *txn;
DBC *dbcp;
int rc;
time_t now;
DBT key = { 0 };
unsigned int count = 0;
if (exit_requested)
return;
/* Cursor operations can hold several locks and therefore deadlock
so don't run expiry if deadlock detection does not work
http://docs.oracle.com/cd/E17076_02/html/programmer_reference/lock_notxn.html */
rc = get_db(&db, 0);
assert(! rc);
if (db == 0 || deadlock_detect == 0)
return;
rc = get_dbenv(&dbenv, 0);
assert(! rc && dbenv);
if (time(&now) == (time_t)-1) {
syslog(LOG_ERR, "time failed during run_expiry");
return;
}
muffle_error++;
rc = dbenv->txn_begin(dbenv, NULL, &txn, DB_TXN_NOWAIT);
if (rc) {
if (rc == DB_LOCK_DEADLOCK)
syslog(LOG_DEBUG, "skipping concurrent expiry avoids "
"deadlocks and unnecessary work");
else
log_db_error("txn_begin failed during run_expiry", rc);
goto out;
}
#if DB_VERSION_MAJOR >= 5
call_db(txn->set_priority(txn, 50), "TXN->set_priority");
#endif
rc = call_db(db->cursor(db, txn, &dbcp, 0),
"db->cursor failed during expiry run");
if (rc)
goto txn_fail;
while ((rc = dbcp->c_get(dbcp, &key, &dbdata, DB_NEXT | DB_RMW)) == 0) {
time_t ref_time;
double age_max, age;
if (triplet_data.pass_count) {
ref_time = triplet_data.access_time;
age_max = pass_max_idle;
}
else {
ref_time = triplet_data.create_time;
age_max = bloc_max_idle;
}
age = difftime(now, ref_time);
if (age > age_max) {
if (opt_verbose) {
syslog(LOG_INFO, "Expiring %s %s after %.0f seconds idle",
db_key_ntop(key.data),
triplet_data.pass_count ? "pass" : "block", age);
}
rc = call_db(dbcp->c_del(dbcp, 0), "dbcp->c_del failed");
if (rc)
goto cursor_fail;
count++;
}
if (exit_requested)
break;
}
if (rc && rc != DB_NOTFOUND) {
if (rc == DB_LOCK_DEADLOCK)
syslog(LOG_NOTICE, "Aborting concurrent expiry due to deadlock");
else
log_db_error("dbcp->c_get failed", rc);
goto cursor_fail;
}
if (call_db(dbcp->c_close(dbcp), "dbcp->c_close failed"))
goto txn_fail;
call_db(txn->commit(txn, 0), "commit failed in run_expiry");
if (count)
syslog(LOG_NOTICE, "Expired %u triplets", count);
goto out;
cursor_fail:
call_db(dbcp->c_close(dbcp), "dbcp->c_close failed");
txn_fail:
call_db(txn->abort(txn), "failed to abort");
out:
muffle_error--;
return;
}
示例14: icalbdbset_commit
icalerrorenum icalbdbset_commit(icalset *set)
{
DB *dbp;
DBC *dbcp;
DBT key, data;
icalcomponent *c;
char *str = NULL;
int ret = 0;
int reterr = ICAL_NO_ERROR;
char keystore[256];
char uidbuf[256];
char datastore[1024];
char *more_mem = NULL;
DB_TXN *tid = NULL;
icalbdbset *bset = (icalbdbset *) set;
int bad_uid_counter = 0;
int retry = 0, done = 0, completed = 0, deadlocked = 0;
icalerror_check_arg_re((bset != 0), "bset", ICAL_BADARG_ERROR);
dbp = bset->dbp;
icalerror_check_arg_re((dbp != 0), "dbp is invalid", ICAL_BADARG_ERROR);
if (bset->changed == 0) {
return ICAL_NO_ERROR;
}
memset(&key, 0, sizeof(key));
memset(&data, 0, sizeof(data));
key.flags = DB_DBT_USERMEM;
key.data = keystore;
key.ulen = (u_int32_t) sizeof(keystore);
data.flags = DB_DBT_USERMEM;
data.data = datastore;
data.ulen = (u_int32_t) sizeof(datastore);
if (!ICAL_DB_ENV) {
if (icalbdbset_init_dbenv(NULL, NULL) != 0) {
return ICAL_INTERNAL_ERROR;
}
}
while ((retry < MAX_RETRY) && !done) {
if ((ret = ICAL_DB_ENV->txn_begin(ICAL_DB_ENV, NULL, &tid, 0)) != 0) {
if (ret == DB_LOCK_DEADLOCK) {
retry++;
continue;
} else if (ret == DB_RUNRECOVERY) {
ICAL_DB_ENV->err(ICAL_DB_ENV, ret, "icalbdbset_commit: txn_begin failed");
abort();
} else {
ICAL_DB_ENV->err(ICAL_DB_ENV, ret, "icalbdbset_commit");
return ICAL_INTERNAL_ERROR;
}
}
/* first delete everything in the database, because there could be removed components */
if ((ret = dbp->cursor(dbp, tid, &dbcp, DB_DIRTY_READ)) != 0) {
tid->abort(tid);
if (ret == DB_LOCK_DEADLOCK) {
retry++;
continue;
} else if (ret == DB_RUNRECOVERY) {
ICAL_DB_ENV->err(ICAL_DB_ENV, ret, "curor failed");
abort();
} else {
ICAL_DB_ENV->err(ICAL_DB_ENV, ret, "curor failed");
/* leave bset->changed set to true */
return ICAL_INTERNAL_ERROR;
}
}
/* fetch the key/data pair, then delete it */
completed = 0;
while (!completed && !deadlocked) {
ret = dbcp->c_get(dbcp, &key, &data, DB_NEXT);
if (ret == DB_NOTFOUND) {
completed = 1;
} else if (ret == ENOMEM) {
if (more_mem) {
free(more_mem);
}
more_mem = malloc(data.ulen + 1024);
data.data = more_mem;
data.ulen = data.ulen + 1024;
} else if (ret == DB_LOCK_DEADLOCK) {
deadlocked = 1;
} else if (ret == DB_RUNRECOVERY) {
tid->abort(tid);
ICAL_DB_ENV->err(ICAL_DB_ENV, ret, "c_get failed.");
abort();
} else if (ret == 0) {
if ((ret = dbcp->c_del(dbcp, 0)) != 0) {
dbp->err(dbp, ret, "cursor");
if (ret == DB_KEYEMPTY) {
/* never actually created, continue onward.. */
/* do nothing - break; */
//.........这里部分代码省略.........
示例15: sizeof
//.........这里部分代码省略.........
if ( rc == DB_NOTFOUND ) {
rc = cursor->c_get( cursor, key, &data, DB_LAST );
if ( rc != 0 ) {
err = "c_get last";
goto fail;
}
} else {
rc = cursor->c_get( cursor, key, &data, DB_PREV );
if ( rc != 0 ) {
err = "c_get prev";
goto fail;
}
}
BDB_DISK2ID( &nhi, &hi );
/* Update hi/lo if needed, then delete all the items
* between lo and hi
*/
if ( id < lo ) {
lo = id;
nlo = nid;
} else if ( id > hi ) {
hi = id;
nhi = nid;
}
data.data = &nid;
/* Don't fetch anything, just position cursor */
data.flags = DB_DBT_USERMEM | DB_DBT_PARTIAL;
data.dlen = data.ulen = 0;
rc = cursor->c_get( cursor, key, &data, DB_SET );
if ( rc != 0 ) {
err = "c_get 2";
goto fail;
}
rc = cursor->c_del( cursor, 0 );
if ( rc != 0 ) {
err = "c_del range1";
goto fail;
}
/* Delete all the records */
for ( i=1; i<count; i++ ) {
rc = cursor->c_get( cursor, &key2, &data, DB_NEXT_DUP );
if ( rc != 0 ) {
err = "c_get next_dup";
goto fail;
}
rc = cursor->c_del( cursor, 0 );
if ( rc != 0 ) {
err = "c_del range";
goto fail;
}
}
/* Store the range marker */
data.size = data.ulen = sizeof(ID);
data.flags = DB_DBT_USERMEM;
nid = 0;
rc = cursor->c_put( cursor, key, &data, DB_KEYFIRST );
if ( rc != 0 ) {
err = "c_put range";
goto fail;
}
nid = nlo;
rc = cursor->c_put( cursor, key, &data, DB_KEYLAST );
if ( rc != 0 ) {
err = "c_put lo";
goto fail;
}