Commit 973a9303 authored by Howard Chu's avatar Howard Chu Committed by Quanah Gibson-Mount
Browse files

ITS#9122 expose SLAP_TOOL_DRYRUN to backends

Most backends should no-op everything. back-config will
still parse and process all config directives.
parent c4ac5b31
......@@ -1836,6 +1836,9 @@ ldif_tool_entry_open( BackendDB *be, int mode )
{
struct ldif_tool *tl = &((struct ldif_info *) be->be_private)->li_tool;
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
tl->ecurrent = 0;
return 0;
}
......@@ -1847,6 +1850,9 @@ ldif_tool_entry_close( BackendDB *be )
Entry **entries = tl->entries;
ID i;
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
for ( i = tl->ecount; i--; )
if ( entries[i] )
entry_free( entries[i] );
......@@ -1947,6 +1953,9 @@ ldif_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
char *parentdir;
Operation op = {0};
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
op.o_bd = be;
rc = ldif_prepare_create( &op, e, &path, &parentdir, &errmsg );
if ( rc == LDAP_SUCCESS ) {
......
......@@ -101,6 +101,9 @@ mdb_tool_entry_get_int( BackendDB *be, ID id, Entry **ep );
int mdb_tool_entry_open(
BackendDB *be, int mode )
{
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
/* In Quick mode, commit once per 500 entries */
mdb_writes = 0;
if ( slapMode & SLAP_TOOL_QUICK )
......@@ -147,6 +150,9 @@ int mdb_tool_entry_open(
int mdb_tool_entry_close(
BackendDB *be )
{
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
#ifdef MDB_TOOL_IDL_CACHING
if ( mdb_tool_info ) {
int i;
......@@ -652,6 +658,9 @@ ID mdb_tool_entry_put(
Operation op = {0};
Opheader ohdr = {0};
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
assert( be != NULL );
assert( slapMode & SLAP_TOOL_MODE );
......
......@@ -62,6 +62,9 @@ int ndb_tool_entry_open(
{
struct ndb_info *ni = (struct ndb_info *) be->be_private;
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
myNdb = new Ndb( ni->ni_cluster[0], ni->ni_dbname );
return myNdb->init(1024);
}
......@@ -70,6 +73,9 @@ extern "C"
int ndb_tool_entry_close(
BackendDB *be )
{
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
if ( myPutTxn ) {
int rc = myPutTxn->execute(NdbTransaction::Commit);
if( rc != 0 ) {
......@@ -408,6 +414,9 @@ ID ndb_tool_entry_put(
assert( text->bv_val != NULL );
assert( text->bv_val[0] == '\0' ); /* overconservative? */
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
Debug( LDAP_DEBUG_TRACE, "=> " LDAP_XSTRING(ndb_tool_entry_put)
"( %ld, \"%s\" )\n", (long) e->e_id, e->e_dn, 0 );
......
......@@ -49,6 +49,9 @@ wt_tool_entry_open( BackendDB *be, int mode )
struct wt_info *wi = (struct wt_info *) be->be_private;
int rc;
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
wc = wt_ctx_init(wi);
if( !wc ){
Debug( LDAP_DEBUG_ANY,
......@@ -71,6 +74,9 @@ wt_tool_entry_open( BackendDB *be, int mode )
int
wt_tool_entry_close( BackendDB *be )
{
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
if( reader ) {
reader->close(reader);
reader = NULL;
......@@ -300,6 +306,9 @@ wt_tool_entry_put( BackendDB *be, Entry *e, struct berval *text )
Operation op = {0};
Opheader ohdr = {0};
if ( slapMode & SLAP_TOOL_DRYRUN )
return 0;
assert( slapMode & SLAP_TOOL_MODE );
assert( text != NULL );
assert( text->bv_val != NULL );
......
......@@ -1607,6 +1607,7 @@ LDAP_SLAPD_V (int) slapMode;
#define SLAP_TOOL_QUICK 0x0800
#define SLAP_TOOL_NO_SCHEMA_CHECK 0x1000
#define SLAP_TOOL_VALUE_CHECK 0x2000
#define SLAP_TOOL_DRYRUN 0x4000
#define SLAP_SERVER_RUNNING 0x8000
......
......@@ -400,7 +400,7 @@ slapadd( int argc, char **argv )
SLAP_DBFLAGS(be) &= ~(SLAP_DBFLAG_NO_SCHEMA_CHECK);
}
if( !dryrun && be->be_entry_open( be, 1 ) != 0 ) {
if( be->be_entry_open && be->be_entry_open( be, 1 ) != 0 ) {
fprintf( stderr, "%s: could not open database.\n",
progname );
exit( EXIT_FAILURE );
......@@ -442,7 +442,7 @@ slapadd( int argc, char **argv )
break;
}
if ( !dryrun ) {
if ( be->be_entry_put ) {
/*
* Initialize text buffer
*/
......@@ -504,7 +504,7 @@ slapadd( int argc, char **argv )
ch_free( buf );
if ( !dryrun ) {
if ( be->be_entry_close ) {
if ( enable_meter ) {
fprintf( stderr, "Closing DB..." );
}
......
......@@ -554,6 +554,7 @@ slap_tool_init(
case 'u': /* dry run */
dryrun++;
mode |= SLAP_TOOL_DRYRUN;
break;
case 'v': /* turn on verbose */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment