Back to index

openldap  2.4.31
Functions
key.c File Reference
#include "portable.h"
#include <stdio.h>
#include <ac/string.h>
#include <ac/socket.h>
#include "slap.h"
#include "back-bdb.h"
#include "idl.h"

Go to the source code of this file.

Functions

int bdb_key_read (Backend *be, DB *db, DB_TXN *txn, struct berval *k, ID *ids, DBC **saved_cursor, int get_flag)
int bdb_key_change (Backend *be, DB *db, DB_TXN *txn, struct berval *k, ID id, int op)

Function Documentation

int bdb_key_change ( Backend be,
DB *  db,
DB_TXN *  txn,
struct berval k,
ID  id,
int  op 
)

Definition at line 65 of file key.c.

{
       int    rc;
       DBT    key;

       Debug( LDAP_DEBUG_TRACE, "=> key_change(%s,%lx)\n",
              op == SLAP_INDEX_ADD_OP ? "ADD":"DELETE", (long) id, 0 );

       DBTzero( &key );
       bv2DBT(k,&key);
       key.ulen = key.size;
       key.flags = DB_DBT_USERMEM;

       if (op == SLAP_INDEX_ADD_OP) {
              /* Add values */

#ifdef BDB_TOOL_IDL_CACHING
              if ( slapMode & SLAP_TOOL_QUICK )
                     rc = bdb_tool_idl_add( be, db, txn, &key, id );
              else
#endif
                     rc = bdb_idl_insert_key( be, db, txn, &key, id );
              if ( rc == DB_KEYEXIST ) rc = 0;
       } else {
              /* Delete values */
              rc = bdb_idl_delete_key( be, db, txn, &key, id );
              if ( rc == DB_NOTFOUND ) rc = 0;
       }

       Debug( LDAP_DEBUG_TRACE, "<= key_change %d\n", rc, 0, 0 );

       return rc;
}

Here is the call graph for this function:

int bdb_key_read ( Backend be,
DB *  db,
DB_TXN *  txn,
struct berval k,
ID ids,
DBC **  saved_cursor,
int  get_flag 
)

Definition at line 30 of file key.c.

{
       int rc;
       DBT key;

       Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );

       DBTzero( &key );
       bv2DBT(k,&key);
       key.ulen = key.size;
       key.flags = DB_DBT_USERMEM;

       rc = bdb_idl_fetch_key( be, db, txn, &key, ids, saved_cursor, get_flag );

       if( rc != LDAP_SUCCESS ) {
              Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read: failed (%d)\n",
                     rc, 0, 0 );
       } else {
              Debug( LDAP_DEBUG_TRACE, "<= bdb_index_read %ld candidates\n",
                     (long) BDB_IDL_N(ids), 0, 0 );
       }

       return rc;
}