Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
e5ae1675
Commit
e5ae1675
authored
Dec 10, 2012
by
Jelte Jansen
Browse files
[2541] Add addZone() to the abstract database accessor base class
parent
0ece8832
Changes
4
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/database.h
View file @
e5ae1675
...
...
@@ -177,6 +177,26 @@ public:
/// an opaque handle.
virtual
std
::
pair
<
bool
,
int
>
getZone
(
const
std
::
string
&
name
)
const
=
0
;
/// \brief Add a new zone to the database
///
/// This method creates a new (and empty) zone in the database.
/// If a zone with the given name exists already, its zone_id value is
/// returned. Otherwise it is created, and the newly created zone_id
/// is returned.
///
/// Given the above, implementations should first do a lookup for the
/// given zone, and return the id if it exists.
///
/// Callers must start a transaction before calling this method,
/// implementations may throw DataSourceError if this has not been done.
/// Callers should also expect DataSourceErrors for other potential
/// problems.
///
/// \param name The (fully qualified) domain name of the zone to add.
/// \return The internal zone id of the zone (whether is existed already
/// or was created by this call).
virtual
int
addZone
(
const
std
::
string
&
name
)
=
0
;
/// \brief This holds the internal context of ZoneIterator for databases
///
/// While the ZoneIterator implementation from DatabaseClient does all the
...
...
src/lib/datasrc/sqlite3_accessor.cc
View file @
e5ae1675
...
...
@@ -617,7 +617,7 @@ SQLite3Accessor::getZone(const std::string& name) const {
}
int
SQLite3Accessor
::
addZone
(
const
std
::
string
&
zone_
name
)
{
SQLite3Accessor
::
addZone
(
const
std
::
string
&
name
)
{
// Transaction should have been started by the caller
if
(
!
dbparameters_
->
in_transaction
)
{
isc_throw
(
DataSourceError
,
"performing addZone on SQLite3 "
...
...
@@ -626,19 +626,19 @@ SQLite3Accessor::addZone(const std::string& zone_name) {
// First check if the zone exists, if it does, do nothing and
// return false
std
::
pair
<
bool
,
int
>
getzone_result
=
getZone
(
zone_
name
);
std
::
pair
<
bool
,
int
>
getzone_result
=
getZone
(
name
);
if
(
getzone_result
.
first
)
{
return
(
getzone_result
.
second
);
}
StatementProcessor
proc
(
*
dbparameters_
,
ADD_ZONE
,
"add zone"
);
proc
.
bindText
(
1
,
zone_
name
.
c_str
(),
SQLITE_TRANSIENT
);
proc
.
bindText
(
1
,
name
.
c_str
(),
SQLITE_TRANSIENT
);
proc
.
bindText
(
2
,
class_
.
c_str
(),
SQLITE_TRANSIENT
);
proc
.
exec
();
// There are tricks to getting this in one go, but it is safer
// to do a new lookup
getzone_result
=
getZone
(
zone_
name
);
getzone_result
=
getZone
(
name
);
assert
(
getzone_result
.
first
);
return
(
getzone_result
.
second
);
}
...
...
src/lib/datasrc/sqlite3_accessor.h
View file @
e5ae1675
...
...
@@ -150,11 +150,11 @@ public:
* is an SQLite3 error when performing the
* queries.
*
* \param
zone_
name The origin name of the zone to add
* \param name The origin name of the zone to add
* \return the id of the zone (either an existing one if the zone exists
* already, or the id of the newly created zone).
*/
virtual
int
addZone
(
const
std
::
string
&
zone_
name
);
virtual
int
addZone
(
const
std
::
string
&
name
);
/** \brief Look up all resource records for a name
*
...
...
src/lib/datasrc/tests/database_unittest.cc
View file @
e5ae1675
...
...
@@ -274,6 +274,11 @@ public:
}
}
virtual
int
addZone
(
const
std
::
string
&
)
{
isc_throw
(
isc
::
NotImplemented
,
"This database datasource can't add zones"
);
}
virtual
boost
::
shared_ptr
<
DatabaseAccessor
>
clone
()
{
// This accessor is stateless, so we can simply return a new instance.
return
(
boost
::
shared_ptr
<
DatabaseAccessor
>
(
new
NopAccessor
));
...
...
@@ -1780,7 +1785,7 @@ doFindAllTestResult(ZoneFinder& finder, const isc::dns::Name& name,
expected_name
,
result
->
rrset
->
getName
());
}
// When asking for an RRset where RRs somehow have different TTLs, it should
// When asking for an RRset where RRs somehow have different TTLs, it should
// convert to the lowest one.
TEST_F
(
MockDatabaseClientTest
,
ttldiff
)
{
ZoneIteratorPtr
it
(
this
->
client_
->
getIterator
(
Name
(
"example.org"
)));
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment