When recreating a database from an ldif file created by ldbmcat,

NEXTID would not be set to one higher than the highest number
used, but to one higher than the last entry in the ldif file.
This commit is contained in:
Julio Sánchez Fernández 1999-07-30 18:53:23 +00:00
parent 3a1aab088d
commit 18393e882c
2 changed files with 13 additions and 5 deletions

View File

@ -34,6 +34,7 @@ main( int argc, char **argv )
int lmax, lcur;
int dbnum;
ID id;
ID maxid;
struct dbcache *db;
Backend *be = NULL;
struct ldbminfo *li;
@ -117,6 +118,7 @@ main( int argc, char **argv )
}
id = 0;
maxid = 0;
stop = 0;
buf = NULL;
lcur = lmax = 0;
@ -163,6 +165,8 @@ main( int argc, char **argv )
int len;
id++;
if ( id > maxid )
maxid = id;
key.dptr = (char *) &id;
key.dsize = sizeof(ID);
data.dptr = buf;
@ -183,8 +187,8 @@ main( int argc, char **argv )
}
}
id++;
bdb2i_put_nextid( be, id );
maxid++;
bdb2i_put_nextid( be, maxid );
#ifdef SLAP_CLEANUP
bdb2i_cache_close( be, db );

View File

@ -34,6 +34,7 @@ main( int argc, char **argv )
int lmax, lcur;
int dbnum;
ID id;
ID maxid;
DBCache *db;
Backend *be = NULL;
struct ldbminfo *li;
@ -119,6 +120,7 @@ main( int argc, char **argv )
}
id = 0;
maxid = 0;
stop = 0;
buf = NULL;
lcur = lmax = 0;
@ -165,6 +167,8 @@ main( int argc, char **argv )
int len;
id++;
if ( id > maxid )
maxid = id;
key.dptr = (char *) &id;
key.dsize = sizeof(ID);
data.dptr = buf;
@ -191,14 +195,14 @@ main( int argc, char **argv )
slap_shutdown(dbnum);
id++;
maxid++;
sprintf( line, "%s/NEXTID",
((struct ldbminfo *) be->be_private)->li_directory );
if ( (fp = fopen( line, "w" )) == NULL ) {
perror( line );
fprintf( stderr, "Could not write next id %ld\n", id );
fprintf( stderr, "Could not write next id %ld\n", maxid );
} else {
fprintf( fp, "%ld\n", id );
fprintf( fp, "%ld\n", maxid );
fclose( fp );
}