Skip to content
Snippets Groups Projects
Commit e237f4cc authored by Howard Chu's avatar Howard Chu
Browse files

Re-introduce hdb dup_compare function, default compares too much

parent f06fdb28
No related branches found
No related tags found
No related merge requests found
......@@ -451,6 +451,31 @@ typedef struct diskNode {
unsigned char entryID[sizeof(ID)]; /* variable placement */
} diskNode;
/* Sort function for the sorted duplicate data items of a dn2id key.
* Sorts based on normalized RDN, in length order.
*/
int
hdb_dup_compare(
DB *db,
const DBT *usrkey,
const DBT *curkey
)
{
diskNode *un, *cn;
int rc, ul, cl;
un = (diskNode *)usrkey->data;
cn = (diskNode *)curkey->data;
/* data is not aligned, cannot compare directly */
ul = un->nrdnlen[0] << 8 | un->nrdnlen[1];
cl = cn->nrdnlen[0] << 8 | cn->nrdnlen[1];
rc = ul - cl;
if( rc ) return rc;
return strcmp( un->nrdn, cn->nrdn );
}
/* This function constructs a full DN for a given entry.
*/
int hdb_fix_dn(
......
......@@ -412,6 +412,8 @@ shm_retry:
flags |= DB_CREATE;
}
#else
rc = db->bdi_db->set_dup_compare( db->bdi_db,
bdb_dup_compare );
if ( slapMode & (SLAP_TOOL_READONLY|SLAP_TOOL_READMAIN) ) {
flags |= DB_RDONLY;
} else {
......
......@@ -129,6 +129,7 @@ int bdb_dn2idl(
#ifdef BDB_HIER
#define bdb_dn2id_parent BDB_SYMBOL(dn2id_parent)
#define bdb_dup_compare BDB_SYMBOL(dup_compare)
#define bdb_fix_dn BDB_SYMBOL(fix_dn)
int bdb_dn2id_parent(
......@@ -137,6 +138,11 @@ int bdb_dn2id_parent(
EntryInfo *ei,
ID *idp );
int bdb_dup_compare(
DB *db,
const DBT *usrkey,
const DBT *curkey );
int bdb_fix_dn( Entry *e, int checkit );
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment