Commit 3d069e27 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1068] used local arrays for columns/parameters of add/delete RRset instead

of class member variables (which are now removed).  also added a test to
detect a bug in the previous code where the sigtype field for addRRset
was incorrectly carried over after adding an RRSIG.
parent 230df584
......@@ -660,8 +660,6 @@ private:
const string zone_name_;
const RRClass zone_class_;
boost::scoped_ptr<DatabaseClient::Finder> finder_;
string add_columns_[DatabaseAccessor::ADD_COLUMN_COUNT];
string del_params_[DatabaseAccessor::DEL_PARAM_COUNT];
};
void
......@@ -688,11 +686,12 @@ DatabaseUpdater::addRRset(const RRset& rrset) {
<< rrset.getType());
}
add_columns_[DatabaseAccessor::ADD_NAME] = rrset.getName().toText();
add_columns_[DatabaseAccessor::ADD_REV_NAME] =
string columns[DatabaseAccessor::ADD_COLUMN_COUNT]; // initialized with ""
columns[DatabaseAccessor::ADD_NAME] = rrset.getName().toText();
columns[DatabaseAccessor::ADD_REV_NAME] =
rrset.getName().reverse().toText();
add_columns_[DatabaseAccessor::ADD_TTL] = rrset.getTTL().toText();
add_columns_[DatabaseAccessor::ADD_TYPE] = rrset.getType().toText();
columns[DatabaseAccessor::ADD_TTL] = rrset.getTTL().toText();
columns[DatabaseAccessor::ADD_TYPE] = rrset.getType().toText();
for (; !it->isLast(); it->next()) {
if (rrset.getType() == RRType::RRSIG()) {
// XXX: the current interface (based on the current sqlite3
......@@ -702,11 +701,11 @@ DatabaseUpdater::addRRset(const RRset& rrset) {
// the interface, but until then we have to conform to the schema.
const generic::RRSIG& rrsig_rdata =
dynamic_cast<const generic::RRSIG&>(it->getCurrent());
add_columns_[DatabaseAccessor::ADD_SIGTYPE] =
columns[DatabaseAccessor::ADD_SIGTYPE] =
rrsig_rdata.typeCovered().toText();
}
add_columns_[DatabaseAccessor::ADD_RDATA] = it->getCurrent().toText();
accessor_->addRecordToZone(add_columns_);
columns[DatabaseAccessor::ADD_RDATA] = it->getCurrent().toText();
accessor_->addRecordToZone(columns);
}
}
......@@ -734,12 +733,12 @@ DatabaseUpdater::deleteRRset(const RRset& rrset) {
<< rrset.getType());
}
del_params_[DatabaseAccessor::DEL_NAME] = rrset.getName().toText();
del_params_[DatabaseAccessor::DEL_TYPE] = rrset.getType().toText();
string params[DatabaseAccessor::DEL_PARAM_COUNT]; // initialized with ""
params[DatabaseAccessor::DEL_NAME] = rrset.getName().toText();
params[DatabaseAccessor::DEL_TYPE] = rrset.getType().toText();
for (; !it->isLast(); it->next()) {
del_params_[DatabaseAccessor::DEL_RDATA] =
it->getCurrent().toText();
accessor_->deleteRecordInZone(del_params_);
params[DatabaseAccessor::DEL_RDATA] = it->getCurrent().toText();
accessor_->deleteRecordInZone(params);
}
}
......
......@@ -1633,6 +1633,15 @@ TEST_F(DatabaseClientTest, addRRsetToNewZone) {
qtype_, rrttl_, ZoneFinder::SUCCESS,
expected_rdatas_, expected_sig_rdatas_);
}
// Add the non RRSIG RRset again, to see the attempt of adding RRSIG
// causes any unexpected effect, in particular, whether the SIGTYPE
// field might remain.
updater_->addRRset(*rrset_);
const char* const rrset_added[] = {
"www.example.org.", "org.example.www.", "3600", "A", "", "192.0.2.2"
};
checkLastAdded(rrset_added);
}
TEST_F(DatabaseClientTest, addRRsetToCurrentZone) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment