From: Julio Sánchez Fernández Date: Fri, 30 Jul 1999 18:53:23 +0000 (+0000) Subject: When recreating a database from an ldif file created by ldbmcat, X-Git-Tag: TWEB_OL_BASE~359 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=18393e882cd89e461fc804b8ef58817027e465a1;p=openldap 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. --- diff --git a/servers/slapd/tools/ldif2id2entry-bdb2.c b/servers/slapd/tools/ldif2id2entry-bdb2.c index 57cef5e506..bc055976bf 100644 --- a/servers/slapd/tools/ldif2id2entry-bdb2.c +++ b/servers/slapd/tools/ldif2id2entry-bdb2.c @@ -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 ); diff --git a/servers/slapd/tools/ldif2id2entry.c b/servers/slapd/tools/ldif2id2entry.c index b828734e50..0e886427b5 100644 --- a/servers/slapd/tools/ldif2id2entry.c +++ b/servers/slapd/tools/ldif2id2entry.c @@ -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 ); }