summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tdb2/private.h1
-rw-r--r--lib/tdb2/tdb.c6
-rw-r--r--lib/tdb2/tdb1.h2
-rw-r--r--lib/tdb2/tdb1_tdb.c1
-rw-r--r--lib/tdb2/test/run-tdb1-3G-file.c2
-rw-r--r--lib/tdb2/test/run-tdb1-incompatible.c4
-rw-r--r--lib/tdb2/test/run-tdb1-nested-transactions.c4
-rw-r--r--lib/tdb2/test/run-tdb1-no-lock-during-traverse.c6
8 files changed, 16 insertions, 10 deletions
diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h
index 97a214f74a..851e0e3a3d 100644
--- a/lib/tdb2/private.h
+++ b/lib/tdb2/private.h
@@ -663,6 +663,7 @@ int tdb1_store(struct tdb_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag);
enum TDB_ERROR tdb1_fetch(struct tdb_context *tdb, TDB_DATA key,
TDB_DATA *data);
int tdb1_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf);
+int tdb1_delete(struct tdb_context *tdb, TDB_DATA key);
/* tdb.c: */
enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
diff --git a/lib/tdb2/tdb.c b/lib/tdb2/tdb.c
index be2ff0d676..28d0e03f7d 100644
--- a/lib/tdb2/tdb.c
+++ b/lib/tdb2/tdb.c
@@ -304,6 +304,12 @@ enum TDB_ERROR tdb_delete(struct tdb_context *tdb, struct tdb_data key)
struct hash_info h;
enum TDB_ERROR ecode;
+ if (tdb->flags & TDB_VERSION1) {
+ if (tdb1_delete(tdb, key) == -1)
+ return tdb->last_error;
+ return TDB_SUCCESS;
+ }
+
off = find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL);
if (TDB_OFF_IS_ERR(off)) {
return tdb->last_error = off;
diff --git a/lib/tdb2/tdb1.h b/lib/tdb2/tdb1.h
index 62b94da44a..77d673ae08 100644
--- a/lib/tdb2/tdb1.h
+++ b/lib/tdb2/tdb1.h
@@ -45,8 +45,6 @@ int tdb1_parse_record(struct tdb_context *tdb, TDB_DATA key,
void *private_data),
void *private_data);
-int tdb1_delete(struct tdb_context *tdb, TDB_DATA key);
-
TDB_DATA tdb1_firstkey(struct tdb_context *tdb);
TDB_DATA tdb1_nextkey(struct tdb_context *tdb, TDB_DATA key);
diff --git a/lib/tdb2/tdb1_tdb.c b/lib/tdb2/tdb1_tdb.c
index 895a8c2ae5..16e945974e 100644
--- a/lib/tdb2/tdb1_tdb.c
+++ b/lib/tdb2/tdb1_tdb.c
@@ -434,6 +434,7 @@ int tdb1_delete(struct tdb_context *tdb, TDB_DATA key)
uint32_t hash = tdb_hash(tdb, key.dptr, key.dsize);
int ret;
+ assert(tdb->flags & TDB_VERSION1);
ret = tdb1_delete_hash(tdb, key, hash);
return ret;
}
diff --git a/lib/tdb2/test/run-tdb1-3G-file.c b/lib/tdb2/test/run-tdb1-3G-file.c
index 5e0e64e815..116c655438 100644
--- a/lib/tdb2/test/run-tdb1-3G-file.c
+++ b/lib/tdb2/test/run-tdb1-3G-file.c
@@ -104,7 +104,7 @@ int main(int argc, char *argv[])
ok1(tdb1_traverse(tdb, test_traverse, &orig_data) == 1);
/* Delete should work. */
- ok1(tdb1_delete(tdb, key) == 0);
+ ok1(tdb_delete(tdb, key) == TDB_SUCCESS);
ok1(tdb1_traverse(tdb, test_traverse, NULL) == 0);
diff --git a/lib/tdb2/test/run-tdb1-incompatible.c b/lib/tdb2/test/run-tdb1-incompatible.c
index d2e07107aa..e6b2994e20 100644
--- a/lib/tdb2/test/run-tdb1-incompatible.c
+++ b/lib/tdb2/test/run-tdb1-incompatible.c
@@ -153,7 +153,7 @@ int main(int argc, char *argv[])
O_RDWR, 0600, &jhash_attr);
ok1(tdb);
ok1(log_count == 0);
- ok1(tdb1_fetch(tdb, d, &d) == TDB_SUCCESS);
+ ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
@@ -202,7 +202,7 @@ int main(int argc, char *argv[])
&dumbhash_attr);
ok1(tdb);
ok1(log_count == 0);
- ok1(tdb1_fetch(tdb, d, &d) == TDB_SUCCESS);
+ ok1(tdb_fetch(tdb, d, &d) == TDB_SUCCESS);
ok1(d.dsize == 5);
free(d.dptr);
ok1(tdb1_check(tdb, NULL, NULL) == 0);
diff --git a/lib/tdb2/test/run-tdb1-nested-transactions.c b/lib/tdb2/test/run-tdb1-nested-transactions.c
index 89e47d3fbf..645b4bc147 100644
--- a/lib/tdb2/test/run-tdb1-nested-transactions.c
+++ b/lib/tdb2/test/run-tdb1-nested-transactions.c
@@ -52,7 +52,7 @@ int main(int argc, char *argv[])
ok1(tdb1_transaction_start(tdb) == 0);
ok1(tdb1_transaction_start(tdb) == 0);
- ok1(tdb1_delete(tdb, key) == 0);
+ ok1(tdb_delete(tdb, key) == TDB_SUCCESS);
ok1(tdb1_transaction_commit(tdb) == 0);
ok1(!tdb1_exists(tdb, key));
ok1(tdb1_transaction_cancel(tdb) == 0);
@@ -61,7 +61,7 @@ int main(int argc, char *argv[])
ok1(tdb1_transaction_start(tdb) == 0);
ok1(tdb1_transaction_start(tdb) == 0);
- ok1(tdb1_delete(tdb, key) == 0);
+ ok1(tdb_delete(tdb, key) == TDB_SUCCESS);
ok1(tdb1_transaction_commit(tdb) == 0);
ok1(!tdb1_exists(tdb, key));
ok1(tdb1_transaction_commit(tdb) == 0);
diff --git a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
index 94c125dcad..383b74cb87 100644
--- a/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
+++ b/lib/tdb2/test/run-tdb1-no-lock-during-traverse.c
@@ -40,7 +40,7 @@ static void delete_entries(struct tdb_context *tdb)
key.dsize = sizeof(i);
key.dptr = (void *)&i;
- ok1(tdb1_delete(tdb, key) == 0);
+ ok1(tdb_delete(tdb, key) == TDB_SUCCESS);
}
}
@@ -52,7 +52,7 @@ static int delete_other(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
memcpy(&i, key.dptr, 4);
i = (i + 1) % NUM_ENTRIES;
key.dptr = (void *)&i;
- if (tdb1_delete(tdb, key) != 0)
+ if (tdb_delete(tdb, key) != TDB_SUCCESS)
(*(int *)private_data)++;
return 0;
}
@@ -60,7 +60,7 @@ static int delete_other(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
static int delete_self(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
void *private_data)
{
- ok1(tdb1_delete(tdb, key) == 0);
+ ok1(tdb_delete(tdb, key) == TDB_SUCCESS);
return 0;
}