/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2006 The OpenLDAP Foundation.
+ * Copyright 2000-2007 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Entry* bdb_tool_entry_get( BackendDB *be, ID id )
{
- int rc, off;
+ int rc;
Entry *e = NULL;
- char *dptr;
assert( be != NULL );
assert( slapMode & SLAP_TOOL_MODE );
data.flags ^= DB_DBT_PARTIAL;
data.ulen = 0;
rc = cursor->c_get( cursor, &key, &data, DB_CURRENT );
- if ( rc != ENOMEM ) goto leave;
+ if ( rc != DB_BUFFER_SMALL ) goto leave;
/* Allocate a block and retrieve the data */
eh.bv.bv_len = eh.nvals * sizeof( struct berval ) + data.size;
eh.data += eoff;
rc = cursor->c_get( cursor, &key, &data, DB_CURRENT );
+ if ( rc ) goto leave;
#ifdef SLAP_ZONE_ALLOC
/* FIXME: will add ctx later */
{
struct bdb_info *bdb = (struct bdb_info *) op->o_bd->be_private;
+ if ( !bdb->bi_nattrs )
+ return 0;
+
if ( slapMode & SLAP_TOOL_QUICK ) {
IndexRec *ir;
int i, rc;
int bdb_tool_entry_reindex(
BackendDB *be,
- ID id )
+ ID id,
+ AttributeDescription **adv )
{
struct bdb_info *bi = (struct bdb_info *) be->be_private;
int rc;
return 0;
}
+ /* Check for explicit list of attrs to index */
+ if ( adv ) {
+ int i, j, n;
+
+ /* count */
+ for ( n = 0; adv[n]; n++ ) ;
+
+ /* insertion sort */
+ for ( i = 0; i < n; i++ ) {
+ AttributeDescription *ad = adv[i];
+ for ( j = i-1; j>=0; j--) {
+ if ( SLAP_PTRCMP( adv[j], ad ) <= 0 ) break;
+ adv[j+1] = adv[j];
+ }
+ adv[j+1] = ad;
+ }
+
+ for ( i = 0; adv[i]; i++ ) {
+ if ( bi->bi_attrs[i]->ai_desc != adv[i] ) {
+ for ( j = i+1; j < bi->bi_nattrs; j++ ) {
+ if ( bi->bi_attrs[j]->ai_desc == adv[i] ) {
+ AttrInfo *ai = bi->bi_attrs[i];
+ bi->bi_attrs[i] = bi->bi_attrs[j];
+ bi->bi_attrs[j] = ai;
+ break;
+ }
+ }
+ if ( j == bi->bi_nattrs ) {
+ Debug( LDAP_DEBUG_ANY,
+ LDAP_XSTRING(bdb_tool_entry_reindex)
+ ": no index configured for %s\n",
+ adv[i]->ad_cname.bv_val, 0, 0 );
+ return -1;
+ }
+ }
+ }
+ bi->bi_nattrs = i;
+ }
+
/* Get the first attribute to index */
if (bi->bi_linear_index && !index_nattrs) {
index_nattrs = bi->bi_nattrs - 1;