]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/back-mdb/init.c
Merge remote-tracking branch 'origin/mdb.RE/0.9'
[openldap] / servers / slapd / back-mdb / init.c
index 7ccdd67b8f0cc143f816e3cc495f670d736782f1..e2f26eb295c2008f6c500d961070e1be39d0daf3 100644 (file)
@@ -2,7 +2,7 @@
 /* $OpenLDAP$ */
 /* This work is part of OpenLDAP Software <http://www.openldap.org/>.
  *
- * Copyright 2000-2013 The OpenLDAP Foundation.
+ * Copyright 2000-2015 The OpenLDAP Foundation.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -176,18 +176,18 @@ mdb_db_open( BackendDB *be, ConfigReply *cr )
 
        if ( rc ) {
                Debug( LDAP_DEBUG_ANY,
-                       LDAP_XSTRING(mdb_db_open) ": database \"%s\" cannot be opened, err %d. "
+                       LDAP_XSTRING(mdb_db_open) ": database \"%s\" cannot be opened: %s (%d). "
                        "Restore from backup!\n",
-                       be->be_suffix[0].bv_val, rc, 0 );
+                       be->be_suffix[0].bv_val, mdb_strerror(rc), rc );
                goto fail;
        }
 
        rc = mdb_txn_begin( mdb->mi_dbenv, NULL, flags & MDB_RDONLY, &txn );
        if ( rc ) {
                Debug( LDAP_DEBUG_ANY,
-                       LDAP_XSTRING(mdb_db_open) ": database \"%s\" cannot be opened, err %d. "
+                       LDAP_XSTRING(mdb_db_open) ": database \"%s\" cannot be opened: %s (%d). "
                        "Restore from backup!\n",
-                       be->be_suffix[0].bv_val, rc, 0 );
+                       be->be_suffix[0].bv_val, mdb_strerror(rc), rc );
                goto fail;
        }
 
@@ -265,10 +265,15 @@ mdb_db_open( BackendDB *be, ConfigReply *cr )
                goto fail;
        }
 
-       rc = mdb_attr_dbs_open( be, txn, cr );
-       if ( rc ) {
-               mdb_txn_abort( txn );
-               goto fail;
+       /* slapcat doesn't need indexes. avoid a failure if
+        * a configured index wasn't created yet.
+        */
+       if ( !(slapMode & SLAP_TOOL_READONLY) ) {
+               rc = mdb_attr_dbs_open( be, txn, cr );
+               if ( rc ) {
+                       mdb_txn_abort( txn );
+                       goto fail;
+               }
        }
 
        rc = mdb_txn_commit(txn);
@@ -451,6 +456,7 @@ mdb_back_initialize(
        bi->bi_op_search = mdb_search;
 
        bi->bi_op_unbind = 0;
+       bi->bi_op_txn = mdb_txn;
 
        bi->bi_extended = mdb_extended;