]> git.sur5r.net Git - openldap/commitdiff
When recreating a database from an ldif file created by ldbmcat,
authorJulio Sánchez Fernández <jsanchez@openldap.org>
Fri, 30 Jul 1999 18:53:23 +0000 (18:53 +0000)
committerJulio Sánchez Fernández <jsanchez@openldap.org>
Fri, 30 Jul 1999 18:53:23 +0000 (18:53 +0000)
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
servers/slapd/tools/ldif2id2entry.c

index 57cef5e506970b40f52f508c64f08c30a63de45f..bc055976bfe8254352d35c3e57d13582e0b7cf90 100644 (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 );
index b828734e50d0ea6e5e2eb91553b21afb94d044fa..0e886427b53f9dff1b93159f9763fa35c96c6d87 100644 (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 );
        }