]> git.sur5r.net Git - openldap/commitdiff
ITS#5319 allow rename to same DN
authorHoward Chu <hyc@openldap.org>
Fri, 11 Jan 2008 03:17:10 +0000 (03:17 +0000)
committerHoward Chu <hyc@openldap.org>
Fri, 11 Jan 2008 03:17:10 +0000 (03:17 +0000)
servers/slapd/back-bdb/modrdn.c

index 965b1e46e7be214c7218bec364e39c186afd86fc..4de5984383ab763f62ee118612cdd79a05ab1cd1 100644 (file)
@@ -559,6 +559,9 @@ retry:      /* transaction retry */
        case DB_NOTFOUND:
                break;
        case 0:
+               /* Allow rename to same DN */
+               if ( nei == ei )
+                       break;
                rs->sr_err = LDAP_ALREADY_EXISTS;
                goto return_results;
        default:
@@ -588,6 +591,27 @@ retry:     /* transaction retry */
                }                   
        }
 
+       /* Rename to exactly the same name, noop */
+       if ( nei == ei && bvmatch( &e->e_name, &new_dn )) {
+               rs->sr_err = LDAP_SUCCESS;
+               if ( op->o_postread ) {
+                       if( postread_ctrl == NULL ) {
+                               postread_ctrl = &ctrls[num_ctrls++];
+                               ctrls[num_ctrls] = NULL;
+                       }
+                       if( slap_read_controls( op, rs, e,
+                               &slap_post_read_bv, postread_ctrl ) )
+                       {
+                               Debug( LDAP_DEBUG_TRACE,        
+                                       "<=- " LDAP_XSTRING(bdb_modrdn)
+                                       ": post-read failed!\n", 0, 0, 0 );
+                       }                   
+               }
+               TXN_ABORT( ltid );
+               ltid = NULL;
+               goto return_results;
+       }
+
        /* nested transaction */
        rs->sr_err = TXN_BEGIN( bdb->bi_dbenv, ltid, &lt2, bdb->bi_db_opflags );
        rs->sr_text = NULL;