summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tdb2/private.h4
-rw-r--r--lib/tdb2/tdb1.h4
-rw-r--r--lib/tdb2/traverse.c22
3 files changed, 26 insertions, 4 deletions
diff --git a/lib/tdb2/private.h b/lib/tdb2/private.h
index 816d5f70f8..50c48fa9a5 100644
--- a/lib/tdb2/private.h
+++ b/lib/tdb2/private.h
@@ -697,6 +697,10 @@ int tdb1_transaction_start(struct tdb_context *tdb);
int tdb1_transaction_prepare_commit(struct tdb_context *tdb);
int tdb1_transaction_commit(struct tdb_context *tdb);
+/* tdb1_traverse.c: */
+TDB_DATA tdb1_firstkey(struct tdb_context *tdb);
+TDB_DATA tdb1_nextkey(struct tdb_context *tdb, TDB_DATA key);
+
/* tdb.c: */
enum TDB_ERROR COLD tdb_logerr(struct tdb_context *tdb,
enum TDB_ERROR ecode,
diff --git a/lib/tdb2/tdb1.h b/lib/tdb2/tdb1.h
index 2855d0c1b0..59c2dd0d1d 100644
--- a/lib/tdb2/tdb1.h
+++ b/lib/tdb2/tdb1.h
@@ -38,10 +38,6 @@
void tdb1_set_max_dead(struct tdb_context *tdb, int max_dead);
-TDB_DATA tdb1_firstkey(struct tdb_context *tdb);
-
-TDB_DATA tdb1_nextkey(struct tdb_context *tdb, TDB_DATA key);
-
int tdb1_get_seqnum(struct tdb_context *tdb);
void tdb1_increment_seqnum_nonblock(struct tdb_context *tdb);
diff --git a/lib/tdb2/traverse.c b/lib/tdb2/traverse.c
index a065ad0042..b27550032f 100644
--- a/lib/tdb2/traverse.c
+++ b/lib/tdb2/traverse.c
@@ -61,6 +61,16 @@ enum TDB_ERROR tdb_firstkey(struct tdb_context *tdb, struct tdb_data *key)
{
struct traverse_info tinfo;
+ if (tdb->flags & TDB_VERSION1) {
+ tdb->last_error = TDB_SUCCESS;
+ *key = tdb1_firstkey(tdb);
+ /* TDB1 didn't set error for last key. */
+ if (!key->dptr && tdb->last_error == TDB_SUCCESS) {
+ tdb->last_error = TDB_ERR_NOEXIST;
+ }
+ return tdb->last_error;
+ }
+
return tdb->last_error = first_in_hash(tdb, &tinfo, key, NULL);
}
@@ -71,6 +81,18 @@ enum TDB_ERROR tdb_nextkey(struct tdb_context *tdb, struct tdb_data *key)
struct hash_info h;
struct tdb_used_record rec;
+ if (tdb->flags & TDB_VERSION1) {
+ struct tdb_data last_key = *key;
+ tdb->last_error = TDB_SUCCESS;
+ *key = tdb1_nextkey(tdb, last_key);
+ free(last_key.dptr);
+ /* TDB1 didn't set error for last key. */
+ if (!key->dptr && tdb->last_error == TDB_SUCCESS) {
+ tdb->last_error = TDB_ERR_NOEXIST;
+ }
+ return tdb->last_error;
+ }
+
tinfo.prev = find_and_lock(tdb, *key, F_RDLCK, &h, &rec, &tinfo);
free(key->dptr);
if (TDB_OFF_IS_ERR(tinfo.prev)) {