]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/entry.c
Fix rev 1.266, was creating {0}config entry prematurely.
[openldap] / servers / slapd / entry.c
index 3e868cc811ffe9a66746c3d2c9dc74cca8c478fb..b83c550defe664064e6fee2875d5d75b74ed650c 100644 (file)
@@ -277,6 +277,18 @@ str2entry2( char *s, int checkvals )
 
                if (( ad_prev && ad != ad_prev ) || ( i == lines )) {
                        int j, k;
+                       /* FIXME: we only need this when migrating from an unsorted DB */
+                       if ( atail != &ahead && atail->a_desc->ad_type->sat_flags & SLAP_AT_SORTED_VAL ) {
+                               rc = slap_sort_vals( (Modifications *)atail, &text, &j, NULL );
+                               if ( rc == LDAP_SUCCESS ) {
+                                       atail->a_flags |= SLAP_ATTR_SORTED_VALS;
+                               } else if ( rc == LDAP_TYPE_OR_VALUE_EXISTS ) {
+                                       Debug( LDAP_DEBUG_ANY,
+                                               "str2entry: attributeType %s value #%d provided more than once\n",
+                                               atail->a_desc->ad_cname.bv_val, j, 0 );
+                                       goto fail;
+                               }
+                       }
                        atail->a_next = attr_alloc( NULL );
                        atail = atail->a_next;
                        atail->a_flags = 0;
@@ -372,7 +384,7 @@ str2entry2( char *s, int checkvals )
 
                        if ( rc ) {
                                Debug( LDAP_DEBUG_ANY,
-                                       "<= str2entry NULL (smr_normalize %d)\n", rc, 0, 0 );
+                                       "<= str2entry NULL (smr_normalize %s %d)\n", ad->ad_cname.bv_val, rc, 0 );
                                goto fail;
                        }
                }
@@ -892,6 +904,19 @@ int entry_decode(EntryHeader *eh, Entry **e)
                } else {
                        a->a_nvals = a->a_vals;
                }
+               /* FIXME: This is redundant once a sorted entry is saved into the DB */
+               if ( a->a_desc->ad_type->sat_flags & SLAP_AT_SORTED_VAL ) {
+                       rc = slap_sort_vals( (Modifications *)a, &text, &j, NULL );
+                       if ( rc == LDAP_SUCCESS ) {
+                               a->a_flags |= SLAP_ATTR_SORTED_VALS;
+                       } else if ( rc == LDAP_TYPE_OR_VALUE_EXISTS ) {
+                               /* should never happen */
+                               Debug( LDAP_DEBUG_ANY,
+                                       "entry_decode: attributeType %s value #%d provided more than once\n",
+                                       a->a_desc->ad_cname.bv_val, j, 0 );
+                               return rc;
+                       }
+               }
                a = a->a_next;
                nattrs--;
                if ( !nattrs )