mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-02-05 13:40:08 +08:00
Fix multivalued indices. Need to add indices of remaining
values after delete of any value.
This commit is contained in:
parent
404ca4a985
commit
d1803fce0a
@ -77,57 +77,6 @@ index_add_entry(
|
|||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
index_add_mods(
|
|
||||||
Backend *be,
|
|
||||||
Modifications *ml,
|
|
||||||
ID id
|
|
||||||
)
|
|
||||||
{
|
|
||||||
int rc;
|
|
||||||
|
|
||||||
for ( ; ml != NULL; ml = ml->sml_next ) {
|
|
||||||
Modification *mod = &ml->sml_mod;
|
|
||||||
|
|
||||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
|
||||||
/* not yet implemented */
|
|
||||||
rc = -1;
|
|
||||||
#else
|
|
||||||
switch ( mod->mod_op ) {
|
|
||||||
case LDAP_MOD_REPLACE:
|
|
||||||
/* XXX: Delete old index data==>problem when this
|
|
||||||
* gets called we lost values already!
|
|
||||||
*/
|
|
||||||
case LDAP_MOD_ADD:
|
|
||||||
rc = index_change_values( be,
|
|
||||||
mod->mod_type,
|
|
||||||
mod->mod_bvalues,
|
|
||||||
id,
|
|
||||||
SLAP_INDEX_ADD_OP );
|
|
||||||
break;
|
|
||||||
case LDAP_MOD_DELETE:
|
|
||||||
rc = index_change_values( be,
|
|
||||||
mod->mod_type,
|
|
||||||
mod->mod_bvalues,
|
|
||||||
id,
|
|
||||||
SLAP_INDEX_DELETE_OP );
|
|
||||||
break;
|
|
||||||
case SLAP_MOD_SOFTADD: /* SOFTADD means index was there */
|
|
||||||
rc = 0;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
rc = -1;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if ( rc != 0 ) {
|
|
||||||
return( rc );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return( 0 );
|
|
||||||
}
|
|
||||||
|
|
||||||
ID_BLOCK *
|
ID_BLOCK *
|
||||||
index_read(
|
index_read(
|
||||||
|
@ -127,39 +127,89 @@ int ldbm_modify_internal(
|
|||||||
}
|
}
|
||||||
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
|
ldap_pvt_thread_mutex_unlock( &op->o_abandonmutex );
|
||||||
|
|
||||||
/* remove old indices */
|
/* run through the attributes removing old indices */
|
||||||
if( save_attrs != NULL ) {
|
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
|
||||||
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
|
mod = &ml->sml_mod;
|
||||||
mod = &ml->sml_mod;
|
|
||||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
|
||||||
if ( mod->sm_op == LDAP_MOD_REPLACE )
|
|
||||||
#else
|
|
||||||
if ( mod->mod_op == LDAP_MOD_REPLACE )
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
|
||||||
/* not yet implemented */
|
|
||||||
#else
|
|
||||||
/* Need to remove all values from indexes */
|
|
||||||
Attribute *a = attr_find( save_attrs, mod->mod_type );
|
|
||||||
|
|
||||||
if( a != NULL ) {
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
(void) index_change_values( be,
|
switch ( mod->sm_op )
|
||||||
mod->mod_type,
|
#else
|
||||||
a->a_vals,
|
switch ( mod->mod_op )
|
||||||
e->e_id,
|
|
||||||
SLAP_INDEX_DELETE_OP);
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
{
|
||||||
|
case LDAP_MOD_REPLACE: {
|
||||||
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
|
/* not yet implemented */
|
||||||
|
#else
|
||||||
|
/* Need to remove all values from indexes */
|
||||||
|
Attribute *a = save_attrs
|
||||||
|
? attr_find( save_attrs, mod->mod_type )
|
||||||
|
: NULL;
|
||||||
|
|
||||||
|
if( a != NULL ) {
|
||||||
|
(void) index_change_values( be,
|
||||||
|
mod->mod_type,
|
||||||
|
a->a_vals,
|
||||||
|
e->e_id,
|
||||||
|
SLAP_INDEX_DELETE_OP );
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case LDAP_MOD_DELETE:
|
||||||
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
|
/* not yet implemented */
|
||||||
|
#else
|
||||||
|
/* remove deleted values */
|
||||||
|
(void) index_change_values( be,
|
||||||
|
mod->mod_type,
|
||||||
|
mod->mod_bvalues,
|
||||||
|
e->e_id,
|
||||||
|
SLAP_INDEX_DELETE_OP );
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
attrs_free( save_attrs );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* modify indexes */
|
attrs_free( save_attrs );
|
||||||
if ( index_add_mods( be, modlist, e->e_id ) != 0 ) {
|
|
||||||
/* our indices are likely hosed */
|
/* run through the attributes adding new indices */
|
||||||
return LDAP_OTHER;
|
for ( ml = modlist; ml != NULL; ml = ml->sml_next ) {
|
||||||
|
mod = &ml->sml_mod;
|
||||||
|
|
||||||
|
switch ( mod->mod_op ) {
|
||||||
|
case LDAP_MOD_REPLACE:
|
||||||
|
case LDAP_MOD_ADD:
|
||||||
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
|
/* not yet implemented */
|
||||||
|
#else
|
||||||
|
(void) index_change_values( be,
|
||||||
|
mod->mod_type,
|
||||||
|
mod->mod_bvalues,
|
||||||
|
e->e_id,
|
||||||
|
SLAP_INDEX_ADD_OP );
|
||||||
|
#endif
|
||||||
|
break;
|
||||||
|
|
||||||
|
case LDAP_MOD_DELETE: {
|
||||||
|
#ifdef SLAPD_SCHEMA_NOT_COMPAT
|
||||||
|
/* not yet implemented */
|
||||||
|
#else
|
||||||
|
/* Need to add all remaining values */
|
||||||
|
Attribute *a = e->e_attrs
|
||||||
|
? attr_find( e->e_attrs, mod->mod_type )
|
||||||
|
: NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if( a != NULL ) {
|
||||||
|
(void) index_change_values( be,
|
||||||
|
mod->mod_type,
|
||||||
|
a->a_vals,
|
||||||
|
e->e_id,
|
||||||
|
SLAP_INDEX_ADD_OP );
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return LDAP_SUCCESS;
|
return LDAP_SUCCESS;
|
||||||
|
@ -132,7 +132,6 @@ ID idl_nextid LDAP_P(( ID_BLOCK *idl, ID *cursor ));
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
int index_add_entry LDAP_P(( Backend *be, Entry *e ));
|
int index_add_entry LDAP_P(( Backend *be, Entry *e ));
|
||||||
int index_add_mods LDAP_P(( Backend *be, Modifications *ml, ID id ));
|
|
||||||
ID_BLOCK * index_read LDAP_P(( Backend *be,
|
ID_BLOCK * index_read LDAP_P(( Backend *be,
|
||||||
char *type, int indextype, char *val ));
|
char *type, int indextype, char *val ));
|
||||||
/* Possible operations supported (op) by index_change_values() */
|
/* Possible operations supported (op) by index_change_values() */
|
||||||
|
Loading…
Reference in New Issue
Block a user