From 18393e882cd89e461fc804b8ef58817027e465a1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Julio=20S=C3=A1nchez=20Fern=C3=A1ndez?= Date: Fri, 30 Jul 1999 18:53:23 +0000 Subject: [PATCH] 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. --- servers/slapd/tools/ldif2id2entry-bdb2.c | 8 ++++++-- servers/slapd/tools/ldif2id2entry.c | 10 +++++++--- 2 files changed, 13 insertions(+), 5 deletions(-) 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 ); } -- 2.39.5