Check the ldif file without actually creating the db (but inits the files;

maybe I should trim this also).  Useful to check LARGE ldif files which
will require TONS on indices without failing at the very last entry for
a silly typo after 45 min. or more :)
This commit is contained in:
Pierangelo Masarati 2002-01-28 20:36:29 +00:00
parent 4f2ff1c108
commit c775624c9f
3 changed files with 25 additions and 15 deletions

View File

@ -52,7 +52,6 @@ main( int argc, char **argv )
}
while( ldif_read_record( ldiffp, &lineno, &buf, &lmax ) ) {
ID id;
Entry *e = str2entry( buf );
struct berval bvtext = { textlen, textbuf };
@ -146,20 +145,25 @@ main( int argc, char **argv )
}
}
id = be->be_entry_put( be, e, &bvtext );
if( id == NOID ) {
fprintf( stderr, "%s: could not add entry dn=\"%s\" (line=%d): %s\n",
progname, e->e_dn, lineno, bvtext.bv_val );
rc = EXIT_FAILURE;
entry_free( e );
if( continuemode ) continue;
break;
}
if (!dryrun) {
ID id = be->be_entry_put( be, e, &bvtext );
if( id == NOID ) {
fprintf( stderr, "%s: could not add entry dn=\"%s\" (line=%d): %s\n",
progname, e->e_dn, lineno, bvtext.bv_val );
rc = EXIT_FAILURE;
entry_free( e );
if( continuemode ) continue;
break;
}
if ( verbose ) {
fprintf( stderr, "added: \"%s\" (%08lx)\n",
e->e_dn, (long) id );
if ( verbose ) {
fprintf( stderr, "added: \"%s\" (%08lx)\n",
e->e_dn, (long) id );
}
} else {
if ( verbose ) {
fprintf( stderr, "(dry) added: \"%s\"\n", e->e_dn );
}
}
entry_free( e );

View File

@ -25,6 +25,7 @@ int truncatemode = 0;
int verbose = 0;
int continuemode = 0;
int nosubordinates = 0;
int dryrun = 0;
char *ldiffile = NULL;
FILE *ldiffp = NULL;
@ -97,7 +98,7 @@ slap_tool_init(
switch( tool ) {
case SLAPADD:
options = "b:cd:f:l:n:tv";
options = "b:cd:f:l:n:tuv";
break;
case SLAPINDEX:
@ -148,6 +149,10 @@ slap_tool_init(
mode |= SLAP_TRUNCATE_MODE;
break;
case 'u': /* dry run */
dryrun++;
break;
case 'v': /* turn on verbose */
verbose++;
break;

View File

@ -26,6 +26,7 @@ extern int appendmode;
extern int verbose;
extern int continuemode;
extern int nosubordinates;
extern int dryrun;
extern char *ldiffile;
extern FILE *ldiffp;