From: Kurt Zeilenga Date: Thu, 3 Sep 1998 00:50:13 +0000 (+0000) Subject: Added support for SleepyCat DB2 DBI. X-Git-Tag: PHP3_TOOL_0_0~86 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=2054d40b7ce1a74c349fd0d523a275ccfdee85c7;p=openldap Added support for SleepyCat DB2 DBI. Derived from public posting to ldap@umich.edu by Kurt Spanier See Make-common.dist for DB2 options --- diff --git a/Make-common.dist b/Make-common.dist index dec90d498a..997b722722 100644 --- a/Make-common.dist +++ b/Make-common.dist @@ -144,6 +144,8 @@ SLAPD_BACKENDS= -DLDAP_LDBM -DLDAP_SHELL -DLDAP_PASSWD # standard unix ndbm # Fallback settings, defaults are set in build/*/Make-platform +# The NDBM interface may not work on some (any) platforms. +# You may be happier with Berkeley DB B-trees. LDBMBACKEND?=-DLDBM_USE_NDBM LDBMINCLUDE?= LDBMLIB?= @@ -163,8 +165,13 @@ LDBMLIB?= #LDBMINCLUDE=-I/usr/local/gdbm/include #LDBMLIB=-lgdbm -#undef these if you have SLEEPYCAT DB2 installed -#LDBMBACKEND=-DLDBM_USE_DBBTREE -DHAVE_SLEEPYCAT_DB2 +#undef these if you have SleepyCat DB2 installed the updated DBI +#LDBMBACKEND=-DLDBM_USE_DBBTREE -DLDBM_USE_DB2 +#LDBMINCLUDE=-I/usr/local/include +#LDBMLIB=-L/usr/local/lib -ldb + +#undef these if you have SleepyCat DB2 installed (with compat185) +#LDBMBACKEND=-DLDBM_USE_DBBTREE -DLDBM_USE_DB2_COMPAT185 #LDBMINCLUDE=-I/usr/local/include #LDBMLIB=-L/usr/local/lib -ldb diff --git a/include/ldbm.h b/include/ldbm.h index 1e3c61410c..f31f135ff8 100644 --- a/include/ldbm.h +++ b/include/ldbm.h @@ -47,10 +47,14 @@ extern gdbm_error gdbm_errno; #include #include -#ifdef HAVE_SLEEPYCAT_DB2 +#ifdef LDBM_USE_DB2_COMPAT185 # include #else # include +# ifdef LDBM_USE_DB2 +# define R_NOOVERWRITE DB_NOOVERWRITE +# define DEFAULT_DB_PAGE_SIZE 1024 +# endif #endif typedef DBT Datum; @@ -62,11 +66,18 @@ typedef DB *LDBM; #define DB_TYPE DB_HASH /* for ldbm_open */ -#define LDBM_READER O_RDONLY -#define LDBM_WRITER O_RDWR -#define LDBM_WRCREAT (O_RDWR|O_CREAT) -#define LDBM_NEWDB (O_RDWR|O_TRUNC|O_CREAT) -#define LDBM_FAST 0 +#ifdef LDBM_USE_DB2 +# define LDBM_READER DB_RDONLY +# define LDBM_WRITER 0x00000 /* hopefully */ +# define LDBM_WRCREAT (DB_NOMMAP|DB_CREATE|DB_THREAD) +# define LDBM_NEWDB (DB_TRUNCATE|DB_CREATE|DB_THREAD) +#else +# define LDBM_READER O_RDONLY +# define LDBM_WRITER O_RDWR +# define LDBM_WRCREAT (O_RDWR|O_CREAT) +# define LDBM_NEWDB (O_RDWR|O_TRUNC|O_CREAT) +# define LDBM_FAST 0 +#endif #define LDBM_SUFFIX ".dbh" @@ -90,12 +101,18 @@ extern int errno; #include #include #include -#ifdef HAVE_SLEEPYCAT_DB2 + +#ifdef LDBM_USE_DB2_COMPAT185 # include #else # include +# ifdef LDBM_USE_DB2 +# define R_NOOVERWRITE DB_NOOVERWRITE +# define DEFAULT_DB_PAGE_SIZE 1024 +# endif #endif + typedef DBT Datum; #define dsize size #define dptr data @@ -105,11 +122,19 @@ typedef DB *LDBM; #define DB_TYPE DB_BTREE /* for ldbm_open */ -#define LDBM_READER O_RDONLY -#define LDBM_WRITER O_RDWR -#define LDBM_WRCREAT (O_RDWR|O_CREAT) -#define LDBM_NEWDB (O_RDWR|O_TRUNC|O_CREAT) -#define LDBM_FAST 0 +#ifdef LDBM_USE_DB2 +# define LDBM_READER DB_RDONLY +# define LDBM_WRITER 0x00000 /* hopefully */ +# define LDBM_WRCREAT (DB_NOMMAP|DB_CREATE|DB_THREAD) +# define LDBM_NEWDB (DB_TRUNCATE|DB_CREATE|DB_THREAD) +#else +# define LDBM_READER O_RDONLY +# define LDBM_WRITER O_RDWR +# define LDBM_WRCREAT (O_RDWR|O_CREAT) +# define LDBM_NEWDB (O_RDWR|O_TRUNC|O_CREAT) +#endif + +# define LDBM_FAST 0 #define LDBM_SUFFIX ".dbb" #define LDBM_ORDERED 1 @@ -159,6 +184,7 @@ typedef DBM *LDBM; #endif /* db btree */ #endif /* gdbm */ +int ldbm_errno( LDBM ldbm ); LDBM ldbm_open( char *name, int rw, int mode, int dbcachesize ); void ldbm_close( LDBM ldbm ); void ldbm_sync( LDBM ldbm ); @@ -167,8 +193,14 @@ Datum ldbm_datum_dup( LDBM ldbm, Datum data ); Datum ldbm_fetch( LDBM ldbm, Datum key ); int ldbm_store( LDBM ldbm, Datum key, Datum data, int flags ); int ldbm_delete( LDBM ldbm, Datum key ); -Datum ldbm_firstkey( LDBM ldbm ); -Datum ldbm_nextkey( LDBM ldbm, Datum key ); -int ldbm_errno( LDBM ldbm ); + +#if LDBM_USE_DB2 + void *ldbm_malloc( size_t size ); + Datum ldbm_firstkey( LDBM ldbm, DBC **dbch ); + Datum ldbm_nextkey( LDBM ldbm, Datum key, DBC *dbcp ); +#else + Datum ldbm_firstkey( LDBM ldbm ); + Datum ldbm_nextkey( LDBM ldbm, Datum key ); +#endif #endif /* _ldbm_h_ */ diff --git a/libraries/libldbm/ldbm.c b/libraries/libldbm/ldbm.c index 6d15e4629e..d4ff0d395c 100644 --- a/libraries/libldbm/ldbm.c +++ b/libraries/libldbm/ldbm.c @@ -1,5 +1,11 @@ /* ldbm.c - ldap dbm compatibility routines */ +/* Patched for Berkeley DB version 2.0; /KSp; 98/02/23 + * + * - basic implementation; 1998/02/23, /KSp + * - DB_DBT_MALLOC ; 1998/03/22, /KSp + */ + #include #include "ldbm.h" @@ -121,10 +127,41 @@ ldbm_errno( LDBM ldbm ) * * *****************************************************************/ +#ifdef LDBM_USE_DB2 +/************************************************* + * * + * A malloc routine for use with DB_DBT_MALLOC * + * * + *************************************************/ + +#include + + +void * +ldbm_malloc( size_t size ) +{ + return( calloc( 1, size )); +} + +#endif + + LDBM ldbm_open( char *name, int rw, int mode, int dbcachesize ) { - LDBM ret; + LDBM ret = NULL; + +#ifdef LDBM_USE_DB2 + DB_INFO dbinfo; + + memset( &dbinfo, 0, sizeof( dbinfo )); + dbinfo.db_cachesize = dbcachesize; + dbinfo.db_pagesize = DEFAULT_DB_PAGE_SIZE; + dbinfo.db_malloc = ldbm_malloc; + + db_open( name, DB_TYPE, rw, mode, NULL, &dbinfo, &ret ); + +#else void *info; BTREEINFO binfo; HASHINFO hinfo; @@ -140,14 +177,22 @@ ldbm_open( char *name, int rw, int mode, int dbcachesize ) } else { info = NULL; } + ret = dbopen( name, rw, mode, DB_TYPE, info ); + +#endif + return( ret ); } void ldbm_close( LDBM ldbm ) { +#ifdef LDBM_USE_DB2 + (*ldbm->close)( ldbm, 0 ); +#else (*ldbm->close)( ldbm ); +#endif } void @@ -167,6 +212,10 @@ ldbm_datum_dup( LDBM ldbm, Datum data ) { Datum dup; +#ifdef LDBM_USE_DB2 + memset( &dup, 0, sizeof( dup )); +#endif + if ( data.dsize == 0 ) { dup.dsize = 0; dup.dptr = NULL; @@ -186,9 +235,18 @@ ldbm_fetch( LDBM ldbm, Datum key ) Datum data; int rc; +#ifdef LDBM_USE_DB2 + memset( &data, 0, sizeof( data )); + + data.flags = DB_DBT_MALLOC; + + if ( (rc = (*ldbm->get)( ldbm, NULL, &key, &data, 0 )) != 0 ) { + if ( data.dptr ) free( data.dptr ); +#else if ( (rc = (*ldbm->get)( ldbm, &key, &data, 0 )) == 0 ) { data = ldbm_datum_dup( ldbm, data ); } else { +#endif data.dptr = NULL; data.dsize = 0; } @@ -201,7 +259,12 @@ ldbm_store( LDBM ldbm, Datum key, Datum data, int flags ) { int rc; +#ifdef LDBM_USE_DB2 + rc = (*ldbm->put)( ldbm, NULL, &key, &data, flags & ~LDBM_SYNC ); + rc = (-1 ) * rc; +#else rc = (*ldbm->put)( ldbm, &key, &data, flags & ~LDBM_SYNC ); +#endif if ( flags & LDBM_SYNC ) (*ldbm->sync)( ldbm, 0 ); return( rc ); @@ -212,38 +275,88 @@ ldbm_delete( LDBM ldbm, Datum key ) { int rc; +#ifdef LDBM_USE_DB2 + rc = (*ldbm->del)( ldbm, NULL, &key, 0 ); + rc = (-1 ) * rc; +#else rc = (*ldbm->del)( ldbm, &key, 0 ); +#endif (*ldbm->sync)( ldbm, 0 ); return( rc ); } Datum +#ifdef LDBM_USE_DB2 +ldbm_firstkey( LDBM ldbm, DBC **dbch ) +#else ldbm_firstkey( LDBM ldbm ) +#endif { Datum key, data; int rc; +#ifdef LDBM_USE_DB2 + DBC *dbci; + + memset( &key, 0, sizeof( key )); + memset( &data, 0, sizeof( data )); + + key.flags = data.flags = DB_DBT_MALLOC; + + /* acquire a cursor for the DB */ + if ( (*ldbm->cursor)( ldbm, NULL, &dbci )) { + return( key ); + } else { + *dbch = dbci; + if ( (*dbci->c_get)( dbci, &key, &data, DB_NEXT ) == 0 ) { + if ( data.dptr ) free( data.dptr ); +#else if ( (rc = (*ldbm->seq)( ldbm, &key, &data, R_FIRST )) == 0 ) { key = ldbm_datum_dup( ldbm, key ); +#endif } else { key.dptr = NULL; key.dsize = 0; } + +#ifdef LDBM_USE_DB2 + } +#endif + return( key ); } Datum +#ifdef LDBM_USE_DB2 +ldbm_nextkey( LDBM ldbm, Datum key, DBC *dbcp ) +#else ldbm_nextkey( LDBM ldbm, Datum key ) +#endif { Datum data; int rc; +#ifdef LDBM_USE_DB2 + void *oldKey = key.dptr; + + memset( &data, 0, sizeof( data )); + + data.flags = DB_DBT_MALLOC; + + if ( (*dbcp->c_get)( dbcp, &key, &data, DB_NEXT ) == 0 ) { + if ( data.dptr ) free( data.dptr ); +#else if ( (rc = (*ldbm->seq)( ldbm, &key, &data, R_NEXT )) == 0 ) { key = ldbm_datum_dup( ldbm, key ); +#endif } else { key.dptr = NULL; key.dsize = 0; } +#ifdef LDBM_USE_DB2 + if ( oldKey ) free( oldKey ); +#endif + return( key ); } diff --git a/servers/slapd/back-ldbm/back-ldbm.h b/servers/slapd/back-ldbm/back-ldbm.h index 4668e7554d..e3099ab21a 100644 --- a/servers/slapd/back-ldbm/back-ldbm.h +++ b/servers/slapd/back-ldbm/back-ldbm.h @@ -6,7 +6,13 @@ #include "ldbm.h" #define DEFAULT_CACHE_SIZE 1000 -#define DEFAULT_DBCACHE_SIZE 100000 + +#ifdef LDBM_USE_DB2 +# define DEFAULT_DBCACHE_SIZE (100 * DEFAULT_DB_PAGE_SIZE) +#else +# define DEFAULT_DBCACHE_SIZE 100000 +#endif + #define DEFAULT_DB_DIRECTORY "/usr/tmp" #define DEFAULT_MODE 0600 diff --git a/servers/slapd/back-ldbm/dbcache.c b/servers/slapd/back-ldbm/dbcache.c index c16c8b160d..56c259c869 100644 --- a/servers/slapd/back-ldbm/dbcache.c +++ b/servers/slapd/back-ldbm/dbcache.c @@ -176,6 +176,9 @@ ldbm_cache_fetch( ) { Datum data; +#ifdef LDBM_USE_DB2 + memset( &data, 0, sizeof( data ) ); +#endif pthread_mutex_lock( &db->dbc_mutex ); #ifdef reentrant_database @@ -216,6 +219,24 @@ ldbm_cache_store( } #endif +#ifdef LDBM_DEBUG + Statslog( LDAP_DEBUG_STATS, + "=> ldbm_cache_store(): key.dptr=%s, key.dsize=%d\n", + key.dptr, key.dsize, 0, 0, 0 ); + + Statslog( LDAP_DEBUG_STATS, + "=> ldbm_cache_store(): key.dptr=0x%08x, data.dptr=0x%0 8x\n", + key.dptr, data.dptr, 0, 0, 0 ); + + Statslog( LDAP_DEBUG_STATS, + "=> ldbm_cache_store(): data.dptr=%s, data.dsize=%d\n", + data.dptr, data.dsize, 0, 0, 0 ); + + Statslog( LDAP_DEBUG_STATS, + "=> ldbm_cache_store(): flags=0x%08x\n", + flags, 0, 0, 0, 0 ); +#endif /* LDBM_DEBUG */ + rc = ldbm_store( db->dbc_db, key, data, flags ); pthread_mutex_unlock( &db->dbc_mutex ); diff --git a/servers/slapd/back-ldbm/dn2id.c b/servers/slapd/back-ldbm/dn2id.c index 45eeec8f10..7d142b311d 100644 --- a/servers/slapd/back-ldbm/dn2id.c +++ b/servers/slapd/back-ldbm/dn2id.c @@ -25,6 +25,11 @@ dn2id_add( Datum key, data; struct ldbminfo *li = (struct ldbminfo *) be->be_private; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); + memset( &data, 0, sizeof( data ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> dn2id_add( \"%s\", %ld )\n", dn, id, 0 ); if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) @@ -66,6 +71,10 @@ dn2id( ID id; Datum key, data; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); + memset( &data, 0, sizeof( data ) ); +#endif dn = strdup( dn ); dn_normalize_case( dn ); @@ -122,6 +131,10 @@ dn2id_delete( Datum key; int rc; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> dn2id_delete( \"%s\" )\n", dn, 0, 0 ); if ( (db = ldbm_cache_open( be, "dn2id", LDBM_SUFFIX, LDBM_WRCREAT )) diff --git a/servers/slapd/back-ldbm/id2children.c b/servers/slapd/back-ldbm/id2children.c index 3b2c55d202..7210eece0d 100644 --- a/servers/slapd/back-ldbm/id2children.c +++ b/servers/slapd/back-ldbm/id2children.c @@ -23,6 +23,11 @@ id2children_add( IDList *idl; char buf[20]; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); + memset( &data, 0, sizeof( data ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> id2children_add( %d, %d )\n", p ? p->e_id : 0, e->e_id, 0 ); @@ -63,6 +68,10 @@ has_children( IDList *idl; char buf[20]; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> has_children( %d )\n", p->e_id , 0, 0 ); if ( (db = ldbm_cache_open( be, "id2children", LDBM_SUFFIX, diff --git a/servers/slapd/back-ldbm/id2entry.c b/servers/slapd/back-ldbm/id2entry.c index f5a51089d7..505ea8863a 100644 --- a/servers/slapd/back-ldbm/id2entry.c +++ b/servers/slapd/back-ldbm/id2entry.c @@ -22,6 +22,11 @@ id2entry_add( Backend *be, Entry *e ) Datum key, data; int len, rc, flags; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); + memset( &data, 0, sizeof( data ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> id2entry_add( %d, \"%s\" )\n", e->e_id, e->e_dn, 0 ); @@ -61,6 +66,10 @@ id2entry_delete( Backend *be, Entry *e ) Datum key; int rc; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> id2entry_delete( %d, \"%s\" )\n", e->e_id, e->e_dn, 0 ); @@ -95,6 +104,11 @@ id2entry( Backend *be, ID id ) Datum key, data; Entry *e; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); + memset( &data, 0, sizeof( data ) ); +#endif + Debug( LDAP_DEBUG_TRACE, "=> id2entry( %ld )\n", id, 0, 0 ); if ( (e = cache_find_entry_id( &li->li_cache, id )) != NULL ) { diff --git a/servers/slapd/back-ldbm/idl.c b/servers/slapd/back-ldbm/idl.c index 8a249fe048..b693c0ce4e 100644 --- a/servers/slapd/back-ldbm/idl.c +++ b/servers/slapd/back-ldbm/idl.c @@ -59,6 +59,11 @@ idl_fetch_one( char *kstr; int i, nids; +#ifdef LDBM_USE_DB2 + memset( &k2, 0, sizeof( k2 ) ); + memset( &data, 0, sizeof( data ) ); +#endif + /* Debug( LDAP_DEBUG_TRACE, "=> idl_fetch_one\n", 0, 0, 0 ); */ data = ldbm_cache_fetch( db, key ); @@ -81,6 +86,11 @@ idl_fetch( char *kstr; int i, nids; +#ifdef LDBM_USE_DB2 + memset( &k2, 0, sizeof( k2 ) ); + memset( &data, 0, sizeof( data ) ); +#endif + /* Debug( LDAP_DEBUG_TRACE, "=> idl_fetch\n", 0, 0, 0 ); */ data = ldbm_cache_fetch( db, key ); @@ -170,11 +180,20 @@ idl_store( Datum data; struct ldbminfo *li = (struct ldbminfo *) be->be_private; +#ifdef LDBM_USE_DB2 + memset( &data, 0, sizeof( data ) ); +#endif + /* Debug( LDAP_DEBUG_TRACE, "=> idl_store\n", 0, 0, 0 ); */ data.dptr = (char *) idl; data.dsize = (2 + idl->b_nmax) * sizeof(ID); +#ifdef LDBM_DEBUG + Statslog( LDAP_DEBUG_STATS, "<= idl_store(): rc=%d\n", + rc, 0, 0, 0, 0 ); +#endif + flags = LDBM_REPLACE; if( li->li_flush_wrt ) flags |= LDBM_SYNC; rc = ldbm_cache_store( db, key, data, flags ); @@ -283,7 +302,16 @@ idl_insert_key( char *kstr; Datum k2; +#ifdef LDBM_USE_DB2 + memset( &k2, 0, sizeof( k2 ) ); +#endif + if ( (idl = idl_fetch_one( be, db, key )) == NULL ) { +#ifdef LDBM_DEBUG + Statslog( LDAP_DEBUG_STATS, "=> idl_insert_key(): no key yet\n", + 0, 0, 0, 0, 0 ); +#endif + idl = idl_alloc( 1 ); idl->b_ids[idl->b_nids++] = id; rc = idl_store( be, db, key, idl ); diff --git a/servers/slapd/back-ldbm/index.c b/servers/slapd/back-ldbm/index.c index 100b058b73..bf1f55de35 100644 --- a/servers/slapd/back-ldbm/index.c +++ b/servers/slapd/back-ldbm/index.c @@ -105,6 +105,10 @@ index_read( char *realval, *tmpval; char buf[BUFSIZ]; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); +#endif + prefix = index2prefix( indextype ); Debug( LDAP_DEBUG_TRACE, "=> index_read( \"%s\" \"%c\" \"%s\" )\n", type, prefix, val ); @@ -175,6 +179,10 @@ add_value( char *realval, *tmpval, *s; char buf[BUFSIZ]; +#ifdef LDBM_USE_DB2 + memset( &key, 0, sizeof( key ) ); +#endif + prefix = index2prefix( indextype ); Debug( LDAP_DEBUG_TRACE, "=> add_value( \"%c%s\" )\n", prefix, val, 0 ); diff --git a/servers/slapd/tools/centipede.c b/servers/slapd/tools/centipede.c index 9919232b7a..fc2b72aa93 100644 --- a/servers/slapd/tools/centipede.c +++ b/servers/slapd/tools/centipede.c @@ -556,6 +556,11 @@ diff_centroids( int amax, acur, dmax, dcur; char **vals; +#ifdef LDBM_USE_DB2 + DBC *ocursorp; + DBC *ncursorp; +#endif /* LDBM_USE_DB2 */ + if ( verbose ) { printf( "Generating mods for differential %s centroid...", attr ); fflush( stdout ); @@ -600,8 +605,14 @@ diff_centroids( olast.dptr = NULL; nlast.dptr = NULL; +#ifdef LDBM_USE_DB2 + for ( okey = ldbm_firstkey( oldbm, &ocursorp ), + nkey = ldbm_firstkey( nldbm, &ncursorp ); + okey.dptr != NULL && nkey.dptr != NULL; ) +#else for ( okey = ldbm_firstkey( oldbm ), nkey = ldbm_firstkey( nldbm ); okey.dptr != NULL && nkey.dptr != NULL; ) +#endif { rc = strcmp( okey.dptr, nkey.dptr ); @@ -616,8 +627,13 @@ diff_centroids( } nlast = nkey; +#ifdef LDBM_USE_DB2 + okey = ldbm_nextkey( oldbm, olast, ocursorp ); + nkey = ldbm_nextkey( nldbm, nlast, ncursorp ); +#else okey = ldbm_nextkey( oldbm, olast ); nkey = ldbm_nextkey( nldbm, nlast ); +#endif } else if ( rc > 0 ) { /* new value is not in old centroid - add it */ if ( charray_add_dup( &avals, &acur, &amax, nkey.dptr ) == NULL ) { @@ -629,7 +645,12 @@ diff_centroids( ldbm_datum_free( nldbm, nlast ); } nlast = nkey; + +#ifdef LDBM_USE_DB2 + nkey = ldbm_nextkey( nldbm, nlast, ncursorp ); +#else nkey = ldbm_nextkey( nldbm, nlast ); +#endif } else { /* old value is not in new centroid - delete it */ if ( charray_add_dup( &dvals, &dcur, &dmax, okey.dptr ) == NULL ) { @@ -641,7 +662,12 @@ diff_centroids( ldbm_datum_free( oldbm, olast ); } olast = okey; + +#ifdef LDBM_USE_DB2 + okey = ldbm_nextkey( oldbm, olast, ocursorp ); +#else okey = ldbm_nextkey( oldbm, olast ); +#endif } } @@ -651,7 +677,11 @@ diff_centroids( return( NULL ); } +#ifdef LDBM_USE_DB2 + okey = ldbm_nextkey( oldbm, olast, ocursorp ); +#else okey = ldbm_nextkey( oldbm, olast ); +#endif if ( olast.dptr != NULL ) { ldbm_datum_free( oldbm, olast ); } @@ -666,7 +696,11 @@ diff_centroids( return( NULL ); } +#ifdef LDBM_USE_DB2 + nkey = ldbm_nextkey( nldbm, nlast, ncursorp ); +#else nkey = ldbm_nextkey( nldbm, nlast ); +#endif if ( nlast.dptr != NULL ) { ldbm_datum_free( nldbm, nlast ); } @@ -687,8 +721,14 @@ diff_centroids( /* generate list of values to add */ lastkey.dptr = NULL; +#ifdef LDBM_USE_DB2 + for ( key = ldbm_firstkey( nldbm, &ncursorp ); key.dptr != NULL; + key = ldbm_nextkey( nldbm, lastkey, ncursorp ) ) +#else for ( key = ldbm_firstkey( nldbm ); key.dptr != NULL; - key = ldbm_nextkey( nldbm, lastkey ) ) { + key = ldbm_nextkey( nldbm, lastkey ) ) +#endif + { /* see if it's in the old one */ data = ldbm_fetch( oldbm, key ); @@ -712,8 +752,14 @@ diff_centroids( /* generate list of values to delete */ lastkey.dptr = NULL; +#ifdef LDBM_USE_DB2 + for ( key = ldbm_firstkey( oldbm, &ocursorp ); key.dptr != NULL; + key = ldbm_nextkey( oldbm, lastkey, ocursorp ) ) +#else for ( key = ldbm_firstkey( oldbm ); key.dptr != NULL; - key = ldbm_nextkey( oldbm, lastkey ) ) { + key = ldbm_nextkey( oldbm, lastkey ) ) +#endif + { /* see if it's in the new one */ data = ldbm_fetch( nldbm, key ); @@ -773,6 +819,10 @@ full_centroid( char **vals; int vcur, vmax; +#ifdef LDBM_USE_DB2 + DBC *cursorp; +#endif + if ( verbose ) { printf( "Generating mods for full %s centroid...", attr ); fflush( stdout ); @@ -800,8 +850,14 @@ full_centroid( lastkey.dptr = NULL; vals = NULL; vcur = vmax = 0; +#ifdef LDBM_USE_DB2 + for ( key = ldbm_firstkey( ldbm, &cursorp ); key.dptr != NULL; + key = ldbm_nextkey( ldbm, lastkey, cursorp ) ) +#else for ( key = ldbm_firstkey( ldbm ); key.dptr != NULL; - key = ldbm_nextkey( ldbm, lastkey ) ) { + key = ldbm_nextkey( ldbm, lastkey ) ) +#endif + { if ( charray_add_dup( &vals, &vcur, &vmax, key.dptr ) == NULL ) { ldap_mods_free( mods, 1 ); return( NULL ); diff --git a/servers/slapd/tools/ldbmcat.c b/servers/slapd/tools/ldbmcat.c index 79465df072..de106e1ac7 100644 --- a/servers/slapd/tools/ldbmcat.c +++ b/servers/slapd/tools/ldbmcat.c @@ -24,6 +24,10 @@ main( argc, argv ) char *file, *s; int printid = 1; +#ifdef LDBM_USE_DB2 + DBC *cursorp; +#endif + if ( argc < 2 || argc > 3 || ( argc == 3 && strcmp( argv[1], "-n" ) != 0 )) { usage( argv[0] ); @@ -41,8 +45,15 @@ main( argc, argv ) } last.dptr = NULL; + +#ifdef LDBM_USE_DB2 + for ( key = ldbm_firstkey( dbp, &cursorp ); key.dptr != NULL; + key = ldbm_nextkey( dbp, last, cursorp ) ) +#else for ( key = ldbm_firstkey( dbp ); key.dptr != NULL; - key = ldbm_nextkey( dbp, last ) ) { + key = ldbm_nextkey( dbp, last ) ) +#endif + { if ( last.dptr != NULL ) ldbm_datum_free( dbp, last ); data = ldbm_fetch( dbp, key ); diff --git a/servers/slapd/tools/ldbmtest.c b/servers/slapd/tools/ldbmtest.c index 56513ab5b8..13e0f95580 100644 --- a/servers/slapd/tools/ldbmtest.c +++ b/servers/slapd/tools/ldbmtest.c @@ -64,6 +64,10 @@ main( argc, argv ) int i; extern char *optarg; +#ifdef LDBM_USE_DB2 + DBC *cursorp; +#endif + tailorfile = SLAPD_DEFAULT_CONFIGFILE; while ( (i = getopt( argc, argv, "d:f:" )) != EOF ) { switch ( i ) { @@ -151,9 +155,16 @@ main( argc, argv ) } savekey.dptr = NULL; +#ifdef LDBM_USE_DB2 + for ( key = ldbm_firstkey( dbc->dbc_db, &cursorp ); + key.dptr != NULL; + key = ldbm_nextkey( dbc->dbc_db, key, cursorp ) ) +#else for ( key = ldbm_firstkey( dbc->dbc_db ); key.dptr != NULL; - key = ldbm_nextkey( dbc->dbc_db, key ) ) { + key = ldbm_nextkey( dbc->dbc_db, key ) ) +#endif + { if ( savekey.dptr != NULL ) ldbm_datum_free( dbc->dbc_db, savekey ); savekey = key; @@ -313,8 +324,16 @@ main( argc, argv ) } last.dptr = NULL; + +#ifdef LDBM_USE_DB2 + for ( key = ldbm_firstkey( dbp, &cursorp ); + key.dptr != NULL; + key = ldbm_nextkey( dbp, last, cursorp ) ) +#else for ( key = ldbm_firstkey( dbp ); key.dptr != NULL; - key = ldbm_nextkey( dbp, last ) ) { + key = ldbm_nextkey( dbp, last ) ) +#endif + { if ( last.dptr != NULL ) { ldbm_datum_free( dbp, last ); }