andykimpe / rpms / 389-ds-base

Forked from rpms/389-ds-base 5 months ago
Clone
dc8c34
From a241f5064e2a08c4248e57e0dfadbc2e997ecad5 Mon Sep 17 00:00:00 2001
dc8c34
From: Noriko Hosoi <nhosoi@redhat.com>
dc8c34
Date: Wed, 16 Apr 2014 15:04:36 -0700
dc8c34
Subject: [PATCH 203/225] Ticket #346 - Slow ldapmodify operation time for
dc8c34
 large quantities of multi-valued attribute values
dc8c34
dc8c34
Description: slapi_entry_add_value is used to add values for sorting,
dc8c34
which did not pass the attribute syntax info and the fallback compare
dc8c34
algorithm was used.  It sometimes different from the attribute syntax
dc8c34
based sorting and failed to find out an attribute.  This patch passes
dc8c34
an attribute syntax info for sorting.
dc8c34
dc8c34
Plus, featuring slapi_berval_cmp for the fallback compare algorithm.
dc8c34
It is closer to the syntax based sorting.
dc8c34
dc8c34
https://fedorahosted.org/389/ticket/346
dc8c34
dc8c34
Reviewed by rmeggins@redhat.com (Thank you, Rich!)
dc8c34
(cherry picked from commit 136fa64f95263ffcaca5e855b771b5d377e3de52)
dc8c34
(cherry picked from commit 821297df835b7d5235d66b592613c89d991d4049)
dc8c34
(cherry picked from commit e97f2b8f2a42d4ceca4020614fd7388e4e319bab)
dc8c34
(cherry picked from commit 5e45f459bbad53e63b8ff8308a934559840e23df)
dc8c34
---
dc8c34
 ldap/servers/slapd/entry.c    |  2 +-
dc8c34
 ldap/servers/slapd/valueset.c | 10 ++--------
dc8c34
 2 files changed, 3 insertions(+), 9 deletions(-)
dc8c34
dc8c34
diff --git a/ldap/servers/slapd/entry.c b/ldap/servers/slapd/entry.c
dc8c34
index d9226af..a5a21e0 100644
dc8c34
--- a/ldap/servers/slapd/entry.c
dc8c34
+++ b/ldap/servers/slapd/entry.c
dc8c34
@@ -2602,7 +2602,7 @@ slapi_entry_add_value (Slapi_Entry *e, const char *type, const Slapi_Value *valu
dc8c34
     Slapi_Attr **a= NULL;
dc8c34
     attrlist_find_or_create(&e->e_attrs, type, &a);
dc8c34
     if(value != (Slapi_Value *) NULL) {
dc8c34
-        slapi_valueset_add_value ( &(*a)->a_present_values, value);
dc8c34
+        slapi_valueset_add_attr_value_ext(*a, &(*a)->a_present_values, (Slapi_Value *)value, 0);
dc8c34
     }
dc8c34
     return 0;
dc8c34
 }
dc8c34
diff --git a/ldap/servers/slapd/valueset.c b/ldap/servers/slapd/valueset.c
dc8c34
index e83e740..960ad79 100644
dc8c34
--- a/ldap/servers/slapd/valueset.c
dc8c34
+++ b/ldap/servers/slapd/valueset.c
dc8c34
@@ -895,16 +895,10 @@ valueset_value_syntax_cmp( const Slapi_Attr *a, const Slapi_Value *v1, const Sla
dc8c34
 		    "slapi_attr_values2keys_sv failed for type %s\n",
dc8c34
 		    a->a_type, 0, 0 );
dc8c34
 	} else {
dc8c34
-		struct berval *bv1, *bv2;
dc8c34
+		const struct berval *bv1, *bv2;
dc8c34
 		bv1 = &keyvals[0]->bv;
dc8c34
 		bv2 = &keyvals[1]->bv;
dc8c34
-		if ( bv1->bv_len < bv2->bv_len ) {
dc8c34
-			rc = -1;
dc8c34
-		} else if ( bv1->bv_len > bv2->bv_len ) {
dc8c34
-			rc = 1;
dc8c34
-		} else {
dc8c34
-			rc = memcmp( bv1->bv_val, bv2->bv_val, bv1->bv_len );
dc8c34
-		}
dc8c34
+		rc = slapi_berval_cmp (bv1, bv2);
dc8c34
 	}
dc8c34
 	if (keyvals != NULL)
dc8c34
 		valuearray_free( &keyvals );
dc8c34
-- 
dc8c34
1.8.1.4
dc8c34