Browse Source

[1068] intermediate editorial cleanup: change database/db, etc to accessor
throughout the code (with fixing conflicts with the original implementation)

JINMEI Tatuya 13 years ago
parent
commit
8216d5dbe1

+ 24 - 25
src/lib/datasrc/database.cc

@@ -38,10 +38,10 @@ namespace isc {
 namespace datasrc {
 
 DatabaseClient::DatabaseClient(boost::shared_ptr<DatabaseAccessor>
-                               database) :
-    database_(database)
+                               accessor) :
+    accessor_(accessor)
 {
-    if (database_.get() == NULL) {
+    if (!accessor_) {
         isc_throw(isc::InvalidParameter,
                   "No database provided to DatabaseClient");
     }
@@ -49,21 +49,21 @@ DatabaseClient::DatabaseClient(boost::shared_ptr<DatabaseAccessor>
 
 DataSourceClient::FindResult
 DatabaseClient::findZone(const Name& name) const {
-    std::pair<bool, int> zone(database_->getZone(name));
+    std::pair<bool, int> zone(accessor_->getZone(name));
     // Try exact first
     if (zone.first) {
         return (FindResult(result::SUCCESS,
-                           ZoneFinderPtr(new Finder(database_,
+                           ZoneFinderPtr(new Finder(accessor_,
                                                     zone.second, name))));
     }
     // Then super domains
     // Start from 1, as 0 is covered above
     for (size_t i(1); i < name.getLabelCount(); ++i) {
         isc::dns::Name superdomain(name.split(i));
-        zone = database_->getZone(superdomain);
+        zone = accessor_->getZone(superdomain);
         if (zone.first) {
             return (FindResult(result::PARTIALMATCH,
-                               ZoneFinderPtr(new Finder(database_,
+                               ZoneFinderPtr(new Finder(accessor_,
                                                         zone.second,
                                                         superdomain))));
         }
@@ -72,10 +72,9 @@ DatabaseClient::findZone(const Name& name) const {
     return (FindResult(result::NOTFOUND, ZoneFinderPtr()));
 }
 
-DatabaseClient::Finder::Finder(boost::shared_ptr<DatabaseAccessor>
-                               database, int zone_id,
-                               const isc::dns::Name& origin) :
-    database_(database),
+DatabaseClient::Finder::Finder(boost::shared_ptr<DatabaseAccessor> accessor,
+                               int zone_id, const isc::dns::Name& origin) :
+    accessor_(accessor),
     zone_id_(zone_id),
     origin_(origin)
 { }
@@ -183,7 +182,7 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
 
     // Request the context
     DatabaseAccessor::IteratorContextPtr
-        context(database_->getRecords(name, zone_id_));
+        context(accessor_->getRecords(name, zone_id_));
     // It must not return NULL, that's a bug of the implementation
     if (!context) {
         isc_throw(isc::Unexpected, "Iterator context null at " +
@@ -227,7 +226,7 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
                 }
                 addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
                             columns[DatabaseAccessor::RDATA_COLUMN],
-                            *database_);
+                            *accessor_);
             } else if (type != NULL && cur_type == *type) {
                 if (result_rrset &&
                     result_rrset->getType() == isc::dns::RRType::CNAME()) {
@@ -240,7 +239,7 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
                 }
                 addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
                             columns[DatabaseAccessor::RDATA_COLUMN],
-                            *database_);
+                            *accessor_);
             } else if (want_cname && cur_type == isc::dns::RRType::CNAME()) {
                 // There should be no other data, so result_rrset should
                 // be empty.
@@ -250,7 +249,7 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
                 }
                 addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
                             columns[DatabaseAccessor::RDATA_COLUMN],
-                            *database_);
+                            *accessor_);
             } else if (want_dname && cur_type == isc::dns::RRType::DNAME()) {
                 // There should be max one RR of DNAME present
                 if (result_rrset &&
@@ -260,7 +259,7 @@ DatabaseClient::Finder::getRRset(const isc::dns::Name& name,
                 }
                 addOrCreate(result_rrset, name, getClass(), cur_type, cur_ttl,
                             columns[DatabaseAccessor::RDATA_COLUMN],
-                            *database_);
+                            *accessor_);
             } else if (cur_type == isc::dns::RRType::RRSIG()) {
                 // If we get signatures before we get the actual data, we
                 // can't know which ones to keep and which to drop...
@@ -306,7 +305,7 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
     ZoneFinder::Result result_status = SUCCESS;
     std::pair<bool, isc::dns::RRsetPtr> found;
     logger.debug(DBG_TRACE_DETAILED, DATASRC_DATABASE_FIND_RECORDS)
-        .arg(database_->getDBName()).arg(name).arg(type);
+        .arg(accessor_->getDBName()).arg(name).arg(type);
 
     // First, do we have any kind of delegation (NS/DNAME) here?
     const Name origin(getOrigin());
@@ -328,12 +327,12 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
             if (result_rrset->getType() == isc::dns::RRType::NS()) {
                 LOG_DEBUG(logger, DBG_TRACE_DETAILED,
                           DATASRC_DATABASE_FOUND_DELEGATION).
-                    arg(database_->getDBName()).arg(superdomain);
+                    arg(accessor_->getDBName()).arg(superdomain);
                 result_status = DELEGATION;
             } else {
                 LOG_DEBUG(logger, DBG_TRACE_DETAILED,
                           DATASRC_DATABASE_FOUND_DNAME).
-                    arg(database_->getDBName()).arg(superdomain);
+                    arg(accessor_->getDBName()).arg(superdomain);
                 result_status = DNAME;
             }
             // Don't search more
@@ -352,7 +351,7 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
             result_rrset->getType() == isc::dns::RRType::NS()) {
             LOG_DEBUG(logger, DBG_TRACE_DETAILED,
                       DATASRC_DATABASE_FOUND_DELEGATION_EXACT).
-                arg(database_->getDBName()).arg(name);
+                arg(accessor_->getDBName()).arg(name);
             result_status = DELEGATION;
         } else if (result_rrset && type != isc::dns::RRType::CNAME() &&
                    result_rrset->getType() == isc::dns::RRType::CNAME()) {
@@ -364,20 +363,20 @@ DatabaseClient::Finder::find(const isc::dns::Name& name,
         if (records_found) {
             logger.debug(DBG_TRACE_DETAILED,
                          DATASRC_DATABASE_FOUND_NXRRSET)
-                        .arg(database_->getDBName()).arg(name)
+                        .arg(accessor_->getDBName()).arg(name)
                         .arg(getClass()).arg(type);
             result_status = NXRRSET;
         } else {
             logger.debug(DBG_TRACE_DETAILED,
                          DATASRC_DATABASE_FOUND_NXDOMAIN)
-                        .arg(database_->getDBName()).arg(name)
+                        .arg(accessor_->getDBName()).arg(name)
                         .arg(getClass()).arg(type);
             result_status = NXDOMAIN;
         }
     } else {
         logger.debug(DBG_TRACE_DETAILED,
                      DATASRC_DATABASE_FOUND_RRSET)
-                    .arg(database_->getDBName()).arg(*result_rrset);
+                    .arg(accessor_->getDBName()).arg(*result_rrset);
     }
     return (FindResult(result_status, result_rrset));
 }
@@ -472,7 +471,7 @@ private:
 ZoneIteratorPtr
 DatabaseClient::getIterator(const isc::dns::Name& name) const {
     // Get the zone
-    std::pair<bool, int> zone(database_->getZone(name));
+    std::pair<bool, int> zone(accessor_->getZone(name));
     if (!zone.first) {
         // No such zone, can't continue
         isc_throw(DataSourceError, "Zone " + name.toText() +
@@ -481,7 +480,7 @@ DatabaseClient::getIterator(const isc::dns::Name& name) const {
     }
     // Request the context
     DatabaseAccessor::IteratorContextPtr
-        context(database_->getAllRecords(zone.second));
+        context(accessor_->getAllRecords(zone.second));
     // It must not return NULL, that's a bug of the implementation
     if (context == DatabaseAccessor::IteratorContextPtr()) {
         isc_throw(isc::Unexpected, "Iterator context null at " +

+ 9 - 7
src/lib/datasrc/database.h

@@ -361,18 +361,19 @@ public:
          * applications shouldn't need it.
          */
         int zone_id() const { return (zone_id_); }
+
         /**
-         * \brief The database.
+         * \brief The database accessor.
          *
-         * This function provides the database stored inside as
+         * This function provides the database accessor stored inside as
          * passed to the constructor. This is meant for testing purposes and
          * normal applications shouldn't need it.
          */
-        const DatabaseAccessor& database() const {
-            return (*database_);
+        const DatabaseAccessor& getAccessor() const {
+            return (*accessor_);
         }
     private:
-        boost::shared_ptr<DatabaseAccessor> database_;
+        boost::shared_ptr<DatabaseAccessor> accessor_;
         const int zone_id_;
         const isc::dns::Name origin_;
         /**
@@ -417,6 +418,7 @@ public:
                                                      bool want_dname,
                                                      bool want_ns);
     };
+
     /**
      * \brief Find a zone in the database
      *
@@ -453,8 +455,8 @@ public:
     virtual ZoneIteratorPtr getIterator(const isc::dns::Name& name) const;
 
 private:
-    /// \brief Our database.
-    const boost::shared_ptr<DatabaseAccessor> database_;
+    /// \brief The accessor to our database.
+    const boost::shared_ptr<DatabaseAccessor> accessor_;
 };
 
 }

+ 25 - 25
src/lib/datasrc/sqlite3_accessor.cc

@@ -119,7 +119,7 @@ private:
     const char* const desc_;
 };
 
-SQLite3Database::SQLite3Database(const std::string& filename,
+SQLite3Accessor::SQLite3Accessor(const std::string& filename,
                                  const isc::dns::RRClass& rrclass) :
     dbparameters_(new SQLite3Parameters),
     class_(rrclass.toText()),
@@ -224,7 +224,7 @@ checkAndSetupSchema(Initializer* initializer) {
 }
 
 void
-SQLite3Database::open(const std::string& name) {
+SQLite3Accessor::open(const std::string& name) {
     LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_SQLITE_CONNOPEN).arg(name);
     if (dbparameters_->db_ != NULL) {
         // There shouldn't be a way to trigger this anyway
@@ -241,7 +241,7 @@ SQLite3Database::open(const std::string& name) {
     initializer.move(dbparameters_.get());
 }
 
-SQLite3Database::~SQLite3Database() {
+SQLite3Accessor::~SQLite3Accessor() {
     LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_SQLITE_DROPCONN);
     if (dbparameters_->db_ != NULL) {
         close();
@@ -249,7 +249,7 @@ SQLite3Database::~SQLite3Database() {
 }
 
 void
-SQLite3Database::close(void) {
+SQLite3Accessor::close(void) {
     LOG_DEBUG(logger, DBG_TRACE_BASIC, DATASRC_SQLITE_CONNCLOSE);
     if (dbparameters_->db_ == NULL) {
         isc_throw(DataSourceError,
@@ -267,12 +267,12 @@ SQLite3Database::close(void) {
 }
 
 std::pair<bool, int>
-SQLite3Database::getZone(const isc::dns::Name& name) const {
+SQLite3Accessor::getZone(const isc::dns::Name& name) const {
     return (getZone(name.toText()));
 }
 
 std::pair<bool, int>
-SQLite3Database::getZone(const string& name) const {
+SQLite3Accessor::getZone(const string& name) const {
     int rc;
     sqlite3_stmt* const stmt = dbparameters_->statements_[ZONE];
 
@@ -338,31 +338,31 @@ convertToPlainChar(const unsigned char* ucp,
 }
 }
 
-class SQLite3Database::Context : public DatabaseAccessor::IteratorContext {
+class SQLite3Accessor::Context : public DatabaseAccessor::IteratorContext {
 public:
     // Construct an iterator for all records. When constructed this
     // way, the getNext() call will copy all fields
-    Context(const boost::shared_ptr<const SQLite3Database>& database, int id) :
+    Context(const boost::shared_ptr<const SQLite3Accessor>& accessor, int id) :
         iterator_type_(ITT_ALL),
-        database_(database),
+        accessor_(accessor),
         statement_(NULL)
     {
         // We create the statement now and then just keep getting data from it
-        statement_ = prepare(database->dbparameters_->db_,
+        statement_ = prepare(accessor->dbparameters_->db_,
                              text_statements[ITERATE]);
         bindZoneId(id);
     }
 
     // Construct an iterator for records with a specific name. When constructed
     // this way, the getNext() call will copy all fields except name
-    Context(const boost::shared_ptr<const SQLite3Database>& database, int id,
+    Context(const boost::shared_ptr<const SQLite3Accessor>& accessor, int id,
             const isc::dns::Name& name) :
         iterator_type_(ITT_NAME),
-        database_(database),
+        accessor_(accessor),
         statement_(NULL)
     {
         // We create the statement now and then just keep getting data from it
-        statement_ = prepare(database->dbparameters_->db_,
+        statement_ = prepare(accessor->dbparameters_->db_,
                              text_statements[ANY]);
         bindZoneId(id);
         bindName(name);
@@ -385,7 +385,7 @@ public:
         } else if (rc != SQLITE_DONE) {
             isc_throw(DataSourceError,
                       "Unexpected failure in sqlite3_step: " <<
-                      sqlite3_errmsg(database_->dbparameters_->db_));
+                      sqlite3_errmsg(accessor_->dbparameters_->db_));
         }
         return (false);
     }
@@ -406,21 +406,21 @@ private:
     void copyColumn(std::string (&data)[COLUMN_COUNT], int column) {
         data[column] = convertToPlainChar(sqlite3_column_text(statement_,
                                                               column),
-                                          database_->dbparameters_.get());
+                                          accessor_->dbparameters_.get());
     }
 
     void bindZoneId(const int zone_id) {
         if (sqlite3_bind_int(statement_, 1, zone_id) != SQLITE_OK) {
             isc_throw(SQLite3Error, "Could not bind int " << zone_id <<
                       " to SQL statement: " <<
-                      sqlite3_errmsg(database_->dbparameters_->db_));
+                      sqlite3_errmsg(accessor_->dbparameters_->db_));
         }
     }
 
     void bindName(const isc::dns::Name& name) {
         if (sqlite3_bind_text(statement_, 2, name.toText().c_str(), -1,
                               SQLITE_TRANSIENT) != SQLITE_OK) {
-            const char* errmsg = sqlite3_errmsg(database_->dbparameters_->db_);
+            const char* errmsg = sqlite3_errmsg(accessor_->dbparameters_->db_);
             sqlite3_finalize(statement_);
             isc_throw(SQLite3Error, "Could not bind text '" << name <<
                       "' to SQL statement: " << errmsg);
@@ -428,22 +428,22 @@ private:
     }
 
     const IteratorType iterator_type_;
-    boost::shared_ptr<const SQLite3Database> database_;
+    boost::shared_ptr<const SQLite3Accessor> accessor_;
     sqlite3_stmt *statement_;
 };
 
 DatabaseAccessor::IteratorContextPtr
-SQLite3Database::getRecords(const isc::dns::Name& name, int id) const {
+SQLite3Accessor::getRecords(const isc::dns::Name& name, int id) const {
     return (IteratorContextPtr(new Context(shared_from_this(), id, name)));
 }
 
 DatabaseAccessor::IteratorContextPtr
-SQLite3Database::getAllRecords(int id) const {
+SQLite3Accessor::getAllRecords(int id) const {
     return (IteratorContextPtr(new Context(shared_from_this(), id)));
 }
 
 pair<bool, int>
-SQLite3Database::startUpdateZone(const string& zone_name, const bool replace) {
+SQLite3Accessor::startUpdateZone(const string& zone_name, const bool replace) {
     if (dbparameters_->updating_zone) {
         isc_throw(DataSourceError,
                   "duplicate zone update on SQLite3 data source");
@@ -479,7 +479,7 @@ SQLite3Database::startUpdateZone(const string& zone_name, const bool replace) {
 }
 
 void
-SQLite3Database::commitUpdateZone() {
+SQLite3Accessor::commitUpdateZone() {
     if (!dbparameters_->updating_zone) {
         isc_throw(DataSourceError, "committing zone update on SQLite3 "
                   "data source without transaction");
@@ -492,7 +492,7 @@ SQLite3Database::commitUpdateZone() {
 }
 
 void
-SQLite3Database::rollbackUpdateZone() {
+SQLite3Accessor::rollbackUpdateZone() {
     if (!dbparameters_->updating_zone) {
         isc_throw(DataSourceError, "rolling back zone update on SQLite3 "
                   "data source without transaction");
@@ -531,7 +531,7 @@ doUpdate(SQLite3Parameters& dbparams, StatementID stmt_id,
 }
 
 void
-SQLite3Database::addRecordToZone(const vector<string>& columns) {
+SQLite3Accessor::addRecordToZone(const vector<string>& columns) {
     if (!dbparameters_->updating_zone) {
         isc_throw(DataSourceError, "adding record to SQLite3 "
                   "data source without transaction");
@@ -545,7 +545,7 @@ SQLite3Database::addRecordToZone(const vector<string>& columns) {
 }
 
 void
-SQLite3Database::deleteRecordInZone(const vector<string>& params) {
+SQLite3Accessor::deleteRecordInZone(const vector<string>& params) {
     if (!dbparameters_->updating_zone) {
         isc_throw(DataSourceError, "deleting record in SQLite3 "
                   "data source without transaction");

+ 4 - 4
src/lib/datasrc/sqlite3_accessor.h

@@ -53,8 +53,8 @@ struct SQLite3Parameters;
  * According to the design, it doesn't interpret the data in any way, it just
  * provides unified access to the DB.
  */
-class SQLite3Database : public DatabaseAccessor,
-    public boost::enable_shared_from_this<SQLite3Database> {
+class SQLite3Accessor : public DatabaseAccessor,
+    public boost::enable_shared_from_this<SQLite3Accessor> {
 public:
     /**
      * \brief Constructor
@@ -69,14 +69,14 @@ public:
      *     file can contain multiple classes of data, single database can
      *     provide only one class).
      */
-    SQLite3Database(const std::string& filename,
+    SQLite3Accessor(const std::string& filename,
                     const isc::dns::RRClass& rrclass);
     /**
      * \brief Destructor
      *
      * Closes the database.
      */
-    ~SQLite3Database();
+    ~SQLite3Accessor();
 
     /**
      * \brief Look up a zone

+ 4 - 7
src/lib/datasrc/tests/database_unittest.cc

@@ -445,12 +445,12 @@ public:
      * times per test.
      */
     void createClient() {
-        current_database_ = new MockAccessor();
+        current_accessor_ = new MockAccessor();
         client_.reset(new DatabaseClient(shared_ptr<DatabaseAccessor>(
-             current_database_)));
+             current_accessor_)));
     }
     // Will be deleted by client_, just keep the current value for comparison.
-    MockAccessor* current_database_;
+    MockAccessor* current_accessor_;
     shared_ptr<DatabaseClient> client_;
     const std::string database_name_;
 
@@ -465,7 +465,7 @@ public:
         ASSERT_NE(shared_ptr<DatabaseClient::Finder>(), finder) <<
             "Wrong type of finder";
         EXPECT_EQ(42, finder->zone_id());
-        EXPECT_EQ(current_database_, &finder->database());
+        EXPECT_EQ(current_accessor_, &finder->getAccessor());
     }
 
     shared_ptr<DatabaseClient::Finder> getFinder() {
@@ -795,7 +795,6 @@ TEST_F(DatabaseClientTest, find) {
                ZoneFinder::CNAME,
                expected_rdatas_, expected_sig_rdatas_);
 
-
     expected_rdatas_.clear();
     expected_sig_rdatas_.clear();
     expected_rdatas_.push_back("192.0.2.1");
@@ -846,7 +845,6 @@ TEST_F(DatabaseClientTest, find) {
                ZoneFinder::SUCCESS,
                expected_rdatas_, expected_sig_rdatas_);
 
-
     EXPECT_THROW(finder->find(isc::dns::Name("badcname1.example.org."),
                                               isc::dns::RRType::A(),
                                               NULL, ZoneFinder::FIND_DEFAULT),
@@ -889,7 +887,6 @@ TEST_F(DatabaseClientTest, find) {
                                               isc::dns::RRType::A(),
                                               NULL, ZoneFinder::FIND_DEFAULT),
                  std::exception);
-
     EXPECT_THROW(finder->find(isc::dns::Name("dsexception.in.getnext."),
                                               isc::dns::RRType::A(),
                                               NULL, ZoneFinder::FIND_DEFAULT),

+ 128 - 122
src/lib/datasrc/tests/sqlite3_accessor_unittest.cc

@@ -49,75 +49,73 @@ std::string SQLITE_DBFILE_NOTEXIST = TEST_DATA_DIR "/nodir/notexist";
 
 // Opening works (the content is tested in different tests)
 TEST(SQLite3Open, common) {
-    EXPECT_NO_THROW(SQLite3Database db(SQLITE_DBFILE_EXAMPLE,
-                                       RRClass::IN()));
+    EXPECT_NO_THROW(SQLite3Accessor accessor(SQLITE_DBFILE_EXAMPLE,
+                                             RRClass::IN()));
 }
 
 // The file can't be opened
 TEST(SQLite3Open, notExist) {
-    EXPECT_THROW(SQLite3Database db(SQLITE_DBFILE_NOTEXIST,
-                                    RRClass::IN()), SQLite3Error);
+    EXPECT_THROW(SQLite3Accessor accessor(SQLITE_DBFILE_NOTEXIST,
+                                          RRClass::IN()), SQLite3Error);
 }
 
 // It rejects broken DB
 TEST(SQLite3Open, brokenDB) {
-    EXPECT_THROW(SQLite3Database db(SQLITE_DBFILE_BROKENDB,
-                                    RRClass::IN()), SQLite3Error);
+    EXPECT_THROW(SQLite3Accessor accessor(SQLITE_DBFILE_BROKENDB,
+                                          RRClass::IN()), SQLite3Error);
 }
 
 // Test we can create the schema on the fly
 TEST(SQLite3Open, memoryDB) {
-    EXPECT_NO_THROW(SQLite3Database db(SQLITE_DBFILE_MEMORY,
-                                       RRClass::IN()));
+    EXPECT_NO_THROW(SQLite3Accessor accessor(SQLITE_DBFILE_MEMORY,
+                                             RRClass::IN()));
 }
 
 // Test fixture for querying the db
-class SQLite3Access : public ::testing::Test {
+class SQLite3AccessorTest : public ::testing::Test {
 public:
-    SQLite3Access() {
+    SQLite3AccessorTest() {
         initAccessor(SQLITE_DBFILE_EXAMPLE, RRClass::IN());
     }
     // So it can be re-created with different data
     void initAccessor(const std::string& filename, const RRClass& rrclass) {
-        db.reset(new SQLite3Database(filename, rrclass));
+        accessor.reset(new SQLite3Accessor(filename, rrclass));
     }
-    // The tested db
-    boost::shared_ptr<SQLite3Database> db;
+    // The tested accessor
+    boost::shared_ptr<SQLite3Accessor> accessor;
 };
 
 // This zone exists in the data, so it should be found
-TEST_F(SQLite3Access, getZone) {
-    std::pair<bool, int> result(db->getZone(Name("example.com")));
+TEST_F(SQLite3AccessorTest, getZone) {
+    std::pair<bool, int> result(accessor->getZone(Name("example.com")));
     EXPECT_TRUE(result.first);
     EXPECT_EQ(1, result.second);
 }
 
 // But it should find only the zone, nothing below it
-TEST_F(SQLite3Access, subZone) {
-    EXPECT_FALSE(db->getZone(Name("sub.example.com")).first);
+TEST_F(SQLite3AccessorTest, subZone) {
+    EXPECT_FALSE(accessor->getZone(Name("sub.example.com")).first);
 }
 
 // This zone is not there at all
-TEST_F(SQLite3Access, noZone) {
-    EXPECT_FALSE(db->getZone(Name("example.org")).first);
+TEST_F(SQLite3AccessorTest, noZone) {
+    EXPECT_FALSE(accessor->getZone(Name("example.org")).first);
 }
 
 // This zone is there, but in different class
-TEST_F(SQLite3Access, noClass) {
+TEST_F(SQLite3AccessorTest, noClass) {
     initAccessor(SQLITE_DBFILE_EXAMPLE, RRClass::CH());
-    EXPECT_FALSE(db->getZone(Name("example.com")).first);
+    EXPECT_FALSE(accessor->getZone(Name("example.com")).first);
 }
 
 // This tests the iterator context
-TEST_F(SQLite3Access, iterator) {
+TEST_F(SQLite3AccessorTest, iterator) {
     // Our test zone is conveniently small, but not empty
     initAccessor(SQLITE_DBFILE_EXAMPLE2, RRClass::IN());
 
     // Get the iterator context
-    DatabaseAccessor::IteratorContextPtr
-        context(db->getAllRecords(1));
-    ASSERT_NE(DatabaseAccessor::IteratorContextPtr(),
-              context);
+    DatabaseAccessor::IteratorContextPtr context(accessor->getAllRecords(1));
+    ASSERT_NE(DatabaseAccessor::IteratorContextPtr(), context);
 
     const size_t size(5);
     std::string data[size];
@@ -132,13 +130,13 @@ TEST_F(SQLite3Access, iterator) {
     EXPECT_FALSE(context->getNext(data));
 }
 
-TEST_F(SQLite3Access, iteratorColumnCount) {
+TEST_F(SQLite3AccessorTest, iteratorColumnCount) {
     // Our test zone is conveniently small, but not empty
     initAccessor(SQLITE_DBFILE_EXAMPLE2, RRClass::IN());
 
     // Get the iterator context
     DatabaseAccessor::IteratorContextPtr
-        context(db->getAllRecords(1));
+        context(accessor->getAllRecords(1));
     ASSERT_NE(DatabaseAccessor::IteratorContextPtr(),
               context);
 
@@ -147,13 +145,13 @@ TEST_F(SQLite3Access, iteratorColumnCount) {
 }
 
 TEST(SQLite3Open, getDBNameExample2) {
-    SQLite3Database db(SQLITE_DBFILE_EXAMPLE2, RRClass::IN());
-    EXPECT_EQ(SQLITE_DBNAME_EXAMPLE2, db.getDBName());
+    SQLite3Accessor accessor(SQLITE_DBFILE_EXAMPLE2, RRClass::IN());
+    EXPECT_EQ(SQLITE_DBNAME_EXAMPLE2, accessor.getDBName());
 }
 
 TEST(SQLite3Open, getDBNameExampleROOT) {
-    SQLite3Database db(SQLITE_DBFILE_EXAMPLE_ROOT, RRClass::IN());
-    EXPECT_EQ(SQLITE_DBNAME_EXAMPLE_ROOT, db.getDBName());
+    SQLite3Accessor accessor(SQLITE_DBFILE_EXAMPLE_ROOT, RRClass::IN());
+    EXPECT_EQ(SQLITE_DBNAME_EXAMPLE_ROOT, accessor.getDBName());
 }
 
 // Simple function to cound the number of records for
@@ -173,8 +171,9 @@ checkRecordRow(const std::string columns[],
     EXPECT_EQ(field4, columns[4]);
 }
 
-TEST_F(SQLite3Access, getRecords) {
-    const std::pair<bool, int> zone_info(db->getZone(Name("example.com")));
+TEST_F(SQLite3AccessorTest, getRecords) {
+    const std::pair<bool, int> zone_info(
+        accessor->getZone(Name("example.com")));
     ASSERT_TRUE(zone_info.first);
 
     const int zone_id = zone_info.second;
@@ -184,14 +183,14 @@ TEST_F(SQLite3Access, getRecords) {
     std::string columns[column_count];
 
     DatabaseAccessor::IteratorContextPtr
-        context(db->getRecords(Name("foo.bar"), 1));
+        context(accessor->getRecords(Name("foo.bar"), 1));
     ASSERT_NE(DatabaseAccessor::IteratorContextPtr(),
               context);
     EXPECT_FALSE(context->getNext(columns));
     checkRecordRow(columns, "", "", "", "", "");
 
     // now try some real searches
-    context = db->getRecords(Name("foo.example.com."), zone_id);
+    context = accessor->getRecords(Name("foo.example.com."), zone_id);
     ASSERT_TRUE(context->getNext(columns));
     checkRecordRow(columns, "CNAME", "3600", "",
                    "cnametest.example.org.", "");
@@ -207,12 +206,13 @@ TEST_F(SQLite3Access, getRecords) {
                    "NSEC 5 3 7200 20100322084538 20100220084538 33495 "
                    "example.com. FAKEFAKEFAKEFAKE", "");
     EXPECT_FALSE(context->getNext(columns));
+
     // with no more records, the array should not have been modified
     checkRecordRow(columns, "RRSIG", "7200", "NSEC",
                    "NSEC 5 3 7200 20100322084538 20100220084538 33495 "
                    "example.com. FAKEFAKEFAKEFAKE", "");
 
-    context = db->getRecords(Name("example.com."), zone_id);
+    context = accessor->getRecords(Name("example.com."), zone_id);
     ASSERT_TRUE(context->getNext(columns));
     checkRecordRow(columns, "SOA", "3600", "",
                    "master.example.com. admin.example.com. "
@@ -296,17 +296,17 @@ const char* const deleted_data[] = {
     "foo.bar.example.com.", "A", "192.0.2.1"
 };
 
-class SQLite3Update : public SQLite3Access {
+class SQLite3Update : public SQLite3AccessorTest {
 protected:
     SQLite3Update() {
         ASSERT_EQ(0, system(INSTALL_PROG " " TEST_DATA_DIR
                             "/test.sqlite3 "
                             TEST_DATA_BUILDDIR "/test.sqlite3.copied"));
         initAccessor(TEST_DATA_BUILDDIR "/test.sqlite3.copied", RRClass::IN());
-        zone_id = db->getZone(Name("example.com")).second;
-        another_db.reset(new SQLite3Database(
-                             TEST_DATA_BUILDDIR "/test.sqlite3.copied",
-                             RRClass::IN()));
+        zone_id = accessor->getZone(Name("example.com")).second;
+        another_accessor.reset(new SQLite3Accessor(
+                                   TEST_DATA_BUILDDIR "/test.sqlite3.copied",
+                                   RRClass::IN()));
         expected_stored.push_back(common_expected_data);
     }
 
@@ -318,16 +318,16 @@ protected:
     vector<const char* const*> empty_stored; // indicate no corresponding data
 
     // Another accessor, emulating one running on a different process/thread
-    shared_ptr<SQLite3Database> another_db;
+    shared_ptr<SQLite3Accessor> another_accessor;
     DatabaseAccessor::IteratorContextPtr iterator;
 };
 
 void
-checkRecords(SQLite3Database& db, int zone_id, const std::string& name,
+checkRecords(SQLite3Accessor& accessor, int zone_id, const std::string& name,
              vector<const char* const*> expected_rows)
 {
     DatabaseAccessor::IteratorContextPtr iterator =
-        db.getRecords(Name(name), zone_id);
+        accessor.getRecords(Name(name), zone_id);
     std::string columns[DatabaseAccessor::COLUMN_COUNT];
     vector<const char* const*>::const_iterator it = expected_rows.begin();
     while (iterator->getNext(columns)) {
@@ -342,45 +342,46 @@ TEST_F(SQLite3Update, emptyUpdate) {
     // If we do nothing between start and commit, the zone content
     // should be intact.
 
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
-    zone_id = db->startUpdateZone("example.com.", false).second;
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
-    db->commitUpdateZone();
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
+    accessor->commitUpdateZone();
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 }
 
 TEST_F(SQLite3Update, flushZone) {
     // With 'replace' being true startUpdateZone() will flush the existing
     // zone content.
 
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
-    zone_id = db->startUpdateZone("example.com.", true).second;
-    checkRecords(*db, zone_id, "foo.bar.example.com.", empty_stored);
-    db->commitUpdateZone();
-    checkRecords(*db, zone_id, "foo.bar.example.com.", empty_stored);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
+    zone_id = accessor->startUpdateZone("example.com.", true).second;
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
+    accessor->commitUpdateZone();
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
 }
 
 TEST_F(SQLite3Update, readWhileUpdate) {
-    zone_id = db->startUpdateZone("example.com.", true).second;
-    checkRecords(*db, zone_id, "foo.bar.example.com.", empty_stored);
+    zone_id = accessor->startUpdateZone("example.com.", true).second;
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
 
     // Until commit is done, the other accessor should see the old data
-    checkRecords(*another_db, zone_id, "foo.bar.example.com.",
+    checkRecords(*another_accessor, zone_id, "foo.bar.example.com.",
                  expected_stored);
 
     // Once the changes are committed, the other accessor will see the new
     // data.
-    db->commitUpdateZone();
-    checkRecords(*another_db, zone_id, "foo.bar.example.com.", empty_stored);
+    accessor->commitUpdateZone();
+    checkRecords(*another_accessor, zone_id, "foo.bar.example.com.",
+                 empty_stored);
 }
 
 TEST_F(SQLite3Update, rollback) {
-    zone_id = db->startUpdateZone("example.com.", true).second;
-    checkRecords(*db, zone_id, "foo.bar.example.com.", empty_stored);
+    zone_id = accessor->startUpdateZone("example.com.", true).second;
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
 
     // Rollback will revert the change made by startUpdateZone(, true).
-    db->rollbackUpdateZone();
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    accessor->rollbackUpdateZone();
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 }
 
 TEST_F(SQLite3Update, rollbackFailure) {
@@ -389,27 +390,27 @@ TEST_F(SQLite3Update, rollbackFailure) {
     // the rollback operation at the end of the test.
 
     string columns[DatabaseAccessor::COLUMN_COUNT];
-    iterator = db->getRecords(Name("example.com"), zone_id);
+    iterator = accessor->getRecords(Name("example.com"), zone_id);
     EXPECT_TRUE(iterator->getNext(columns));
 
-    db->startUpdateZone("example.com.", true);
-    EXPECT_THROW(db->rollbackUpdateZone(), DataSourceError);
+    accessor->startUpdateZone("example.com.", true);
+    EXPECT_THROW(accessor->rollbackUpdateZone(), DataSourceError);
 }
 
 TEST_F(SQLite3Update, commitConflict) {
     // Start reading the DB by another accessor.  We should stop at a single
     // call to getNextRecord() to keep holding the lock.
-    iterator = another_db->getRecords(Name("foo.example.com"), zone_id);
+    iterator = another_accessor->getRecords(Name("foo.example.com"), zone_id);
     EXPECT_TRUE(iterator->getNext(get_columns));
 
     // Due to getNextRecord() above, the other accessor holds a DB lock,
     // which will prevent commit.
-    zone_id = db->startUpdateZone("example.com.", true).second;
-    checkRecords(*db, zone_id, "foo.bar.example.com.", empty_stored);
-    EXPECT_THROW(db->commitUpdateZone(), DataSourceError);
-    db->rollbackUpdateZone();   // rollback should still succeed
+    zone_id = accessor->startUpdateZone("example.com.", true).second;
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
+    EXPECT_THROW(accessor->commitUpdateZone(), DataSourceError);
+    accessor->rollbackUpdateZone();   // rollback should still succeed
 
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 }
 
 TEST_F(SQLite3Update, updateConflict) {
@@ -417,54 +418,57 @@ TEST_F(SQLite3Update, updateConflict) {
     // update attempt.  Note that these two accessors modify disjoint sets
     // of data; sqlite3 only has a coarse-grained lock so we cannot allow
     // these updates to run concurrently.
-    EXPECT_TRUE(another_db->startUpdateZone("sql1.example.com.", true).first);
-    EXPECT_THROW(db->startUpdateZone("example.com.", true), DataSourceError);
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    EXPECT_TRUE(another_accessor->startUpdateZone("sql1.example.com.",
+                                                  true).first);
+    EXPECT_THROW(accessor->startUpdateZone("example.com.", true),
+                 DataSourceError);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 }
 
 TEST_F(SQLite3Update, duplicateUpdate) {
-    db->startUpdateZone("example.com.", false);
-    EXPECT_THROW(db->startUpdateZone("example.com.", false), DataSourceError);
+    accessor->startUpdateZone("example.com.", false);
+    EXPECT_THROW(accessor->startUpdateZone("example.com.", false),
+                 DataSourceError);
 }
 
 TEST_F(SQLite3Update, commitWithoutTransaction) {
-    EXPECT_THROW(db->commitUpdateZone(), DataSourceError);
+    EXPECT_THROW(accessor->commitUpdateZone(), DataSourceError);
 }
 
 TEST_F(SQLite3Update, rollbackWithoutTransaction) {
-    EXPECT_THROW(db->rollbackUpdateZone(), DataSourceError);
+    EXPECT_THROW(accessor->rollbackUpdateZone(), DataSourceError);
 }
 
 TEST_F(SQLite3Update, addRecord) {
     // Before update, there should be no record for this name
-    checkRecords(*db, zone_id, "newdata.example.com.", empty_stored);
+    checkRecords(*accessor, zone_id, "newdata.example.com.", empty_stored);
 
-    zone_id = db->startUpdateZone("example.com.", false).second;
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
     update_columns.assign(new_data,
                           new_data + DatabaseAccessor::ADD_COLUMN_COUNT);
-    db->addRecordToZone(update_columns);
+    accessor->addRecordToZone(update_columns);
 
     expected_stored.clear();
     expected_stored.push_back(new_data);
-    checkRecords(*db, zone_id, "newdata.example.com.", expected_stored);
+    checkRecords(*accessor, zone_id, "newdata.example.com.", expected_stored);
 
     // Commit the change, and confirm the new data is still there.
-    db->commitUpdateZone();
-    checkRecords(*db, zone_id, "newdata.example.com.", expected_stored);
+    accessor->commitUpdateZone();
+    checkRecords(*accessor, zone_id, "newdata.example.com.", expected_stored);
 }
 
 TEST_F(SQLite3Update, addThenRollback) {
-    zone_id = db->startUpdateZone("example.com.", false).second;
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
     update_columns.assign(new_data,
                           new_data + DatabaseAccessor::ADD_COLUMN_COUNT);
-    db->addRecordToZone(update_columns);
+    accessor->addRecordToZone(update_columns);
 
     expected_stored.clear();
     expected_stored.push_back(new_data);
-    checkRecords(*db, zone_id, "newdata.example.com.", expected_stored);
+    checkRecords(*accessor, zone_id, "newdata.example.com.", expected_stored);
 
-    db->rollbackUpdateZone();
-    checkRecords(*db, zone_id, "newdata.example.com.", empty_stored);
+    accessor->rollbackUpdateZone();
+    checkRecords(*accessor, zone_id, "newdata.example.com.", empty_stored);
 }
 
 TEST_F(SQLite3Update, duplicateAdd) {
@@ -474,103 +478,105 @@ TEST_F(SQLite3Update, duplicateAdd) {
     };
     expected_stored.clear();
     expected_stored.push_back(dup_data);
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 
     // Adding exactly the same data.  As this backend is "dumb", another
     // row of the same content will be inserted.
     update_columns.assign(dup_data,
                           dup_data + DatabaseAccessor::ADD_COLUMN_COUNT);
-    zone_id = db->startUpdateZone("example.com.", false).second;
-    db->addRecordToZone(update_columns);
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
+    accessor->addRecordToZone(update_columns);
     expected_stored.push_back(dup_data);
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 }
 
 TEST_F(SQLite3Update, invalidAdd) {
     // An attempt of add before an explicit start of transaction
-    EXPECT_THROW(db->addRecordToZone(update_columns), DataSourceError);
+    EXPECT_THROW(accessor->addRecordToZone(update_columns), DataSourceError);
 
     // Short column vector
     update_columns.clear();
-    zone_id = db->startUpdateZone("example.com.", false).second;
-    EXPECT_THROW(db->addRecordToZone(update_columns), DataSourceError);
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
+    EXPECT_THROW(accessor->addRecordToZone(update_columns), DataSourceError);
 
     // Too many columns
     for (int i = 0; i < DatabaseAccessor::ADD_COLUMN_COUNT + 1; ++i) {
         update_columns.push_back("");
     }
-    EXPECT_THROW(db->addRecordToZone(update_columns), DataSourceError);
+    EXPECT_THROW(accessor->addRecordToZone(update_columns), DataSourceError);
 }
 
 TEST_F(SQLite3Update, deleteRecord) {
-    zone_id = db->startUpdateZone("example.com.", false).second;
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
 
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 
     update_columns.assign(deleted_data, deleted_data +
                           DatabaseAccessor::DEL_PARAM_COUNT);
-    db->deleteRecordInZone(update_columns);
-    checkRecords(*db, zone_id, "foo.bar.example.com.", empty_stored);
+    accessor->deleteRecordInZone(update_columns);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
 
     // Commit the change, and confirm the deleted data still isn't there.
-    db->commitUpdateZone();
-    checkRecords(*db, zone_id, "foo.bar.example.com.", empty_stored);
+    accessor->commitUpdateZone();
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
 }
 
 TEST_F(SQLite3Update, deleteThenRollback) {
-    zone_id = db->startUpdateZone("example.com.", false).second;
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
 
     update_columns.assign(deleted_data, deleted_data +
                           DatabaseAccessor::DEL_PARAM_COUNT);
-    db->deleteRecordInZone(update_columns);
-    checkRecords(*db, zone_id, "foo.bar.example.com.", empty_stored);
+    accessor->deleteRecordInZone(update_columns);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", empty_stored);
 
     // Rollback the change, and confirm the data still exists.
-    db->rollbackUpdateZone();
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    accessor->rollbackUpdateZone();
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 }
 
 TEST_F(SQLite3Update, deleteNonexistent) {
-    zone_id = db->startUpdateZone("example.com.", false).second;
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
     update_columns.assign(deleted_data, deleted_data +
                           DatabaseAccessor::DEL_PARAM_COUNT);
 
     // Replace the name with a non existent one, then try to delete it.
     // nothing should happen.
     update_columns[0] = "no-such-name.example.com.";
-    checkRecords(*db, zone_id, "no-such-name.example.com.", empty_stored);
-    db->deleteRecordInZone(update_columns);
-    checkRecords(*db, zone_id, "no-such-name.example.com.", empty_stored);
+    checkRecords(*accessor, zone_id, "no-such-name.example.com.",
+                 empty_stored);
+    accessor->deleteRecordInZone(update_columns);
+    checkRecords(*accessor, zone_id, "no-such-name.example.com.",
+                 empty_stored);
 
     // Name exists but the RR type is different.  Delete attempt shouldn't
     // delete only by name.
     update_columns.assign(deleted_data, deleted_data +
                           DatabaseAccessor::DEL_PARAM_COUNT);
     update_columns[1] = "AAAA";
-    db->deleteRecordInZone(update_columns);
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    accessor->deleteRecordInZone(update_columns);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 
     // Similar to the previous case, but RDATA is different.
     update_columns.assign(deleted_data, deleted_data +
                           DatabaseAccessor::DEL_PARAM_COUNT);
     update_columns[2] = "192.0.2.2";
-    db->deleteRecordInZone(update_columns);
-    checkRecords(*db, zone_id, "foo.bar.example.com.", expected_stored);
+    accessor->deleteRecordInZone(update_columns);
+    checkRecords(*accessor, zone_id, "foo.bar.example.com.", expected_stored);
 }
 
 TEST_F(SQLite3Update, invalidDelete) {
     // An attempt of delete before an explicit start of transaction
-    EXPECT_THROW(db->deleteRecordInZone(update_columns), DataSourceError);
+    EXPECT_THROW(accessor->deleteRecordInZone(update_columns), DataSourceError);
 
     // Short column vector
     update_columns.clear();
-    zone_id = db->startUpdateZone("example.com.", false).second;
-    EXPECT_THROW(db->deleteRecordInZone(update_columns), DataSourceError);
+    zone_id = accessor->startUpdateZone("example.com.", false).second;
+    EXPECT_THROW(accessor->deleteRecordInZone(update_columns), DataSourceError);
 
     // Too many parameters
     for (int i = 0; i < DatabaseAccessor::DEL_PARAM_COUNT + 1; ++i) {
         update_columns.push_back("");
     }
-    EXPECT_THROW(db->deleteRecordInZone(update_columns), DataSourceError);
+    EXPECT_THROW(accessor->deleteRecordInZone(update_columns), DataSourceError);
 }
 } // end anonymous namespace