Browse Source

[1183] getAllRecords already takes zone_id, does not need name

Jelte Jansen 13 years ago
parent
commit
1b421982a6

+ 1 - 1
src/lib/datasrc/database.cc

@@ -497,7 +497,7 @@ DatabaseClient::getIterator(const isc::dns::Name& name) const {
     }
     // Request the context
     DatabaseAccessor::IteratorContextPtr
-        context(database_->getAllRecords(name, zone.second));
+        context(database_->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 " +

+ 1 - 3
src/lib/datasrc/database.h

@@ -173,15 +173,13 @@ public:
      * \param id The ID of the zone, returned from getZone().
      * \return Newly created iterator context. Must not be NULL.
      */
-    virtual IteratorContextPtr getAllRecords(const isc::dns::Name& name,
-                                             int id) const
+    virtual IteratorContextPtr getAllRecords(int id) const
     {
         /*
          * This is a compromise. We need to document the parameters in doxygen,
          * so they need a name, but then it complains about unused parameter.
          * This is a NOP that "uses" the parameters.
          */
-        static_cast<void>(name);
         static_cast<void>(id);
 
         isc_throw(isc::NotImplemented,

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

@@ -468,7 +468,7 @@ SQLite3Database::getRecords(const isc::dns::Name& name, int id) const {
 }
 
 DatabaseAccessor::IteratorContextPtr
-SQLite3Database::getAllRecords(const isc::dns::Name&, int id) const {
+SQLite3Database::getAllRecords(int id) const {
     return (IteratorContextPtr(new Context(shared_from_this(), id)));
 }
 

+ 1 - 2
src/lib/datasrc/sqlite3_accessor.h

@@ -96,8 +96,7 @@ public:
                                           int id) const;
 
     /// \brief Implementation of DatabaseAbstraction::getAllRecords
-    virtual IteratorContextPtr getAllRecords(const isc::dns::Name&,
-                                             int id) const;
+    virtual IteratorContextPtr getAllRecords(int id) const;
 
     /// The SQLite3 implementation of this method returns a string starting
     /// with a fixed prefix of "sqlite3_" followed by the DB file name

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

@@ -233,7 +233,7 @@ private:
         }
     };
 public:
-    virtual IteratorContextPtr getAllRecords(const Name&, int id) const {
+    virtual IteratorContextPtr getAllRecords(int id) const {
         if (id == 42) {
             return (IteratorContextPtr(new MockIteratorContext()));
         } else if (id == 13) {
@@ -440,12 +440,16 @@ private:
     }
 };
 
+// This tests the default getRecords behaviour, throwing NotImplemented
+TEST(DatabaseConnectionTest, getRecords) {
+    EXPECT_THROW(NopAccessor().getRecords(Name("."), 1),
+                 isc::NotImplemented);
+}
+
 // This tests the default getAllRecords behaviour, throwing NotImplemented
 TEST(DatabaseConnectionTest, getAllRecords) {
     // The parameters don't matter
-    EXPECT_THROW(NopAccessor().getRecords(Name("."), 1),
-                 isc::NotImplemented);
-    EXPECT_THROW(NopAccessor().getAllRecords(Name("."), 1),
+    EXPECT_THROW(NopAccessor().getAllRecords(1),
                  isc::NotImplemented);
 }
 

+ 2 - 2
src/lib/datasrc/tests/sqlite3_accessor_unittest.cc

@@ -110,7 +110,7 @@ TEST_F(SQLite3Access, iterator) {
 
     // Get the iterator context
     DatabaseAccessor::IteratorContextPtr
-        context(db->getAllRecords(Name("example2.com"), 1));
+        context(db->getAllRecords(1));
     ASSERT_NE(DatabaseAccessor::IteratorContextPtr(),
               context);
 
@@ -133,7 +133,7 @@ TEST_F(SQLite3Access, iteratorColumnCount) {
 
     // Get the iterator context
     DatabaseAccessor::IteratorContextPtr
-        context(db->getAllRecords(Name("example2.com"), 1));
+        context(db->getAllRecords(1));
     ASSERT_NE(DatabaseAccessor::IteratorContextPtr(),
               context);