Blame SOURCES/0010-Ticket-47504-idlistscanlimit-per-index-type-value.patch

ba46c7
From 86cc92be7b84f4583bf9ed616848ef178f73d475 Mon Sep 17 00:00:00 2001
ba46c7
From: Rich Megginson <rmeggins@redhat.com>
ba46c7
Date: Wed, 25 Sep 2013 08:51:12 -0600
ba46c7
Subject: [PATCH 10/28] Ticket #47504 idlistscanlimit per index/type/value
ba46c7
ba46c7
https://fedorahosted.org/389/ticket/47504
ba46c7
Reviewed by: nhosoi (Thanks!)
ba46c7
Branch: rhel-7.0
ba46c7
Fix Description: This patch broke replication.  The problem is that we cannot
ba46c7
compare the allidslimit to 0 unless the value is explicitly set by
ba46c7
index_get_allids.  The fix is to only return ALLIDS if the allidslimit was
ba46c7
explicitly set to 0 by index_get_allids.
ba46c7
Platforms tested: RHEL6 x86_64
ba46c7
Flag Day: no
ba46c7
Doc impact: no
ba46c7
(cherry picked from commit 058d01d7479204a2507dab822cd81e32c37be862)
ba46c7
(cherry picked from commit e5405e627439ccaf370d90c42e65c0a987e33e73)
ba46c7
---
ba46c7
 ldap/servers/slapd/back-ldbm/index.c |   20 ++++++++++++--------
ba46c7
 1 files changed, 12 insertions(+), 8 deletions(-)
ba46c7
ba46c7
diff --git a/ldap/servers/slapd/back-ldbm/index.c b/ldap/servers/slapd/back-ldbm/index.c
ba46c7
index d5ca16a..f4de2fa 100644
ba46c7
--- a/ldap/servers/slapd/back-ldbm/index.c
ba46c7
+++ b/ldap/servers/slapd/back-ldbm/index.c
ba46c7
@@ -52,7 +52,7 @@
ba46c7
 static const char *errmsg = "database index operation failed";
ba46c7
 
ba46c7
 static int   is_indexed (const char* indextype, int indexmask, char** index_rules);
ba46c7
-static int index_get_allids( int default_allids, const char *indextype, struct attrinfo *ai, const struct berval *val, unsigned int flags );
ba46c7
+static int index_get_allids( int *allids, const char *indextype, struct attrinfo *ai, const struct berval *val, unsigned int flags );
ba46c7
 
ba46c7
 static Slapi_Value **
ba46c7
 valuearray_minus_valuearray(
ba46c7
@@ -985,8 +985,11 @@ index_read_ext_allids(
ba46c7
 		slapi_pblock_get(pb, SLAPI_SEARCH_IS_AND, &is_and);
ba46c7
 	}
ba46c7
 	ai_flags = is_and ? INDEX_ALLIDS_FLAG_AND : 0;
ba46c7
-	allidslimit = index_get_allids( allidslimit, indextype, ai, val, ai_flags );
ba46c7
-	if (allidslimit == 0) {
ba46c7
+	/* the caller can pass in a value of 0 - just ignore those - but if the index
ba46c7
+	 * config sets the allidslimit to 0, this means to skip the index
ba46c7
+	 */
ba46c7
+	if (index_get_allids( &allidslimit, indextype, ai, val, ai_flags ) &&
ba46c7
+	    (allidslimit == 0)) {
ba46c7
 		idl = idl_allids( be );
ba46c7
 		if (unindexed != NULL) *unindexed = 1;
ba46c7
 		LDAPDebug1Arg( LDAP_DEBUG_BACKLDBM, "<= index_read %lu candidates "
ba46c7
@@ -2400,9 +2403,9 @@ valuearray_minus_valuearray(
ba46c7
 #define AI_HAS_TYPE 0x02
ba46c7
 #define AI_HAS_FLAG 0x01
ba46c7
 static int
ba46c7
-index_get_allids( int default_allids, const char *indextype, struct attrinfo *ai, const struct berval *val, unsigned int flags )
ba46c7
+index_get_allids( int *allids, const char *indextype, struct attrinfo *ai, const struct berval *val, unsigned int flags )
ba46c7
 {
ba46c7
-    int allids = default_allids;
ba46c7
+    int found = 0;
ba46c7
     Slapi_Value sval;
ba46c7
     struct index_idlistsizeinfo *iter; /* iterator */
ba46c7
     int cookie = 0;
ba46c7
@@ -2410,7 +2413,7 @@ index_get_allids( int default_allids, const char *indextype, struct attrinfo *ai
ba46c7
     struct index_idlistsizeinfo *best_match = NULL;
ba46c7
 
ba46c7
     if (!ai->ai_idlistinfo) {
ba46c7
-        return allids;
ba46c7
+        return found;
ba46c7
     }
ba46c7
 
ba46c7
     if (val) { /* val should already be a Slapi_Value, but some paths do not use Slapi_Value */
ba46c7
@@ -2454,9 +2457,10 @@ index_get_allids( int default_allids, const char *indextype, struct attrinfo *ai
ba46c7
     }
ba46c7
 
ba46c7
     if (best_match) {
ba46c7
-        allids = best_match->ai_idlistsizelimit;
ba46c7
+        *allids = best_match->ai_idlistsizelimit;
ba46c7
+        found = 1; /* found a match */
ba46c7
     }
ba46c7
 
ba46c7
-    return allids;
ba46c7
+    return found;
ba46c7
 }
ba46c7
 
ba46c7
-- 
ba46c7
1.7.1
ba46c7