summaryrefslogtreecommitdiff
path: root/lib/tdb2/traverse.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tdb2/traverse.c')
-rw-r--r--lib/tdb2/traverse.c22
1 files changed, 22 insertions, 0 deletions
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)) {