ldb: only used a->syntax->index_format_fn if GUID indexing is enabled
authorAaron Haslett <aaronhaslett@catalyst.net.nz>
Tue, 28 May 2019 01:00:43 +0000 (13:00 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 29 May 2019 04:41:24 +0000 (04:41 +0000)
Only enable ORDERED_INTEGER and index_format_fn functionality if GUID
indexing is enabled.  This is in line with the rest of ldb_kv which binds
the new ORDERED_INTEGER to GUID indexed databases, and allows a practical
way to create the old index format (by disabling the GUID index).

Signed-off-by: Aaron Haslett <aaronhaslett@catalyst.net.nz>
Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Garming Sam <garming@catalyst.net.nz>
Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

lib/ldb/ldb_key_value/ldb_kv_index.c

index f6b2620a87519bbdd20eed48c2269e6155e4ff5b..fff00918a126db01c8643428a24480142c08ed00 100644 (file)
@@ -924,7 +924,8 @@ static struct ldb_dn *ldb_kv_index_key(struct ldb_context *ldb,
                        v = *value;
                } else {
                        ldb_attr_handler_t fn;
-                       if (a->syntax->index_format_fn) {
+                       if (a->syntax->index_format_fn &&
+                           ldb_kv->cache->GUID_index_attribute != NULL) {
                                fn = a->syntax->index_format_fn;
                        } else {
                                fn = a->syntax->canonicalise_fn;