ldb_mdb: Add some warnings about poorly constructed callbacks
[bbaumbach/samba-autobuild/.git] / lib / ldb / ldb_mdb / ldb_mdb.c
index fd13bc3dcc32166a0ed9d4ea213f680681da398f..b57998c1e31fe24e18ebb5d48ae763a54973bc89 100644 (file)
@@ -283,6 +283,16 @@ static int lmdb_traverse_fn(struct ldb_kv_private *ldb_kv,
 
                ret = fn(ldb_kv, key, data, ctx);
                if (ret != 0) {
+                       /*
+                        * NOTE: This DOES NOT set lmdb->error!
+                        *
+                        * This means that the caller will get success.
+                        * This matches TDB traverse behaviour, where callbacks
+                        * may terminate the traverse, but do not change the
+                        * return code from success.
+                        *
+                        * Callers SHOULD store their own error codes.
+                        */
                        goto done;
                }
        }
@@ -489,6 +499,16 @@ static int lmdb_iterate_range(struct ldb_kv_private *ldb_kv,
 
                ret = fn(ldb_kv, key, data, ctx);
                if (ret != 0) {
+                       /*
+                        * NOTE: This DOES NOT set lmdb->error!
+                        *
+                        * This means that the caller will get success.
+                        * This matches TDB traverse behaviour, where callbacks
+                        * may terminate the traverse, but do not change the
+                        * return code from success.
+                        *
+                        * Callers SHOULD store their own error codes.
+                        */
                        goto done;
                }
        }
@@ -512,6 +532,16 @@ static int lmdb_iterate_range(struct ldb_kv_private *ldb_kv,
 
                ret = fn(ldb_kv, key, data, ctx);
                if (ret != 0) {
+                       /*
+                        * NOTE: This DOES NOT set lmdb->error!
+                        *
+                        * This means that the caller will get success.
+                        * This matches TDB traverse behaviour, where callbacks
+                        * may terminate the traverse, but do not change the
+                        * return code from success.
+                        *
+                        * Callers SHOULD store their own error codes.
+                        */
                        goto done;
                }
        }