ldb: Add even more comments on what strict does to the list intersections
authorAndrew Bartlett <abartlet@samba.org>
Fri, 1 Feb 2019 01:22:17 +0000 (14:22 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Fri, 1 Feb 2019 02:36:15 +0000 (03:36 +0100)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13762

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_key_value/ldb_kv_index.c

index 9a4a0db7e74f57ece4694d23401dc29a346ebb1d..6d02c91a597fc3d6e7c972a5c3005ea024c5f88f 100644 (file)
@@ -1259,6 +1259,14 @@ static bool list_intersect(struct ldb_context *ldb,
                return true;
        }
 
+       /*
+        * In both of the below we check for strict and in that
+        * case do not optimise the intersection of this list,
+        * we must never return an entry not in this
+        * list.  This allows the index for
+        * SCOPE_ONELEVEL to be trusted.
+        */
+
        /* the indexing code is allowed to return a longer list than
           what really matches, as all results are filtered by the
           full expression at the end - this shortcut avoids a lot of
@@ -1660,7 +1668,13 @@ static int ldb_kv_index_dn_one(struct ldb_module *module,
                               struct dn_list *list,
                               enum key_truncation *truncation)
 {
-       /* Ensure we do not shortcut on intersection for this list */
+       /*
+        * Ensure we do not shortcut on intersection for this list.
+        * We must never be lazy and return an entry not in this
+        * list.  This allows the index for
+        * SCOPE_ONELEVEL to be trusted.
+        */
+
        list->strict = true;
        return ldb_kv_index_dn_attr(
            module, ldb_kv, LDB_KV_IDXONE, parent_dn, list, truncation);