]> git.sur5r.net Git - openldap/blob - servers/slapd/back-bdb/tools.c
Fix ITS#3255, boi_bdb comparisons
[openldap] / servers / slapd / back-bdb / tools.c
1 /* tools.c - tools for slap tools */
2 /* $OpenLDAP$ */
3 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
4  *
5  * Copyright 2000-2004 The OpenLDAP Foundation.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted only as authorized by the OpenLDAP
10  * Public License.
11  *
12  * A copy of this license is available in the file LICENSE in the
13  * top-level directory of the distribution or, alternatively, at
14  * <http://www.OpenLDAP.org/license.html>.
15  */
16
17 #include "portable.h"
18
19 #include <stdio.h>
20 #include <ac/string.h>
21
22 #define AVL_INTERNAL
23 #include "back-bdb.h"
24 #include "external.h"
25
26 static DBC *cursor = NULL;
27 static DBT key, data;
28
29 typedef struct dn_id {
30         ID id;
31         struct berval dn;
32 } dn_id;
33
34 #define HOLE_SIZE       4096
35 static dn_id hbuf[HOLE_SIZE], *holes = hbuf;
36 static unsigned nhmax = HOLE_SIZE;
37 static unsigned nholes;
38
39 Avlnode *index_attrs, index_dummy;
40
41 int bdb_tool_entry_open(
42         BackendDB *be, int mode )
43 {
44         /* initialize key and data thangs */
45         DBTzero( &key );
46         DBTzero( &data );
47         key.flags = DB_DBT_REALLOC;
48         data.flags = DB_DBT_REALLOC;
49
50         return 0;
51 }
52
53 int bdb_tool_entry_close(
54         BackendDB *be )
55 {
56         assert( be != NULL );
57
58         if( key.data ) {
59                 ch_free( key.data );
60                 key.data = NULL;
61         }
62         if( data.data ) {
63                 ch_free( data.data );
64                 data.data = NULL;
65         }
66
67         if( cursor ) {
68                 cursor->c_close( cursor );
69                 cursor = NULL;
70         }
71
72         if( nholes ) {
73                 unsigned i;
74                 fprintf( stderr, "Error, entries missing!\n");
75                 for (i=0; i<nholes; i++) {
76                         fprintf(stderr, "  entry %ld: %s\n",
77                                 holes[i].id, holes[i].dn.bv_val);
78                 }
79                 return -1;
80         }
81                         
82         return 0;
83 }
84
85 static int bdb_reindex_cmp(const void *a, const void *b) { return 0; }
86
87 ID bdb_tool_entry_next(
88         BackendDB *be )
89 {
90         int rc;
91         ID id;
92         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
93
94         assert( be != NULL );
95         assert( slapMode & SLAP_TOOL_MODE );
96         assert( bdb != NULL );
97         
98         /* Initialization */
99         if (cursor == NULL) {
100                 rc = bdb->bi_id2entry->bdi_db->cursor(
101                         bdb->bi_id2entry->bdi_db, NULL, &cursor,
102                         bdb->bi_db_opflags );
103                 if( rc != 0 ) {
104                         return NOID;
105                 }
106         }
107
108         rc = cursor->c_get( cursor, &key, &data, DB_NEXT );
109
110         if( rc != 0 ) {
111                 /* If we're doing linear indexing and there are more attrs to
112                  * index, and we're at the end of the database, start over.
113                  */
114                 if ( bdb->bi_attrs == &index_dummy ) {
115                         if ( index_attrs && rc == DB_NOTFOUND ) {
116                                 /* optional - do a checkpoint here? */
117                                 index_dummy.avl_data = avl_delete(&index_attrs, NULL, bdb_reindex_cmp);
118                                 rc = cursor->c_get( cursor, &key, &data, DB_FIRST );
119                         }
120                         if ( rc ) {
121                                 bdb->bi_attrs = NULL;
122                                 return NOID;
123                         }
124                 } else {
125                         return NOID;
126                 }
127         }
128
129         if( data.data == NULL ) {
130                 return NOID;
131         }
132
133         AC_MEMCPY( &id, key.data, key.size );
134         return id;
135 }
136
137 ID bdb_tool_dn2id_get(
138         Backend *be,
139         struct berval *dn
140 )
141 {
142         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
143         DB *db = bdb->bi_dn2id->bdi_db;
144         int rc;
145         DBT     key, data;
146         ID      id;
147
148         DBTzero( &key );
149         key.size = dn->bv_len + 2;
150         key.data = ch_malloc( key.size );
151         ((char*)key.data)[0] = DN_BASE_PREFIX;
152         AC_MEMCPY( &((char*)key.data)[1], dn->bv_val, key.size - 1 );
153
154         DBTzero( &data );
155         data.data = &id;
156         data.ulen = sizeof(ID);
157         data.flags = DB_DBT_USERMEM;
158
159         rc = db->get( db, NULL, &key, &data, bdb->bi_db_opflags );
160
161     if( rc != 0 ) {
162 #ifdef NEW_LOGGING
163                 LDAP_LOG ( INDEX, ERR, "bdb_tool_dn2id_get: get failed %s (%d)\n",
164                                 db_strerror(rc), rc, 0 );
165 #else
166                 Debug( LDAP_DEBUG_TRACE, "bdb_tool_dn2id_get: get failed: %s (%d)\n",
167                                 db_strerror( rc ), rc, 0 );
168 #endif
169                 id = NOID;
170         }
171
172         ch_free( key.data );
173         return id;
174 }
175
176 int bdb_tool_id2entry_get(
177         Backend *be,
178         ID id,
179         Entry **e
180 )
181 {
182         return bdb_id2entry( be, NULL, id, e );
183 }
184
185 Entry* bdb_tool_entry_get( BackendDB *be, ID id )
186 {
187         int rc;
188         Entry *e = NULL;
189         struct berval bv;
190
191         assert( be != NULL );
192         assert( slapMode & SLAP_TOOL_MODE );
193         assert( data.data != NULL );
194
195 #ifndef BDB_HIER
196         DBT2bv( &data, &bv );
197
198         rc = entry_decode( &bv, &e );
199
200         if( rc == LDAP_SUCCESS ) {
201                 e->e_id = id;
202         }
203 #else
204         {
205                 EntryInfo *ei = NULL;
206                 Operation op = {0};
207
208                 op.o_bd = be;
209                 op.o_tmpmemctx = NULL;
210                 op.o_tmpmfuncs = &ch_mfuncs;
211
212                 rc = bdb_cache_find_id( &op, NULL, id, &ei, 0, 0, NULL );
213                 if ( rc == LDAP_SUCCESS )
214                         e = ei->bei_e;
215         }
216 #endif
217         return e;
218 }
219
220 static int bdb_tool_next_id(
221         Operation *op,
222         DB_TXN *tid,
223         Entry *e,
224         struct berval *text,
225         int hole )
226 {
227         struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
228         struct berval dn = e->e_name;
229         struct berval ndn = e->e_nname;
230         struct berval pdn, npdn;
231         EntryInfo *ei = NULL;
232         int rc;
233
234         if (ndn.bv_len == 0) return 0;
235
236         rc = bdb_cache_find_ndn( op, tid, &ndn, &ei );
237         if ( ei ) bdb_cache_entryinfo_unlock( ei );
238         if ( rc == DB_NOTFOUND ) {
239                 if ( !be_issuffix( op->o_bd, &ndn ) ) {
240                         dnParent( &dn, &pdn );
241                         dnParent( &ndn, &npdn );
242                         e->e_name = pdn;
243                         e->e_nname = npdn;
244                         rc = bdb_tool_next_id( op, tid, e, text, 1 );
245                         e->e_name = dn;
246                         e->e_nname = ndn;
247                         if ( rc ) {
248                                 return rc;
249                         }
250                 }
251                 rc = bdb_next_id( op->o_bd, tid, &e->e_id );
252                 if ( rc ) {
253                         snprintf( text->bv_val, text->bv_len,
254                                 "next_id failed: %s (%d)",
255                                 db_strerror(rc), rc );
256 #ifdef NEW_LOGGING
257                 LDAP_LOG ( TOOLS, ERR, 
258                         "=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 );
259 #else
260                 Debug( LDAP_DEBUG_ANY,
261                         "=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 );
262 #endif
263                         return rc;
264                 }
265                 rc = bdb_dn2id_add( op, tid, ei, e );
266                 if ( rc ) {
267                         snprintf( text->bv_val, text->bv_len, 
268                                 "dn2id_add failed: %s (%d)",
269                                 db_strerror(rc), rc );
270 #ifdef NEW_LOGGING
271                 LDAP_LOG ( TOOLS, ERR, 
272                         "=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 );
273 #else
274                 Debug( LDAP_DEBUG_ANY,
275                         "=> bdb_tool_next_id: %s\n", text->bv_val, 0, 0 );
276 #endif
277                 } else if ( hole ) {
278                         if ( nholes == nhmax - 1 ) {
279                                 if ( holes == hbuf ) {
280                                         holes = ch_malloc( nhmax * sizeof(dn_id) * 2 );
281                                         AC_MEMCPY( holes, hbuf, sizeof(hbuf) );
282                                 } else {
283                                         holes = ch_realloc( holes, nhmax * sizeof(dn_id) * 2 );
284                                 }
285                                 nhmax *= 2;
286                         }
287                         ber_dupbv( &holes[nholes].dn, &ndn );
288                         holes[nholes++].id = e->e_id;
289                 }
290         } else if ( !hole ) {
291                 unsigned i;
292
293                 e->e_id = ei->bei_id;
294
295                 for ( i=0; i<nholes; i++) {
296                         if ( holes[i].id == e->e_id ) {
297                                 int j;
298                                 free(holes[i].dn.bv_val);
299                                 for (j=i;j<nholes;j++) holes[j] = holes[j+1];
300                                 holes[j].id = 0;
301                                 nholes--;
302                                 break;
303                         } else if ( holes[i].id > e->e_id ) {
304                                 break;
305                         }
306                 }
307         }
308         return rc;
309 }
310
311 ID bdb_tool_entry_put(
312         BackendDB *be,
313         Entry *e,
314         struct berval *text )
315 {
316         int rc;
317         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
318         DB_TXN *tid = NULL;
319         Operation op = {0};
320
321         assert( be != NULL );
322         assert( slapMode & SLAP_TOOL_MODE );
323
324         assert( text );
325         assert( text->bv_val );
326         assert( text->bv_val[0] == '\0' );      /* overconservative? */
327
328 #ifdef NEW_LOGGING
329         LDAP_LOG ( TOOLS, ARGS, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
330                 (long) e->e_id, e->e_dn, 0 );
331 #else
332         Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
333                 (long) e->e_id, e->e_dn, 0 );
334 #endif
335
336         rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid, 
337                 bdb->bi_db_opflags );
338         if( rc != 0 ) {
339                 snprintf( text->bv_val, text->bv_len,
340                         "txn_begin failed: %s (%d)",
341                         db_strerror(rc), rc );
342 #ifdef NEW_LOGGING
343         LDAP_LOG ( TOOLS, ERR, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
344 #else
345                 Debug( LDAP_DEBUG_ANY,
346                         "=> bdb_tool_entry_put: %s\n",
347                          text->bv_val, 0, 0 );
348 #endif
349                 return NOID;
350         }
351
352         op.o_bd = be;
353         op.o_tmpmemctx = NULL;
354         op.o_tmpmfuncs = &ch_mfuncs;
355
356         /* add dn2id indices */
357         rc = bdb_tool_next_id( &op, tid, e, text, 0 );
358         if( rc != 0 ) {
359                 goto done;
360         }
361
362         /* id2entry index */
363         rc = bdb_id2entry_add( be, tid, e );
364         if( rc != 0 ) {
365                 snprintf( text->bv_val, text->bv_len,
366                                 "id2entry_add failed: %s (%d)",
367                                 db_strerror(rc), rc );
368 #ifdef NEW_LOGGING
369                 LDAP_LOG ( TOOLS, ERR, 
370                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
371 #else
372                 Debug( LDAP_DEBUG_ANY,
373                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
374 #endif
375                 goto done;
376         }
377
378         if ( !bdb->bi_linear_index )
379                 rc = bdb_index_entry_add( &op, tid, e );
380         if( rc != 0 ) {
381                 snprintf( text->bv_val, text->bv_len,
382                                 "index_entry_add failed: %s (%d)",
383                                 db_strerror(rc), rc );
384 #ifdef NEW_LOGGING
385                 LDAP_LOG ( TOOLS, ERR, 
386                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
387 #else
388                 Debug( LDAP_DEBUG_ANY,
389                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
390 #endif
391                 goto done;
392         }
393
394 done:
395         if( rc == 0 ) {
396                 rc = TXN_COMMIT( tid, 0 );
397                 if( rc != 0 ) {
398                         snprintf( text->bv_val, text->bv_len,
399                                         "txn_commit failed: %s (%d)",
400                                         db_strerror(rc), rc );
401 #ifdef NEW_LOGGING
402                         LDAP_LOG ( TOOLS, ERR, 
403                                 "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
404 #else
405                         Debug( LDAP_DEBUG_ANY,
406                                 "=> bdb_tool_entry_put: %s\n",
407                                 text->bv_val, 0, 0 );
408 #endif
409                         e->e_id = NOID;
410                 }
411
412         } else {
413                 TXN_ABORT( tid );
414                 snprintf( text->bv_val, text->bv_len,
415                         "txn_aborted! %s (%d)",
416                         db_strerror(rc), rc );
417 #ifdef NEW_LOGGING
418                 LDAP_LOG ( TOOLS, ERR, 
419                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
420 #else
421                 Debug( LDAP_DEBUG_ANY,
422                         "=> bdb_tool_entry_put: %s\n",
423                         text->bv_val, 0, 0 );
424 #endif
425                 e->e_id = NOID;
426         }
427
428         return e->e_id;
429 }
430
431 int bdb_tool_entry_reindex(
432         BackendDB *be,
433         ID id )
434 {
435         struct bdb_info *bi = (struct bdb_info *) be->be_private;
436         int rc;
437         Entry *e;
438         DB_TXN *tid = NULL;
439         Operation op = {0};
440
441 #ifdef NEW_LOGGING
442         LDAP_LOG ( TOOLS, ARGS, 
443                 "=> bdb_tool_entry_reindex( %ld )\n", (long) id, 0, 0 );
444 #else
445         Debug( LDAP_DEBUG_ARGS, "=> bdb_tool_entry_reindex( %ld )\n",
446                 (long) id, 0, 0 );
447 #endif
448
449         /* No indexes configured, nothing to do. Could return an
450          * error here to shortcut things.
451          */
452         if (!bi->bi_attrs) {
453                 return 0;
454         }
455
456         /* Get the first attribute to index */
457         if (bi->bi_linear_index && !index_attrs && bi->bi_attrs != &index_dummy) {
458                 index_attrs = bi->bi_attrs;
459                 bi->bi_attrs = &index_dummy;
460                 index_dummy.avl_data = avl_delete(&index_attrs, NULL, bdb_reindex_cmp);
461         }
462
463         e = bdb_tool_entry_get( be, id );
464
465         if( e == NULL ) {
466 #ifdef NEW_LOGGING
467                 LDAP_LOG ( TOOLS, DETAIL1, 
468                         "bdb_tool_entry_reindex:: could not locate id=%ld\n", 
469                         (long) id, 0, 0 );
470 #else
471                 Debug( LDAP_DEBUG_ANY,
472                         "bdb_tool_entry_reindex:: could not locate id=%ld\n",
473                         (long) id, 0, 0 );
474 #endif
475                 return -1;
476         }
477
478         rc = TXN_BEGIN( bi->bi_dbenv, NULL, &tid, bi->bi_db_opflags );
479         if( rc != 0 ) {
480 #ifdef NEW_LOGGING
481                 LDAP_LOG ( TOOLS, ERR, 
482                         "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n", 
483                         db_strerror(rc), rc, 0 );
484 #else
485                 Debug( LDAP_DEBUG_ANY,
486                         "=> bdb_tool_entry_reindex: txn_begin failed: %s (%d)\n",
487                         db_strerror(rc), rc, 0 );
488 #endif
489                 goto done;
490         }
491         
492         /*
493          * just (re)add them for now
494          * assume that some other routine (not yet implemented)
495          * will zap index databases
496          *
497          */
498
499 #ifdef NEW_LOGGING
500         LDAP_LOG ( TOOLS, ERR, 
501                 "=> bdb_tool_entry_reindex( %ld, \"%s\" )\n", (long) id, e->e_dn, 0 );
502 #else
503         Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_reindex( %ld, \"%s\" )\n",
504                 (long) id, e->e_dn, 0 );
505 #endif
506
507         op.o_bd = be;
508         op.o_tmpmemctx = NULL;
509         op.o_tmpmfuncs = &ch_mfuncs;
510
511 #if 0 /* ndef BDB_HIER */
512         /* add dn2id indices */
513         rc = bdb_dn2id_add( &op, tid, NULL, e );
514         if( rc != 0 && rc != DB_KEYEXIST ) {
515 #ifdef NEW_LOGGING
516                 LDAP_LOG ( TOOLS, ERR, 
517                         "=> bdb_tool_entry_reindex: dn2id_add failed: %s (%d)\n", 
518                         db_strerror(rc), rc, 0 );
519 #else
520                 Debug( LDAP_DEBUG_ANY,
521                         "=> bdb_tool_entry_reindex: dn2id_add failed: %s (%d)\n",
522                         db_strerror(rc), rc, 0 );
523 #endif
524                 goto done;
525         }
526 #endif
527
528         rc = bdb_index_entry_add( &op, tid, e );
529
530 done:
531         if( rc == 0 ) {
532                 rc = TXN_COMMIT( tid, 0 );
533                 if( rc != 0 ) {
534 #ifdef NEW_LOGGING
535                         LDAP_LOG ( TOOLS, ERR, 
536                                 "=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n", 
537                                 db_strerror(rc), rc, 0 );
538 #else
539                         Debug( LDAP_DEBUG_ANY,
540                                 "=> bdb_tool_entry_reindex: txn_commit failed: %s (%d)\n",
541                                 db_strerror(rc), rc, 0 );
542 #endif
543                         e->e_id = NOID;
544                 }
545
546         } else {
547                 TXN_ABORT( tid );
548 #ifdef NEW_LOGGING
549                 LDAP_LOG ( TOOLS, DETAIL1, 
550                         "=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n", 
551                         db_strerror(rc), rc, 0 );
552 #else
553                 Debug( LDAP_DEBUG_ANY,
554                         "=> bdb_tool_entry_reindex: txn_aborted! %s (%d)\n",
555                         db_strerror(rc), rc, 0 );
556 #endif
557                 e->e_id = NOID;
558         }
559         bdb_entry_release( &op, e, 0 );
560
561         return rc;
562 }
563
564 ID bdb_tool_entry_modify(
565         BackendDB *be,
566         Entry *e,
567         struct berval *text )
568 {
569         int rc;
570         struct bdb_info *bdb = (struct bdb_info *) be->be_private;
571         DB_TXN *tid = NULL;
572         Operation op = {0};
573
574         assert( be != NULL );
575         assert( slapMode & SLAP_TOOL_MODE );
576
577         assert( text );
578         assert( text->bv_val );
579         assert( text->bv_val[0] == '\0' );      /* overconservative? */
580
581         assert ( e->e_id != NOID );
582         assert ( e->e_id != 0 );
583
584 #ifdef NEW_LOGGING
585         LDAP_LOG ( TOOLS, ARGS, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
586                 (long) e->e_id, e->e_dn, 0 );
587 #else
588         Debug( LDAP_DEBUG_TRACE, "=> bdb_tool_entry_put( %ld, \"%s\" )\n",
589                 (long) e->e_id, e->e_dn, 0 );
590 #endif
591
592         rc = TXN_BEGIN( bdb->bi_dbenv, NULL, &tid, 
593                 bdb->bi_db_opflags );
594         if( rc != 0 ) {
595                 snprintf( text->bv_val, text->bv_len,
596                         "txn_begin failed: %s (%d)",
597                         db_strerror(rc), rc );
598 #ifdef NEW_LOGGING
599         LDAP_LOG ( TOOLS, ERR, "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
600 #else
601                 Debug( LDAP_DEBUG_ANY,
602                         "=> bdb_tool_entry_put: %s\n",
603                          text->bv_val, 0, 0 );
604 #endif
605                 return NOID;
606         }
607
608         op.o_bd = be;
609         op.o_tmpmemctx = NULL;
610         op.o_tmpmfuncs = &ch_mfuncs;
611
612         /* id2entry index */
613         rc = bdb_id2entry_update( be, tid, e );
614         if( rc != 0 ) {
615                 snprintf( text->bv_val, text->bv_len,
616                                 "id2entry_add failed: %s (%d)",
617                                 db_strerror(rc), rc );
618 #ifdef NEW_LOGGING
619                 LDAP_LOG ( TOOLS, ERR, 
620                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
621 #else
622                 Debug( LDAP_DEBUG_ANY,
623                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
624 #endif
625                 goto done;
626         }
627
628         rc = bdb_index_entry_del( &op, tid, e );
629         if( rc != 0 ) {
630                 snprintf( text->bv_val, text->bv_len,
631                                 "index_entry_del failed: %s (%d)",
632                                 db_strerror(rc), rc );
633 #ifdef NEW_LOGGING
634                 LDAP_LOG ( TOOLS, ERR, 
635                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
636 #else
637                 Debug( LDAP_DEBUG_ANY,
638                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
639 #endif
640                 goto done;
641         }
642
643         rc = bdb_index_entry_add( &op, tid, e );
644         if( rc != 0 ) {
645                 snprintf( text->bv_val, text->bv_len,
646                                 "index_entry_add failed: %s (%d)",
647                                 db_strerror(rc), rc );
648 #ifdef NEW_LOGGING
649                 LDAP_LOG ( TOOLS, ERR, 
650                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
651 #else
652                 Debug( LDAP_DEBUG_ANY,
653                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
654 #endif
655                 goto done;
656         }
657
658 done:
659         if( rc == 0 ) {
660                 rc = TXN_COMMIT( tid, 0 );
661                 if( rc != 0 ) {
662                         snprintf( text->bv_val, text->bv_len,
663                                         "txn_commit failed: %s (%d)",
664                                         db_strerror(rc), rc );
665 #ifdef NEW_LOGGING
666                         LDAP_LOG ( TOOLS, ERR, 
667                                 "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
668 #else
669                         Debug( LDAP_DEBUG_ANY,
670                                 "=> bdb_tool_entry_put: %s\n",
671                                 text->bv_val, 0, 0 );
672 #endif
673                         e->e_id = NOID;
674                 }
675
676         } else {
677                 TXN_ABORT( tid );
678                 snprintf( text->bv_val, text->bv_len,
679                         "txn_aborted! %s (%d)",
680                         db_strerror(rc), rc );
681 #ifdef NEW_LOGGING
682                 LDAP_LOG ( TOOLS, ERR, 
683                         "=> bdb_tool_entry_put: %s\n", text->bv_val, 0, 0 );
684 #else
685                 Debug( LDAP_DEBUG_ANY,
686                         "=> bdb_tool_entry_put: %s\n",
687                         text->bv_val, 0, 0 );
688 #endif
689                 e->e_id = NOID;
690         }
691
692         return e->e_id;
693 }