2011-09-02 07:52:53 +08:00
|
|
|
/* index.c - routines for dealing with attribute indexes */
|
|
|
|
/* $OpenLDAP$ */
|
|
|
|
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
|
|
|
|
*
|
2012-01-01 23:07:45 +08:00
|
|
|
* Copyright 2000-2012 The OpenLDAP Foundation.
|
2011-09-02 07:52:53 +08:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted only as authorized by the OpenLDAP
|
|
|
|
* Public License.
|
|
|
|
*
|
|
|
|
* A copy of this license is available in the file LICENSE in the
|
|
|
|
* top-level directory of the distribution or, alternatively, at
|
|
|
|
* <http://www.OpenLDAP.org/license.html>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "portable.h"
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include <ac/string.h>
|
|
|
|
#include <ac/socket.h>
|
|
|
|
|
|
|
|
#include "slap.h"
|
|
|
|
#include "back-mdb.h"
|
|
|
|
#include "idl.h"
|
|
|
|
|
|
|
|
/* read a key */
|
|
|
|
int
|
|
|
|
mdb_key_read(
|
|
|
|
Backend *be,
|
|
|
|
MDB_txn *txn,
|
|
|
|
MDB_dbi dbi,
|
|
|
|
struct berval *k,
|
|
|
|
ID *ids,
|
|
|
|
MDB_cursor **saved_cursor,
|
|
|
|
int get_flag
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
MDB_val key;
|
2012-03-09 13:39:31 +08:00
|
|
|
#ifndef MISALIGNED_OK
|
2011-11-09 17:03:14 +08:00
|
|
|
int kbuf[2];
|
|
|
|
#endif
|
2011-09-02 07:52:53 +08:00
|
|
|
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "=> key_read\n", 0, 0, 0 );
|
|
|
|
|
2011-11-09 17:03:14 +08:00
|
|
|
#ifndef MISALIGNED_OK
|
2012-03-09 13:39:31 +08:00
|
|
|
if (k->bv_len & ALIGNER) {
|
2011-11-09 17:03:14 +08:00
|
|
|
key.mv_size = sizeof(kbuf);
|
|
|
|
key.mv_data = kbuf;
|
|
|
|
kbuf[1] = 0;
|
|
|
|
memcpy(kbuf, k->bv_val, k->bv_len);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
key.mv_size = k->bv_len;
|
|
|
|
key.mv_data = k->bv_val;
|
|
|
|
}
|
2011-09-02 07:52:53 +08:00
|
|
|
|
|
|
|
rc = mdb_idl_fetch_key( be, txn, dbi, &key, ids, saved_cursor, get_flag );
|
|
|
|
|
|
|
|
if( rc != LDAP_SUCCESS ) {
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "<= mdb_index_read: failed (%d)\n",
|
|
|
|
rc, 0, 0 );
|
|
|
|
} else {
|
|
|
|
Debug( LDAP_DEBUG_TRACE, "<= mdb_index_read %ld candidates\n",
|
|
|
|
(long) MDB_IDL_N(ids), 0, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|