/* $OpenLDAP$ */
/* This work is part of OpenLDAP Software <http://www.openldap.org/>.
*
- * Copyright 2000-2012 The OpenLDAP Foundation.
+ * Copyright 2000-2013 The OpenLDAP Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
int
mdb_idl_insert_keys(
+ BackendDB *be,
MDB_cursor *cursor,
struct berval *keys,
ID id )
{
+ struct mdb_info *mdb = be->be_private;
MDB_val key, data;
ID lo, hi, *i;
char *err;
- int rc, k;
+ int rc = 0, k;
unsigned int flag = MDB_NODUPDATA;
#ifndef MISALIGNED_OK
int kbuf[2];
assert( id != NOID );
#ifndef MISALIGNED_OK
- if (keys[0].bv_len & 0x03)
+ if (keys[0].bv_len & ALIGNER)
kbuf[1] = 0;
#endif
for ( k=0; keys[k].bv_val; k++ ) {
* exists and if it's a range.
*/
#ifndef MISALIGNED_OK
- if (keys[k].bv_len & 0x03) {
+ if (keys[k].bv_len & ALIGNER) {
key.mv_size = sizeof(kbuf);
key.mv_data = kbuf;
memcpy(key.mv_data, keys[k].bv_val, keys[k].bv_len);
}
} else {
/* There's room, just store it */
- if ( slapMode & SLAP_TOOL_QUICK )
- flag |= MDB_APPEND;
+ if (id == mdb->mi_nextid)
+ flag |= MDB_APPENDDUP;
goto put1;
}
} else {
}
}
} else if ( rc == MDB_NOTFOUND ) {
+ flag &= ~MDB_APPENDDUP;
put1: data.mv_data = &id;
data.mv_size = sizeof(ID);
rc = mdb_cursor_put( cursor, &key, &data, flag );
int
mdb_idl_delete_keys(
+ BackendDB *be,
MDB_cursor *cursor,
struct berval *keys,
ID id )
{
- int rc, k;
+ int rc = 0, k;
MDB_val key, data;
ID lo, hi, tmp, *i;
char *err;
assert( id != NOID );
#ifndef MISALIGNED_OK
- if (keys[0].bv_len & 0x03)
+ if (keys[0].bv_len & ALIGNER)
kbuf[1] = 0;
#endif
for ( k=0; keys[k].bv_val; k++) {
* exists and if it's a range.
*/
#ifndef MISALIGNED_OK
- if (keys[k].bv_len & 0x03) {
+ if (keys[k].bv_len & ALIGNER) {
key.mv_size = sizeof(kbuf);
key.mv_data = kbuf;
memcpy(key.mv_data, keys[k].bv_val, keys[k].bv_len);
/* 8 bit Radix sort + insertion sort
*
* based on code from http://www.cubic.org/docs/radix.htm
- * with improvements by mbackes@symas.com and hyc@symas.com
+ * with improvements by ebackes@symas.com and hyc@symas.com
*
* This code is O(n) but has a relatively high constant factor. For lists
* up to ~50 Quicksort is slightly faster; up to ~100 they are even.