Browse Source

[1330] Back out change 918c35143eb61d6e0ac96e98f2a95b12d55fdc0c

A different exception adds nothing to the error and has the
complication of requiring an additional query.
Stephen Morris 13 years ago
parent
commit
edf044e9e2

+ 9 - 24
src/lib/datasrc/sqlite3_accessor.cc

@@ -54,11 +54,10 @@ enum StatementID {
     FIND_PREVIOUS = 10,
     ADD_RECORD_DIFF = 11,
     GET_RECORD_DIFF = 12,       // This is temporary for testing "add diff"
-    COUNT_DIFF_RECS = 13,
-    LOW_DIFF_ID = 14,
-    HIGH_DIFF_ID = 15,
-    DIFF_RECS = 16,
-    NUM_STATEMENTS = 17
+    LOW_DIFF_ID = 13,
+    HIGH_DIFF_ID = 14,
+    DIFF_RECS = 15,
+    NUM_STATEMENTS = 16
 };
 
 const char* const text_statements[NUM_STATEMENTS] = {
@@ -96,8 +95,6 @@ const char* const text_statements[NUM_STATEMENTS] = {
 
     // Two statements to select the lowest ID and highest ID in a set of
     // differences.
-    "SELECT COUNT(id) FROM diffs "  // COUNT_DIFF_RECS
-        "WHERE zone_id=?1",
     "SELECT id FROM diffs "     // LOW_DIFF_ID
         "WHERE zone_id=?1 AND version=?2 and OPERATION=0 "
         "ORDER BY id ASC LIMIT 1",
@@ -799,23 +796,11 @@ private:
 
         } catch (TooLittleData) {
 
-            // Why is there too little data?  Could be there is no data in
-            // the table for the zone, or there is but there is no data for
-            // that particular serial number.  Do another query to find out.
-            clearBindings(COUNT_DIFF_RECS);
-            bindInt(COUNT_DIFF_RECS, 1, zone_id);
-
-            // If this throws an exception, let it propagate - there is
-            // definitely an error.
-            result = getSingleValue(COUNT_DIFF_RECS);
-            if (result == 0) {
-                isc_throw(NoDiffRecs, "no data in differences table for "
-                          "zone ID " << zone_id);
-            } else {
-                isc_throw(NoSuchSerial, "no data in differences table for "
-                          "zone ID " << zone_id << ", serial number " <<
-                          serial);
-            }
+            // No data returned but the SQL query succeeded.  Only possibility
+            // is that there is no entry in the differences table for the given
+            // zone and version.
+            isc_throw(NoSuchSerial, "No entry in differences table for " <<
+                      " zone ID " << zone_id << ", serial number " << serial);
         }
 
         return (result);

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

@@ -71,22 +71,10 @@ public:
 };
 
 /**
- * \brief No difference records
- *
- * Thrown if there are no difference records in the table for the requested
- * zone.
- */
-class NoDiffRecs : public Exception {
-public:
-    NoDiffRecs(const char* file, size_t line, const char* what) :
-        isc::Exception(file, line, what) {}
-};
-
-/**
  * \brief No such serial number when obtaining difference iterator
  *
- * Thrown if either the start or end version requested for the difference
- * iterator does not exist.
+ * Thrown if either the zone/start version or zone/end version combination
+ * does not exist in the differences table.
  */
 class NoSuchSerial : public Exception {
 public:

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

@@ -230,9 +230,9 @@ TEST_F(SQLite3AccessorTest, diffIteratorNoRecords) {
                  NoSuchSerial);
 
     // Check that valid versions - but for the wrong zone which does not hold
-    // any records - throws the correct exception.
+    // any records - also throws this exception.
     EXPECT_THROW(accessor->getDiffs(zone_info.second + 42, 1231, 1234),
-                 NoDiffRecs);
+                 NoSuchSerial);
 
 }