]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-sql/modrdn.c
ITS#6001 SID of queued CSN must match the one in the op
[openldap] / servers / slapd / back-sql / modrdn.c
index 67940a58ba881d3e649c0ffc6a2ca950bc595729..fafd98ee545029d981ad7737330f340a070d0a8a 100644 (file)
@@ -1,7 +1,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 1999-2006 The OpenLDAP Foundation.
+ * Copyright 1999-2009 The OpenLDAP Foundation.
  * Portions Copyright 1999 Dmitry Kovalev.
  * Portions Copyright 2002 Pierangelo Masarati.
  * All rights reserved.
@@ -50,7 +50,6 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                                *e = NULL;
        int                     manageDSAit = get_manageDSAit( op );
        struct berval           *newSuperior = op->oq_modrdn.rs_newSup;
-       char                    *next;
  
        Debug( LDAP_DEBUG_TRACE, "==>backsql_modrdn() renaming entry \"%s\", "
                        "newrdn=\"%s\", newSuperior=\"%s\"\n",
@@ -73,7 +72,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                        LDAP_SCOPE_BASE, 
                        (time_t)(-1), NULL, dbh, op, rs,
                        slap_anlist_all_attributes,
-                       ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY ) );
+                       ( BACKSQL_ISF_MATCHED | BACKSQL_ISF_GET_ENTRY | BACKSQL_ISF_GET_OC ) );
        switch ( rs->sr_err ) {
        case LDAP_SUCCESS:
                break;
@@ -165,6 +164,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
         */
        bsi.bsi_e = &p;
        e_id = bsi.bsi_base_id;
+       memset( &bsi.bsi_base_id, 0, sizeof( bsi.bsi_base_id ) );
        rs->sr_err = backsql_init_search( &bsi, &pndn,
                        LDAP_SCOPE_BASE, 
                        (time_t)(-1), NULL, dbh, op, rs,
@@ -198,7 +198,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
        }
 
        if ( newSuperior ) {
-               (void)backsql_free_entryID( op, &bsi.bsi_base_id, 0 );
+               (void)backsql_free_entryID( &bsi.bsi_base_id, 0, op->o_tmpmemctx );
                
                /*
                 * namingContext "" is not supported
@@ -260,6 +260,8 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                new_npdn = &pndn;
        }
 
+       memset( &bsi.bsi_base_id, 0, sizeof( bsi.bsi_base_id ) );
+
        if ( newSuperior && dn_match( &pndn, new_npdn ) ) {
                Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(): "
                        "newSuperior is equal to old parent - ignored\n",
@@ -396,7 +398,8 @@ backsql_modrdn( Operation *op, SlapReply *rs )
 
        slap_mods_opattrs( op, &op->orr_modlist, 1 );
 
-       oc = backsql_id2oc( bi, e_id.eid_oc_id );
+       assert( e_id.eid_oc != NULL );
+       oc = e_id.eid_oc;
        rs->sr_err = backsql_modify_internal( op, rs, dbh, oc, &e_id, op->orr_modlist );
        slap_graduate_commit_csn( op );
        if ( rs->sr_err != LDAP_SUCCESS ) {
@@ -408,7 +411,7 @@ backsql_modrdn( Operation *op, SlapReply *rs )
                char            textbuf[ SLAP_TEXT_BUFLEN ] = { '\0' };
 
                backsql_entry_clean( op, &r );
-               (void)backsql_free_entryID( op, &e_id, 0 );
+               (void)backsql_free_entryID( &e_id, 0, op->o_tmpmemctx );
 
                bsi.bsi_e = &r;
                rs->sr_err = backsql_init_search( &bsi, &new_ndn,
@@ -452,10 +455,10 @@ backsql_modrdn( Operation *op, SlapReply *rs )
 
                e_id = bsi.bsi_base_id;
 
-               rs->sr_err = entry_schema_check( op, &r, NULL, 0,
+               rs->sr_err = entry_schema_check( op, &r, NULL, 0, 0, NULL,
                        &rs->sr_text, textbuf, sizeof( textbuf ) );
                if ( rs->sr_err != LDAP_SUCCESS ) {
-                       Debug( LDAP_DEBUG_TRACE, "   backsql_add(\"%s\"): "
+                       Debug( LDAP_DEBUG_TRACE, "   backsql_modrdn(\"%s\"): "
                                "entry failed schema check -- aborting\n",
                                r.e_name.bv_val, 0, 0 );
                        e = NULL;
@@ -511,11 +514,11 @@ done:;
        }
        
        if ( !BER_BVISNULL( &e_id.eid_ndn ) ) {
-               (void)backsql_free_entryID( op, &e_id, 0 );
+               (void)backsql_free_entryID( &e_id, 0, op->o_tmpmemctx );
        }
 
        if ( !BER_BVISNULL( &n_id.eid_ndn ) ) {
-               (void)backsql_free_entryID( op, &n_id, 0 );
+               (void)backsql_free_entryID( &n_id, 0, op->o_tmpmemctx );
        }
 
        if ( !BER_BVISNULL( &r.e_nname ) ) {