]> git.sur5r.net Git - openldap/commitdiff
ITS#4089 use slapcat -n XX to specify just the superior of a glued tree
authorHoward Chu <hyc@openldap.org>
Sat, 15 Oct 2005 20:08:56 +0000 (20:08 +0000)
committerHoward Chu <hyc@openldap.org>
Sat, 15 Oct 2005 20:08:56 +0000 (20:08 +0000)
servers/slapd/backglue.c
servers/slapd/proto-slap.h
servers/slapd/slapcommon.c

index bc17618b36bf29a0f08acab01865199ae424380a..71a1884dfe7cd289b501c033bee99bd4df167e1e 100644 (file)
@@ -919,6 +919,51 @@ glue_sub_add( BackendDB *be, int advert, int online )
        return rc;
 }
 
+/* Detach all glued subordinates from the superior. Only
+ * called in tool mode.
+ */
+void
+glue_sub_detach( BackendDB *be )
+{
+       slap_overinfo *oi = (slap_overinfo *)be->bd_info;
+       slap_overinst *on, **oprev;
+
+       /* If glue is the only overlay, just remove the overlay framework */
+       if ( oi->oi_list->on_bi.bi_type == glue.on_bi.bi_type &&
+               oi->oi_list->on_next == NULL ) {
+               /* We don't do any cleanup. Doesn't matter in tool mode. */
+               be->bd_info = oi->oi_orig;
+               return;
+       }
+
+       /* There are multiple overlays, just drop ours from the list */
+       for ( on=oi->oi_list, oprev = &oi->oi_list; on; on=on->on_next ) {
+               if ( on->on_bi.bi_type == glue.on_bi.bi_type ) {
+                       *oprev = on->on_next;
+                       break;
+               }
+               oprev = &on->on_next;
+
+               /* Undo the glue_db_init() changes in oi */
+               oi->oi_bi.bi_open = oi->oi_orig->bi_open;
+               oi->oi_bi.bi_close = oi->oi_orig->bi_close;
+
+               oi->oi_bi.bi_entry_release_rw = oi->oi_orig->bi_entry_release_rw;
+
+               oi->oi_bi.bi_tool_entry_open = oi->oi_orig->bi_tool_entry_open;
+               oi->oi_bi.bi_tool_entry_close = oi->oi_orig->bi_tool_entry_close;
+               oi->oi_bi.bi_tool_entry_first = oi->oi_orig->bi_tool_entry_first;
+               oi->oi_bi.bi_tool_entry_get = oi->oi_orig->bi_tool_entry_get;
+               oi->oi_bi.bi_tool_entry_put = oi->oi_orig->bi_tool_entry_put;
+               oi->oi_bi.bi_tool_entry_reindex = oi->oi_orig->bi_tool_entry_reindex;
+               oi->oi_bi.bi_tool_sync = oi->oi_orig->bi_tool_sync;
+               oi->oi_bi.bi_tool_dn2id_get = oi->oi_orig->bi_tool_dn2id_get;
+               oi->oi_bi.bi_tool_id2entry_get = oi->oi_orig->bi_tool_id2entry_get;
+               oi->oi_bi.bi_tool_entry_modify = oi->oi_orig->bi_tool_entry_modify;
+       }
+       return;
+}
+
 int
 glue_sub_init()
 {
index d9c0ab24364788408a9ac528d5aa7687f2c5b58e..41fed652947a053043df5d1ef913ce1cf0e1996e 100644 (file)
@@ -404,6 +404,7 @@ LDAP_SLAPD_F (int) glue_sub_init( void );
 LDAP_SLAPD_F (int) glue_sub_attach( void );
 LDAP_SLAPD_F (int) glue_sub_add( BackendDB *be, int advert, int online );
 LDAP_SLAPD_F (int) glue_sub_del( BackendDB *be );
+LDAP_SLAPD_F (void) glue_sub_detach( BackendDB *be );
 
 /*
  * backover.c
index eb82e2da38502e6f50cbb0c4dbe139bc9e3582ed..ddec1a2447fc29c53454fa16e858231f0bb04f6a 100644 (file)
@@ -560,6 +560,12 @@ slap_tool_init(
                        if ( dbnum == 0 ) break;
                        dbnum--;
                }
+               /* If a glued database is specified by number, just operate
+                * on the single database.
+                */
+               if ( SLAP_GLUE_INSTANCE( be ) ) {
+                       glue_sub_detach( be );
+               }
        }
 
 startup:;