]> git.sur5r.net Git - openldap/commitdiff
Re-introduce hdb dup_compare function, default compares too much
authorHoward Chu <hyc@openldap.org>
Thu, 6 Dec 2007 15:58:47 +0000 (15:58 +0000)
committerHoward Chu <hyc@openldap.org>
Thu, 6 Dec 2007 15:58:47 +0000 (15:58 +0000)
servers/slapd/back-bdb/dn2id.c
servers/slapd/back-bdb/init.c
servers/slapd/back-bdb/proto-bdb.h

index c360e4cb8f6b86c28506fca323da19ee2c309e9c..1f5f75cef040f54b547b130033f381b254ac0f1b 100644 (file)
@@ -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(
index 3d9d89d95dab38dc0f4e308f36a1c051fe8ad6ea..552540112fbb2459444becfc78e24d9c2e41d352 100644 (file)
@@ -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 {
index d1691b0808d0269de28b2289337d06f017b9031f..8e39be0cec44a1d6ab2b06c94ca3389cf03c8224 100644 (file)
@@ -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