BIND 10 trac1330, updated. 61feac8366f972b60410b925e36a9267338b3e9a [1330] First test (index not in table) now passing
BIND 10 source code commits
bind10-changes at lists.isc.org
Fri Nov 4 16:30:38 UTC 2011
The branch, trac1330 has been updated
via 61feac8366f972b60410b925e36a9267338b3e9a (commit)
via 01b4b95b5fb7aa99765f29ffc61f5131173148eb (commit)
from 09e4d880b9e7260caf6b5ec763aa1e0712531657 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 61feac8366f972b60410b925e36a9267338b3e9a
Author: Stephen Morris <stephen at isc.org>
Date: Fri Nov 4 16:28:33 2011 +0000
[1330] First test (index not in table) now passing
commit 01b4b95b5fb7aa99765f29ffc61f5131173148eb
Author: Stephen Morris <stephen at isc.org>
Date: Thu Nov 3 15:49:26 2011 +0000
[1330] Basic definitions and test data complete
-----------------------------------------------------------------------
Summary of changes:
src/lib/datasrc/database.h | 50 +++++
src/lib/datasrc/sqlite3_accessor.cc | 189 ++++++++++++++++++--
src/lib/datasrc/sqlite3_accessor.h | 43 +++++-
src/lib/datasrc/tests/database_unittest.cc | 5 +
src/lib/datasrc/tests/sqlite3_accessor_unittest.cc | 19 ++
src/lib/datasrc/tests/testdata/brokendb.sqlite3 | Bin 2048 -> 4096 bytes
.../{example.org.sqlite3 => diffs.sqlite3} | Bin 14336 -> 16384 bytes
src/lib/datasrc/tests/testdata/diffs_table.sql | 122 +++++++++++++
src/lib/datasrc/tests/testdata/example.org.sqlite3 | Bin 14336 -> 14336 bytes
.../datasrc/tests/testdata/example2.com.sqlite3 | Bin 11264 -> 14336 bytes
src/lib/datasrc/tests/testdata/rwtest.sqlite3 | Bin 11264 -> 13312 bytes
src/lib/datasrc/tests/testdata/test-root.sqlite3 | Bin 14336 -> 17408 bytes
src/lib/datasrc/tests/testdata/test.sqlite3 | Bin 43008 -> 46080 bytes
13 files changed, 409 insertions(+), 19 deletions(-)
copy src/lib/datasrc/tests/testdata/{example.org.sqlite3 => diffs.sqlite3} (68%)
create mode 100644 src/lib/datasrc/tests/testdata/diffs_table.sql
-----------------------------------------------------------------------
diff --git a/src/lib/datasrc/database.h b/src/lib/datasrc/database.h
index d80a4ab..1479b32 100644
--- a/src/lib/datasrc/database.h
+++ b/src/lib/datasrc/database.h
@@ -249,6 +249,56 @@ public:
*/
virtual IteratorContextPtr getAllRecords(int id) const = 0;
+ /**
+ * \brief Creates an iterator context for a set of differences.
+ *
+ * Returns an IteratorContextPtr that contains all difference records for
+ * the given zone between two versions of a zone.
+ *
+ * The difference records are the set of records that would appear in an
+ * IXFR serving a request for the difference between two versions of a zone.
+ * The records are returned in the same order as they would be in the IXFR.
+ * This means that if the the difference between versions of a zone with SOA
+ * serial numbers of "start" and "end" is required, and the zone contains
+ * the differences between serial number "start" to serial number
+ * "intermediate" and from serial number "intermediate" to serial number
+ * "end", the returned records will be (in order):
+ *
+ * \li SOA for serial "start"
+ * \li Records removed from the zone between versions "start" and
+ * "intermediate" of the zone. The order of these is not guaranteed.
+ * \li SOA for serial "intermediate"
+ * \li Records added to the zone between versions "start" and
+ * "intermediate" of the zone. The order of these is not guaranteed.
+ * \li SOA for serial "intermediate"
+ * \li Records removed from the zone between versions "intermediate" and
+ * "end" of the zone. The order of these is not guaranteed.
+ * \li SOA for serial "end"
+ * \li Records added to the zone between versions "intermediate" and "end"
+ * of the zone. The order of these is not guaranteed.
+ *
+ * Note that there is no requirement that "start" be less than "end". Owing
+ * to serial number arithmetic, it is entirely possible that a later version
+ * of a zone will have a smaller SOA serial number than an earlier version.
+ *
+ * Each call to getNext() on the returned iterator should copy all
+ * column fields of the array that is passed, as defined in the
+ * RecordColumns enum.
+ *
+ * \exception any Since any implementation can be used, the caller should
+ * expect any exception to be thrown.
+ *
+ * \param id The ID of the zone, returned from getZone().
+ * \param start The SOA serial number of the version of the zone from
+ * which the difference sequence should start.
+ * \param end The SOA serial number of the version of the zone at which
+ * the difference sequence should end.
+ *
+ * \return Newly created iterator context. Must not be NULL.
+ */
+ virtual IteratorContextPtr getDiffs(int id, uint32_t start, uint32_t end)
+ const = 0;
+
/// Start a transaction for updating a zone.
///
/// Each derived class version of this method starts a database
diff --git a/src/lib/datasrc/sqlite3_accessor.cc b/src/lib/datasrc/sqlite3_accessor.cc
index cf1593a..77e7057 100644
--- a/src/lib/datasrc/sqlite3_accessor.cc
+++ b/src/lib/datasrc/sqlite3_accessor.cc
@@ -52,7 +52,10 @@ enum StatementID {
DEL_RECORD = 8,
ITERATE = 9,
FIND_PREVIOUS = 10,
- NUM_STATEMENTS = 11
+ LOW_DIFF_ID = 11,
+ HIGH_DIFF_ID = 12,
+ DIFFS = 13,
+ NUM_STATEMENTS = 14
};
const char* const text_statements[NUM_STATEMENTS] = {
@@ -60,28 +63,39 @@ const char* const text_statements[NUM_STATEMENTS] = {
// specifically chosen to match the enum values in RecordColumns
"SELECT id FROM zones WHERE name=?1 AND rdclass = ?2", // ZONE
"SELECT rdtype, ttl, sigtype, rdata FROM records " // ANY
- "WHERE zone_id=?1 AND name=?2",
+ "WHERE zone_id=?1 AND name=?2",
"SELECT rdtype, ttl, sigtype, rdata " // ANY_SUB
- "FROM records WHERE zone_id=?1 AND name LIKE (\"%.\" || ?2)",
+ "FROM records WHERE zone_id=?1 AND name LIKE (\"%.\" || ?2)",
"BEGIN", // BEGIN
"COMMIT", // COMMIT
"ROLLBACK", // ROLLBACK
"DELETE FROM records WHERE zone_id=?1", // DEL_ZONE_RECORDS
"INSERT INTO records " // ADD_RECORD
- "(zone_id, name, rname, ttl, rdtype, sigtype, rdata) "
- "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
+ "(zone_id, name, rname, ttl, rdtype, sigtype, rdata) "
+ "VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)",
"DELETE FROM records WHERE zone_id=?1 AND name=?2 " // DEL_RECORD
- "AND rdtype=?3 AND rdata=?4",
+ "AND rdtype=?3 AND rdata=?4",
"SELECT rdtype, ttl, sigtype, rdata, name FROM records " // ITERATE
- "WHERE zone_id = ?1 ORDER BY rname, rdtype",
+ "WHERE zone_id = ?1 ORDER BY rname, rdtype",
/*
* This one looks for previous name with NSEC record. It is done by
* using the reversed name. The NSEC is checked because we need to
* skip glue data, which don't have the NSEC.
*/
"SELECT name FROM records " // FIND_PREVIOUS
- "WHERE zone_id=?1 AND rdtype = 'NSEC' AND "
- "rname < $2 ORDER BY rname DESC LIMIT 1"
+ "WHERE zone_id=?1 AND rdtype = 'NSEC' AND "
+ "rname < $2 ORDER BY rname DESC LIMIT 1",
+ // Two statements to select the lowest ID and highest ID in a set of
+ // differences.
+ "SELECT id FROM diffs " // LOW_DIFF_ID
+ "WHERE zone_id=?1 AND version=?2 and OPERATION=0 "
+ "ORDER BY id ASC LIMIT 1",
+ "SELECT id FROM diffs " // LOW_DIFF_ID
+ "WHERE zone_id=?1 AND version=?2 and OPERATION=1 "
+ "ORDER BY id DESC LIMIT 1",
+ "SELECT name, rrtype, ttl, rdata FROM diffs " // DIFFS
+ "WHERE zone_id=?1 AND id>=?2 and id<=?3"
+
};
struct SQLite3Parameters {
@@ -194,18 +208,26 @@ const char* const SCHEMA_LIST[] = {
"dnssec BOOLEAN NOT NULL DEFAULT 0)",
"CREATE INDEX zones_byname ON zones (name)",
"CREATE TABLE records (id INTEGER PRIMARY KEY, "
- "zone_id INTEGER NOT NULL, name STRING NOT NULL COLLATE NOCASE, "
- "rname STRING NOT NULL COLLATE NOCASE, ttl INTEGER NOT NULL, "
- "rdtype STRING NOT NULL COLLATE NOCASE, sigtype STRING COLLATE NOCASE, "
- "rdata STRING NOT NULL)",
+ "zone_id INTEGER NOT NULL, name STRING NOT NULL COLLATE NOCASE, "
+ "rname STRING NOT NULL COLLATE NOCASE, ttl INTEGER NOT NULL, "
+ "rdtype STRING NOT NULL COLLATE NOCASE, sigtype STRING COLLATE NOCASE, "
+ "rdata STRING NOT NULL)",
"CREATE INDEX records_byname ON records (name)",
"CREATE INDEX records_byrname ON records (rname)",
"CREATE TABLE nsec3 (id INTEGER PRIMARY KEY, zone_id INTEGER NOT NULL, "
- "hash STRING NOT NULL COLLATE NOCASE, "
- "owner STRING NOT NULL COLLATE NOCASE, "
- "ttl INTEGER NOT NULL, rdtype STRING NOT NULL COLLATE NOCASE, "
- "rdata STRING NOT NULL)",
+ "hash STRING NOT NULL COLLATE NOCASE, "
+ "owner STRING NOT NULL COLLATE NOCASE, "
+ "ttl INTEGER NOT NULL, rdtype STRING NOT NULL COLLATE NOCASE, "
+ "rdata STRING NOT NULL)",
"CREATE INDEX nsec3_byhash ON nsec3 (hash)",
+ "CREATE TABLE diffs (id INTEGER PRIMARY KEY AUTOINCREMENT,"
+ "zone_id INTEGER NOT NULL, "
+ "version INTEGER NOT NULL, "
+ "operation INTEGER NOT NULL, "
+ "name STRING NOT NULL COLLATE NOCASE, "
+ "rrtype STRING NOT NULL COLLATE NOCASE, "
+ "ttl INTEGER NOT NULL, "
+ "rdata STRING NOT NULL)",
NULL
};
@@ -526,6 +548,9 @@ private:
const std::string name_;
};
+
+// Methods to retrieve the various iterators
+
DatabaseAccessor::IteratorContextPtr
SQLite3Accessor::getRecords(const std::string& name, int id,
bool subdomains) const
@@ -539,6 +564,136 @@ SQLite3Accessor::getAllRecords(int id) const {
return (IteratorContextPtr(new Context(shared_from_this(), id)));
}
+
+/// \brief Difference Iterator
+///
+///
+
+class SQLite3Accessor::DiffContext : public DatabaseAccessor::IteratorContext {
+public:
+
+ // Construct an iterator for difference records.
+ DiffContext(const boost::shared_ptr<const SQLite3Accessor>& accessor,
+ int id, int start, int end) :
+ accessor_(accessor)
+ {
+ int low_id = findIndex(LOW_DIFF_ID, id, start);
+ int high_id = findIndex(HIGH_DIFF_ID, id, end);
+ std::cout << "Low index is " << low_id << ", high index is " << high_id << "\n";
+ }
+
+ virtual ~DiffContext() {}
+
+ virtual bool getNext(std::string (&data)[COLUMN_COUNT]) {
+ static_cast<void>(data[0]);
+ return (false);
+ }
+
+private:
+
+ /// \brief Clear Statement Bindings
+ ///
+ /// Clears the bindings of variables in a prepared statement and resets
+ /// them to null.
+ ///
+ /// \param stindex Index of prepared statement to which to bind
+ void clearBindings(int stindex) {
+ if (sqlite3_clear_bindings(accessor_->dbparameters_->statements_[stindex])
+ != SQLITE_OK) {
+ isc_throw(SQLite3Error, "Could not clear SQL statement bindings in '" <<
+ text_statements[stindex] << "': " <<
+ sqlite3_errmsg(accessor_->dbparameters_->db_));
+ }
+ }
+
+ /// \brief Bind Int
+ ///
+ /// Binds an integer to a specific variable in a prepared statement.
+ ///
+ /// \param stindex Index of prepared statement to which to bind
+ /// \param varindex Index of variable to which to bind
+ /// \param value Value of variable to bind
+ /// \exception SQLite3Error on an error
+ void bindInt(int stindex, int varindex, int value) {
+ if (sqlite3_bind_int(accessor_->dbparameters_->statements_[stindex],
+ varindex, value) != SQLITE_OK) {
+ isc_throw(SQLite3Error, "Could not bind value to parameter " <<
+ varindex << " in statement '" <<
+ text_statements[stindex] << "': " <<
+ sqlite3_errmsg(accessor_->dbparameters_->db_));
+ }
+ }
+
+ /// \brief Find index
+ ///
+ /// Executes the prepared statement locating the high or low index in
+ /// the diffs table and returns that index.
+ ///
+ /// \param stmt_id Index of the prepared statement to execute
+ /// \param zone_id ID of the zone for which the index is being sought
+ /// \param serial Zone serial number for which an index is being sought.
+ ///
+ /// \return int ID of the row in the difss table corresponding to the
+ /// statement.
+ ///
+ /// \exception NoSuchSerial Serial number not found
+ int findIndex(StatementID stindex, int zone_id, uint32_t serial) {
+
+ // Set up the statement
+ clearBindings(stindex);
+ bindInt(stindex, 1, zone_id);
+ bindInt(stindex, 2, serial);
+
+ // Get a pointer to the statement for brevity (does not transfer resources)
+ sqlite3_stmt* stmt = accessor_->dbparameters_->statements_[stindex];
+
+ // Execute the data. Should be just one result
+ int rc = sqlite3_step(stmt);
+ int result = -1;
+ if (rc == SQLITE_ROW) {
+
+ // Got some data, extract the value
+ result = sqlite3_column_int(stmt, 1);
+ int rc = sqlite3_step(stmt);
+ if (rc == SQLITE_DONE) {
+
+ // That was the only data, OK to return. Tidy up as we go,
+ // ignoring any error return.
+ rc = sqlite3_reset(stmt);
+ } else if (rc == SQLITE_ROW) {
+ isc_throw(DataSourceError, "request to return one value from "
+ "diffs table for serial " << serial << " (zone ID " <<
+ zone_id << ") returned multiple values");
+ }
+ } else if (rc == SQLITE_DONE) {
+
+ // No data in the table for this zone and version. Note that.
+ isc_throw(NoSuchSerial, "no data on serial number " << serial <<
+ " for zone ID " << zone_id);
+ }
+
+ if (rc != SQLITE_OK) {
+ isc_throw(DataSourceError, "could not get data from diffs table: " <<
+ sqlite3_errmsg(accessor_->dbparameters_->db_));
+ }
+
+ return (result);
+ }
+
+
+ boost::shared_ptr<const SQLite3Accessor> accessor_; // Accessor object
+};
+
+// ... and return the iterator
+
+DatabaseAccessor::IteratorContextPtr
+SQLite3Accessor::getDiffs(int id, uint32_t start, uint32_t end) const {
+ return (IteratorContextPtr(new DiffContext(shared_from_this(), id, start,
+ end)));
+}
+
+
+
pair<bool, int>
SQLite3Accessor::startUpdateZone(const string& zone_name, const bool replace) {
if (dbparameters_->updating_zone) {
diff --git a/src/lib/datasrc/sqlite3_accessor.h b/src/lib/datasrc/sqlite3_accessor.h
index 3d1c85d..65d64e6 100644
--- a/src/lib/datasrc/sqlite3_accessor.h
+++ b/src/lib/datasrc/sqlite3_accessor.h
@@ -46,6 +46,18 @@ public:
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 doe nsot exist.
+ */
+class NoSuchSerial : public Exception {
+public:
+ NoSuchSerial(const char* file, size_t line, const char* what) :
+ isc::Exception(file, line, what) {}
+};
+
struct SQLite3Parameters;
/**
@@ -128,6 +140,27 @@ public:
*/
virtual IteratorContextPtr getAllRecords(int id) const;
+ /** \brief Creates an iterator context for a set of differences.
+ *
+ * Implements the getDiffs() method from DatabaseAccessor
+ *
+ * \exception NoSuchSerial if either of the versions do not exist in
+ * the difference table.
+ * \exception SQLite3Error if there is an sqlite3 error when performing
+ * the query
+ *
+ * \param id The ID of the zone, returned from getZone().
+ * \param start The SOA serial number of the version of the zone from
+ * which the difference sequence should start.
+ * \param end The SOA serial number of the version of the zone at which
+ * the difference sequence should end.
+ *
+ * \return Iterator containing difference records.
+ */
+ virtual IteratorContextPtr getDiffs(int id, uint32_t start, uint32_t end) const;
+
+
+
virtual std::pair<bool, int> startUpdateZone(const std::string& zone_name,
bool replace);
@@ -175,14 +208,20 @@ private:
const std::string filename_;
/// \brief The class for which the queries are done
const std::string class_;
+ /// \brief Database name
+ const std::string database_name_;
+
/// \brief Opens the database
void open(const std::string& filename);
/// \brief Closes the database
void close();
- /// \brief SQLite3 implementation of IteratorContext
+
+ /// \brief SQLite3 implementation of IteratorContext for all records
class Context;
friend class Context;
- const std::string database_name_;
+ /// \brief SQLite3 implementation of IteratorContext for differences
+ class DiffContext;
+ friend class DiffContext;
};
/// \brief Creates an instance of the SQlite3 datasource client
diff --git a/src/lib/datasrc/tests/database_unittest.cc b/src/lib/datasrc/tests/database_unittest.cc
index 9775321..39110c8 100644
--- a/src/lib/datasrc/tests/database_unittest.cc
+++ b/src/lib/datasrc/tests/database_unittest.cc
@@ -250,6 +250,11 @@ public:
"This database datasource can't be iterated");
}
+ virtual IteratorContextPtr getDiffs(int, uint32_t, uint32_t) const {
+ isc_throw(isc::NotImplemented,
+ "This database datasource can't be iterated");
+ }
+
virtual std::string findPreviousName(int, const std::string&) const {
isc_throw(isc::NotImplemented,
"This data source doesn't support DNSSEC");
diff --git a/src/lib/datasrc/tests/sqlite3_accessor_unittest.cc b/src/lib/datasrc/tests/sqlite3_accessor_unittest.cc
index 5d66737..47a7f59 100644
--- a/src/lib/datasrc/tests/sqlite3_accessor_unittest.cc
+++ b/src/lib/datasrc/tests/sqlite3_accessor_unittest.cc
@@ -44,6 +44,7 @@ std::string SQLITE_DBNAME_EXAMPLE_ROOT = "sqlite3_test-root.sqlite3";
std::string SQLITE_DBFILE_BROKENDB = TEST_DATA_DIR "/brokendb.sqlite3";
std::string SQLITE_DBFILE_MEMORY = ":memory:";
std::string SQLITE_DBFILE_EXAMPLE_ORG = TEST_DATA_DIR "/example.org.sqlite3";
+std::string SQLITE_DBFILE_DIFFS = TEST_DATA_DIR "/diffs.sqlite3";
// The following file must be non existent and must be non"creatable";
// the sqlite3 library will try to create a new DB file if it doesn't exist,
@@ -204,6 +205,24 @@ TEST_F(SQLite3AccessorTest, iterator) {
EXPECT_FALSE(context->getNext(data));
}
+// This tests the difference iterator context
+
+// Test that at attempt to create a difference iterator for a serial that
+// does not exist throws an exception.
+
+TEST_F(SQLite3AccessorTest, diffIteratorNoVersion) {
+
+ // Our test zone is conveniently small, but not empty
+ initAccessor(SQLITE_DBFILE_DIFFS, "IN");
+
+ const std::pair<bool, int> zone_info(accessor->getZone("example.org."));
+ ASSERT_TRUE(zone_info.first);
+
+ // Get the iterator context. Difference of version 1 does not exist.
+ EXPECT_THROW(accessor->getDiffs(zone_info.second, 1U, 1234U),
+ NoSuchSerial);
+}
+
TEST(SQLite3Open, getDBNameExample2) {
SQLite3Accessor accessor(SQLITE_DBFILE_EXAMPLE2, "IN");
EXPECT_EQ(SQLITE_DBNAME_EXAMPLE2, accessor.getDBName());
diff --git a/src/lib/datasrc/tests/testdata/brokendb.sqlite3 b/src/lib/datasrc/tests/testdata/brokendb.sqlite3
index 7aad3af..63f3cc5 100644
Binary files a/src/lib/datasrc/tests/testdata/brokendb.sqlite3 and b/src/lib/datasrc/tests/testdata/brokendb.sqlite3 differ
diff --git a/src/lib/datasrc/tests/testdata/diffs.sqlite3 b/src/lib/datasrc/tests/testdata/diffs.sqlite3
new file mode 100644
index 0000000..c5a1476
Binary files /dev/null and b/src/lib/datasrc/tests/testdata/diffs.sqlite3 differ
diff --git a/src/lib/datasrc/tests/testdata/diffs_table.sql b/src/lib/datasrc/tests/testdata/diffs_table.sql
new file mode 100644
index 0000000..b5467a7
--- /dev/null
+++ b/src/lib/datasrc/tests/testdata/diffs_table.sql
@@ -0,0 +1,122 @@
+-- Copyright (C) 2011 Internet Systems Consortium, Inc. ("ISC")
+--
+-- Permission to use, copy, modify, and/or distribute this software for any
+-- purpose with or without fee is hereby granted, provided that the above
+-- copyright notice and this permission notice appear in all copies.
+--
+-- THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+-- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+-- AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+-- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+-- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+-- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+-- PERFORMANCE OF THIS SOFTWARE.
+
+-- \brief Create Differences Table
+--
+-- This is a short-term solution to creating the differences table for testing
+-- purposes.
+--
+-- It is assumed that the database used is a copy of the "example.org.sqlite3"
+-- database in this test directory. The diffs table is created and populated
+-- with a set of RRs that purport to represent differences that end in the
+-- zone as is.
+--
+-- The file can be executed by the command:
+-- % sqlite3 -init <this-file> <database-file> ".quit"
+--
+-- The file gets executed as the set of SQL statements on the database file,
+-- the ".quit" on the command line then getting executed to exit SQLite3.
+
+-- Create the diffs table
+CREATE TABLE diffs (id INTEGER PRIMARY KEY AUTOINCREMENT,
+ zone_id INTEGER NOT NULL,
+ version INTEGER NOT NULL,
+ operation INTEGER NOT NULL,
+ name STRING NOT NULL COLLATE NOCASE,
+ rrtype STRING NOT NULL COLLATE NOCASE,
+ ttl INTEGER NOT NULL,
+ rdata STRING NOT NULL);
+
+-- Populate it. A dummy zone_id is used for now - this will be updated last of
+-- all.
+
+-- Change from 4294967280 (0xfffffff0) to 1230 to show serial rollover
+-- Update one record in the zone.
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 4294967280, 0, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 4294967280 3600 1800 2419200, 7200");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 4294967280, 0, "www.example.org.", "A", 3600, "192.0.2.31");
+
+-- Records added in version 1230 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1230, 1, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 1230 3600 1800 2419200, 7200");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1230, 1, "www.example.org.", "A", 3600, "192.0.2.21");
+
+-- Change 1230 to 1231: Change change a parameter of the SOA record
+-- Records removed from version 1230 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1230, 0, "example.org.", "SOA", 1800,
+ "ns1.example.org. admin.example.org. 1230 3600 1800 2419200, 7200");
+
+-- Records added in version 1231 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1231, 1, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 1231 3600 1800 2419200, 7200");
+
+
+-- Change 1231 to 1232: Remove one record, don't add anything.
+-- Records removed from version 1231 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1231, 0, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 1231 3600 1800 2419200, 7200");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1231, 0, "unused.example.org.", "A", 3600, "192.0.2.102");
+
+-- Records added in version 1232 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1232, 1, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 1232 3600 1800 2419200, 7200");
+
+-- Change 1232 to 1233: Add two, don't remove anything.
+-- Records removed from version 1232 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1232, 0, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 1232 3600 1800 2419200, 7200");
+
+-- Records added in version 1233 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1233, 1, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 1233 3600 1800 2419200, 7200");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1233, 1, "sub.example.org.", "NS", 3600, "ns.sub.example.org.");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1233, 1, "ns.sub.example.org.", "A", 3600, "192.0.2.101");
+
+
+-- Change 1233 to 1234: change addresses of two A records
+-- Records removed from version 1233 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1233, 0, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 1233 3600 1800 2419200, 7200");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1233, 0, "www.example.org.", "A", 3600, "192.0.2.21");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1233, 0, "mail.example.org.", "A", 3600, "192.0.2.210");
+
+-- Records added in version 1234 of the zone
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1234, 1, "example.org.", "SOA", 3600,
+ "ns1.example.org. admin.example.org. 1234 3600 1800 2419200, 7200");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1234, 1, "www.example.org.", "A", 3600, "192.0.2.1");
+INSERT INTO diffs(zone_id, version, operation, name, rrtype, ttl, rdata)
+ VALUES(1, 1234, 1, "mail.example.org.", "A", 3600, "192.0.2.10");
+
+-- Finally, update the zone_id in the diffs table with what is actually
+-- in the zone table.
+UPDATE diffs SET zone_id =
+ (SELECT id FROM ZONES LIMIT 1);
diff --git a/src/lib/datasrc/tests/testdata/example.org.sqlite3 b/src/lib/datasrc/tests/testdata/example.org.sqlite3
index 070012f..60e6e05 100644
Binary files a/src/lib/datasrc/tests/testdata/example.org.sqlite3 and b/src/lib/datasrc/tests/testdata/example.org.sqlite3 differ
diff --git a/src/lib/datasrc/tests/testdata/example2.com.sqlite3 b/src/lib/datasrc/tests/testdata/example2.com.sqlite3
index 8d3bb34..9da7d0e 100644
Binary files a/src/lib/datasrc/tests/testdata/example2.com.sqlite3 and b/src/lib/datasrc/tests/testdata/example2.com.sqlite3 differ
diff --git a/src/lib/datasrc/tests/testdata/rwtest.sqlite3 b/src/lib/datasrc/tests/testdata/rwtest.sqlite3
index ce95a1d..ccbb884 100644
Binary files a/src/lib/datasrc/tests/testdata/rwtest.sqlite3 and b/src/lib/datasrc/tests/testdata/rwtest.sqlite3 differ
diff --git a/src/lib/datasrc/tests/testdata/test-root.sqlite3 b/src/lib/datasrc/tests/testdata/test-root.sqlite3
index 7cc6195..c1dae47 100644
Binary files a/src/lib/datasrc/tests/testdata/test-root.sqlite3 and b/src/lib/datasrc/tests/testdata/test-root.sqlite3 differ
diff --git a/src/lib/datasrc/tests/testdata/test.sqlite3 b/src/lib/datasrc/tests/testdata/test.sqlite3
index cc8cfc3..a93a244 100644
Binary files a/src/lib/datasrc/tests/testdata/test.sqlite3 and b/src/lib/datasrc/tests/testdata/test.sqlite3 differ
More information about the bind10-changes
mailing list