ldb_tdb: consistently use ltdb->cache->attribute_indexes to determine if we have...
authorAndrew Bartlett <abartlet@samba.org>
Thu, 30 Mar 2017 00:21:34 +0000 (13:21 +1300)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 31 May 2017 04:34:26 +0000 (06:34 +0200)
This is instead of checking the number of elements via ltdb->cache->indexlist->num_elements

In turn, this allows us to avoid fetching ltdb->cache->indexlist in the future

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
lib/ldb/ldb_tdb/ldb_index.c

index fc21bac90bdbd495ae88389289930ff881b799cc..46ba725c07f977c4bbdd508bce6cebb46119a065 100644 (file)
@@ -452,6 +452,10 @@ static bool ltdb_is_indexed(struct ldb_module *module,
        unsigned int i;
        struct ldb_message_element *el;
 
+       if (!ltdb->cache->attribute_indexes) {
+               return false;
+       }
+
        el = ldb_msg_find_element(ltdb->cache->indexlist, LTDB_IDXATTR);
        if (el == NULL) {
                return false;
@@ -1222,7 +1226,7 @@ static int ltdb_index_add_all(struct ldb_module *module, const char *dn,
                return LDB_SUCCESS;
        }
 
-       if (ltdb->cache->indexlist->num_elements == 0) {
+       if (!ltdb->cache->attribute_indexes) {
                /* no indexed fields */
                return LDB_SUCCESS;
        }
@@ -1640,7 +1644,7 @@ int ltdb_reindex(struct ldb_module *module)
        }
 
        /* if we don't have indexes we have nothing todo */
-       if (ltdb->cache->indexlist->num_elements == 0) {
+       if (!ltdb->cache->attribute_indexes) {
                return LDB_SUCCESS;
        }