NeoMutt  2021-02-05-666-ge300cd
Teaching an old dog new tricks
DOXYGEN
delete_record()

Delete a record from the Store. More...

+ Collaboration diagram for delete_record():

Functions

static int store_bdb_delete_record (void *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -. More...
 
static int store_gdbm_delete_record (void *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -. More...
 
static int store_kyotocabinet_delete_record (void *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -. More...
 
static int store_lmdb_delete_record (void *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -. More...
 
static int store_qdbm_delete_record (void *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -. More...
 
static int store_rocksdb_delete_record (void *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -. More...
 
static int store_tokyocabinet_delete_record (void *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -. More...
 
static int store_tdb_delete_record (void *store, const char *key, size_t klen)
 Implements StoreOps::delete_record() -. More...
 

Detailed Description

Delete a record from the Store.

Parameters
[in]storeStore retrieved via open()
[in]keyKey identifying the record
[in]klenLength of the Key string
Return values
0Success
numError, a backend-specific error code

Function Documentation

◆ store_bdb_delete_record()

static int store_bdb_delete_record ( void *  store,
const char *  key,
size_t  klen 
)
static

Implements StoreOps::delete_record() -.

Definition at line 212 of file bdb.c.

213 {
214  if (!store)
215  return -1;
216 
217  DBT dkey;
218 
219  struct StoreDbCtx *ctx = store;
220 
221  dbt_init(&dkey, (void *) key, klen);
222  return ctx->db->del(ctx->db, NULL, &dkey, 0);
223 }
Berkeley DB context.
Definition: bdb.c:48
static void dbt_init(DBT *dbt, void *data, size_t len)
Initialise a BDB context.
Definition: bdb.c:62
DB * db
Definition: bdb.c:51
+ Here is the call graph for this function:

◆ store_gdbm_delete_record()

static int store_gdbm_delete_record ( void *  store,
const char *  key,
size_t  klen 
)
static

Implements StoreOps::delete_record() -.

Definition at line 111 of file gdbm.c.

112 {
113  if (!store)
114  return -1;
115 
116  datum dkey;
117 
118  GDBM_FILE db = store;
119 
120  dkey.dptr = (char *) key;
121  dkey.dsize = klen;
122 
123  return gdbm_delete(db, dkey);
124 }
DB * db
Definition: bdb.c:51

◆ store_kyotocabinet_delete_record()

static int store_kyotocabinet_delete_record ( void *  store,
const char *  key,
size_t  klen 
)
static

Implements StoreOps::delete_record() -.

Definition at line 113 of file kc.c.

114 {
115  if (!store)
116  return -1;
117 
118  KCDB *db = store;
119  if (!kcdbremove(db, key, klen))
120  {
121  int ecode = kcdbecode(db);
122  return ecode ? ecode : -1;
123  }
124  return 0;
125 }
DB * db
Definition: bdb.c:51

◆ store_lmdb_delete_record()

static int store_lmdb_delete_record ( void *  store,
const char *  key,
size_t  klen 
)
static

Implements StoreOps::delete_record() -.

Definition at line 261 of file lmdb.c.

262 {
263  if (!store)
264  return -1;
265 
266  MDB_val dkey;
267 
268  struct StoreLmdbCtx *ctx = store;
269 
270  dkey.mv_data = (void *) key;
271  dkey.mv_size = klen;
272  int rc = mdb_get_w_txn(ctx);
273  if (rc != MDB_SUCCESS)
274  {
275  mutt_debug(LL_DEBUG2, "mdb_get_w_txn: %s\n", mdb_strerror(rc));
276  return rc;
277  }
278  rc = mdb_del(ctx->txn, ctx->db, &dkey, NULL);
279  if ((rc != MDB_SUCCESS) && (rc != MDB_NOTFOUND))
280  {
281  mutt_debug(LL_DEBUG2, "mdb_del: %s\n", mdb_strerror(rc));
282  mdb_txn_abort(ctx->txn);
284  ctx->txn = NULL;
285  }
286 
287  return rc;
288 }
static int mdb_get_w_txn(struct StoreLmdbCtx *ctx)
Get an LMDB write transaction.
Definition: lmdb.c:97
enum MdbTxnMode txn_mode
Definition: lmdb.c:61
MDB_txn * txn
Definition: lmdb.c:59
LMDB context.
Definition: lmdb.c:56
Log at debug level 2.
Definition: logging.h:41
MDB_dbi db
Definition: lmdb.c:60
#define mutt_debug(LEVEL,...)
Definition: logging.h:85
Transaction is uninitialised.
Definition: lmdb.c:48
+ Here is the call graph for this function:

◆ store_qdbm_delete_record()

static int store_qdbm_delete_record ( void *  store,
const char *  key,
size_t  klen 
)
static

Implements StoreOps::delete_record() -.

Definition at line 93 of file qdbm.c.

94 {
95  if (!store)
96  return -1;
97 
98  VILLA *db = store;
99  /* Not sure if dbecode is reset on success, so better to explicitly return 0
100  * on success */
101  bool success = vlout(db, key, klen);
102  return success ? 0 : dpecode ? dpecode : -1;
103 }
MDB_dbi db
Definition: lmdb.c:60

◆ store_rocksdb_delete_record()

static int store_rocksdb_delete_record ( void *  store,
const char *  key,
size_t  klen 
)
static

Implements StoreOps::delete_record() -.

Definition at line 143 of file rocksdb.c.

144 {
145  if (!store)
146  return -1;
147 
148  struct RocksDbCtx *ctx = store;
149 
150  rocksdb_delete(ctx->db, ctx->write_options, key, klen, &ctx->err);
151  if (ctx->err)
152  {
153  rocksdb_free(ctx->err);
154  ctx->err = NULL;
155  return -1;
156  }
157 
158  return 0;
159 }
rocksdb_t * db
Definition: rocksdb.c:41
char * err
Definition: rocksdb.c:45
rocksdb_writeoptions_t * write_options
Definition: rocksdb.c:44
Berkeley DB context.
Definition: rocksdb.c:39

◆ store_tokyocabinet_delete_record()

static int store_tokyocabinet_delete_record ( void *  store,
const char *  key,
size_t  klen 
)
static

Implements StoreOps::delete_record() -.

Definition at line 105 of file tc.c.

106 {
107  if (!store)
108  return -1;
109 
110  TCBDB *db = store;
111  if (!tcbdbout(db, key, klen))
112  {
113  int ecode = tcbdbecode(db);
114  return ecode ? ecode : -1;
115  }
116  return 0;
117 }
rocksdb_t * db
Definition: rocksdb.c:41

◆ store_tdb_delete_record()

static int store_tdb_delete_record ( void *  store,
const char *  key,
size_t  klen 
)
static

Implements StoreOps::delete_record() -.

Definition at line 106 of file tdb.c.

107 {
108  if (!store)
109  return -1;
110 
111  TDB_CONTEXT *db = store;
112  TDB_DATA dkey;
113 
114  dkey.dptr = (unsigned char *) key;
115  dkey.dsize = klen;
116 
117  return tdb_delete(db, dkey);
118 }
rocksdb_t * db
Definition: rocksdb.c:41