Просмотр исходного кода

Resolves: #471998
Summary: dbverify: support integer type index
Description:
1) changed dblayer_bt_compare to public (proto-back-ldbm.h, dblayer.c)
2) set dblayer_bt_compare by dbp->set_bt_compare if the attribute has a
comparison function set in ai->ai_key_cmp_fn (dbverify.c)
3) cleaned up the function dbverify_ext; set the right page size based upon the
idl type (new idl or old idl), also set dup compare function only when the idl
type is new. (dbverify.c)

Noriko Hosoi 17 лет назад
Родитель
Сommit
50a963bba7

+ 1 - 1
ldap/servers/slapd/back-ldbm/dblayer.c

@@ -243,7 +243,7 @@ static int dblayer_db_remove_ex(dblayer_private_env *env, char const path[], cha
 
    see also DBTcmp
 */
-static int
+int
 dblayer_bt_compare(DB *db, const DBT *dbt1, const DBT *dbt2)
 {
     struct berval bv1, bv2;

+ 52 - 10
ldap/servers/slapd/back-ldbm/dbverify.c

@@ -111,25 +111,67 @@ dbverify_ext( ldbm_instance *inst, int verbose )
                         "Unable to create id2entry db file %d\n", rval);
             return rval;
         }
+
 #define VLVPREFIX "vlv#"
-        if ((0 != strncmp(direntry->name, ID2ENTRY, strlen(ID2ENTRY))) &&
-            (0 != strncmp(direntry->name, VLVPREFIX, strlen(VLVPREFIX))))
+        if (0 != strncmp(direntry->name, ID2ENTRY, strlen(ID2ENTRY)))
         {
-            rval = dbp->set_flags(dbp, DB_DUP | DB_DUPSORT);
-            if (0 != rval)
+            struct attrinfo *ai = NULL;
+            char *p = NULL;
+            p = strstr(filep, LDBM_FILENAME_SUFFIX); /* since already checked,
+                                                        it must have it */
+            *p = '\0';
+            ainfo_get( inst->inst_be, filep+1, &ai );
+            *p = '.';
+            if (ai->ai_key_cmp_fn) {
+                dbp->app_private = (void *)ai->ai_key_cmp_fn;
+                dbp->set_bt_compare(dbp, dblayer_bt_compare);
+            }
+            if (idl_get_idl_new())
             {
-                slapi_log_error(SLAPI_LOG_FATAL, "DB verify",
-                       "Unable to set DUP flags to db %d\n", rval);
-                return rval;
+                rval = dbp->set_pagesize(dbp,
+                        (priv->dblayer_index_page_size == 0) ?
+                        DBLAYER_INDEX_PAGESIZE : priv->dblayer_index_page_size);
+            }
+            else
+            {
+                rval = dbp->set_pagesize(dbp,
+                        (priv->dblayer_page_size == 0) ?
+                        DBLAYER_PAGESIZE : priv->dblayer_page_size);
             }
-
-            rval = dbp->set_dup_compare(dbp, idl_new_compare_dups);
             if (0 != rval)
             {
                 slapi_log_error(SLAPI_LOG_FATAL, "DB verify",
-                       "Unable to set dup_compare to db %d\n", rval);
+                         "Unable to set pagesize flags to db (%d)\n", rval);
                 return rval;
             }
+            if (0 == strncmp(direntry->name, VLVPREFIX, strlen(VLVPREFIX)))
+            {
+                rval = dbp->set_flags(dbp, DB_RECNUM);
+                if (0 != rval)
+                {
+                    slapi_log_error(SLAPI_LOG_FATAL, "DB verify",
+                         "Unable to set RECNUM flag to vlv index (%d)\n", rval);
+                    return rval;
+                }
+            }
+            else if (idl_get_idl_new())
+            {
+                rval = dbp->set_flags(dbp, DB_DUP | DB_DUPSORT);
+                if (0 != rval)
+                {
+                    slapi_log_error(SLAPI_LOG_FATAL, "DB verify",
+                           "Unable to set DUP flags to db (%d)\n", rval);
+                    return rval;
+                }
+    
+                rval = dbp->set_dup_compare(dbp, idl_new_compare_dups);
+                if (0 != rval)
+                {
+                    slapi_log_error(SLAPI_LOG_FATAL, "DB verify",
+                           "Unable to set dup_compare to db (%d)\n", rval);
+                    return rval;
+                }
+            }
         }
 #undef VLVPREFIX
         rval = dbp->verify(dbp, dbdir, NULL, NULL, 0);

+ 2 - 0
ldap/servers/slapd/back-ldbm/proto-back-ldbm.h

@@ -170,6 +170,8 @@ int dblayer_db_uses_locking(DB_ENV *db_env);
 int dblayer_db_uses_transactions(DB_ENV *db_env);
 int dblayer_db_uses_mpool(DB_ENV *db_env);
 int dblayer_db_uses_logging(DB_ENV *db_env);
+int dblayer_bt_compare(DB *db, const DBT *dbt1, const DBT *dbt2);
+
 
 /*
  * dn2entry.c