mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[#145] addressed review comments
This commit is contained in:
@@ -419,14 +419,14 @@ mysql_upgrade_13_to_14_test() {
|
|||||||
# -- lease counting tests --
|
# -- lease counting tests --
|
||||||
|
|
||||||
# Check that @json_supported is NULL by default.
|
# Check that @json_supported is NULL by default.
|
||||||
query='SELECT @json_supported'
|
query="SELECT @json_supported"
|
||||||
run_command \
|
run_command \
|
||||||
mysql_execute "${query}"
|
mysql_execute "${query}"
|
||||||
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
||||||
assert_str_eq "NULL" "${OUTPUT}" "${query}: expected output %s, returned %s"
|
assert_str_eq "NULL" "${OUTPUT}" "${query}: expected output %s, returned %s"
|
||||||
|
|
||||||
# Clean up.
|
# Clean up.
|
||||||
query='DELETE FROM lease4; DELETE FROM lease6'
|
query="DELETE FROM lease4; DELETE FROM lease6"
|
||||||
run_command \
|
run_command \
|
||||||
mysql_execute "${query}"
|
mysql_execute "${query}"
|
||||||
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
||||||
|
@@ -490,7 +490,7 @@ pgsql_upgrade_12_to_13_test() {
|
|||||||
# -- lease counting tests --
|
# -- lease counting tests --
|
||||||
|
|
||||||
# Clean up.
|
# Clean up.
|
||||||
query='DELETE FROM lease4; DELETE FROM lease6'
|
query="DELETE FROM lease4; DELETE FROM lease6"
|
||||||
run_command \
|
run_command \
|
||||||
pgsql_execute "${query}"
|
pgsql_execute "${query}"
|
||||||
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
||||||
@@ -533,7 +533,7 @@ pgsql_upgrade_12_to_13_test() {
|
|||||||
assert_str_eq '' "${OUTPUT}" "INSERT INTO leases when upgrading from 11 to 12 failed. expected output %s, returned %s"
|
assert_str_eq '' "${OUTPUT}" "INSERT INTO leases when upgrading from 11 to 12 failed. expected output %s, returned %s"
|
||||||
|
|
||||||
# Check that @json_supported is NULL by default.
|
# Check that @json_supported is NULL by default.
|
||||||
query='SELECT isJsonSupported()'
|
query="SELECT isJsonSupported()"
|
||||||
run_command \
|
run_command \
|
||||||
pgsql_execute "${query}"
|
pgsql_execute "${query}"
|
||||||
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
assert_eq 0 "${EXIT_CODE}" "${query}: expected %d, returned %d"
|
||||||
|
@@ -166,7 +166,7 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele
|
|||||||
ConstElementPtr subnet_id = element->get("subnet-id");
|
ConstElementPtr subnet_id = element->get("subnet-id");
|
||||||
if (!subnet_id || (subnet_id->getType() != Element::integer)) {
|
if (!subnet_id || (subnet_id->getType() != Element::integer)) {
|
||||||
isc_throw(BadValue, "subnet-id not present in the parsed lease"
|
isc_throw(BadValue, "subnet-id not present in the parsed lease"
|
||||||
" or it is not a number");
|
" or it is not an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (subnet_id->intValue() <= 0) {
|
if (subnet_id->intValue() <= 0) {
|
||||||
@@ -183,7 +183,7 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele
|
|||||||
ConstElementPtr pool_id = element->get("pool-id");
|
ConstElementPtr pool_id = element->get("pool-id");
|
||||||
if (pool_id) {
|
if (pool_id) {
|
||||||
if (pool_id->getType() != Element::integer) {
|
if (pool_id->getType() != Element::integer) {
|
||||||
isc_throw(BadValue, "pool-id is not a number");
|
isc_throw(BadValue, "pool-id is not an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pool_id->intValue() < 0) {
|
if (pool_id->intValue() < 0) {
|
||||||
@@ -219,7 +219,7 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele
|
|||||||
ConstElementPtr cltt = element->get("cltt");
|
ConstElementPtr cltt = element->get("cltt");
|
||||||
if (!cltt || (cltt->getType() != Element::integer)) {
|
if (!cltt || (cltt->getType() != Element::integer)) {
|
||||||
isc_throw(BadValue, "cltt is not present in the parsed lease"
|
isc_throw(BadValue, "cltt is not present in the parsed lease"
|
||||||
" or it is not a number");
|
" or it is not an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cltt->intValue() <= 0) {
|
if (cltt->intValue() <= 0) {
|
||||||
@@ -233,7 +233,7 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele
|
|||||||
ConstElementPtr valid_lifetime = element->get("valid-lft");
|
ConstElementPtr valid_lifetime = element->get("valid-lft");
|
||||||
if (!valid_lifetime || (valid_lifetime->getType() != Element::integer)) {
|
if (!valid_lifetime || (valid_lifetime->getType() != Element::integer)) {
|
||||||
isc_throw(BadValue, "valid-lft is not present in the parsed lease"
|
isc_throw(BadValue, "valid-lft is not present in the parsed lease"
|
||||||
" or it is not a number");
|
" or it is not an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (valid_lifetime->intValue() < 0) {
|
if (valid_lifetime->intValue() < 0) {
|
||||||
@@ -275,7 +275,7 @@ Lease::fromElementCommon(const LeasePtr& lease, const data::ConstElementPtr& ele
|
|||||||
ConstElementPtr state = element->get("state");
|
ConstElementPtr state = element->get("state");
|
||||||
if (!state || (state->getType() != Element::integer)) {
|
if (!state || (state->getType() != Element::integer)) {
|
||||||
isc_throw(BadValue, "state is not present in the parsed lease"
|
isc_throw(BadValue, "state is not present in the parsed lease"
|
||||||
" or it is not a number");
|
" or it is not an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((state->intValue() < 0) || (state->intValue() > Lease::STATE_EXPIRED_RECLAIMED)) {
|
if ((state->intValue() < 0) || (state->intValue() > Lease::STATE_EXPIRED_RECLAIMED)) {
|
||||||
@@ -664,7 +664,7 @@ Lease6::fromElement(const data::ConstElementPtr& element) {
|
|||||||
ConstElementPtr prefix_len = element->get("prefix-len");
|
ConstElementPtr prefix_len = element->get("prefix-len");
|
||||||
if (!prefix_len || (prefix_len->getType() != Element::integer)) {
|
if (!prefix_len || (prefix_len->getType() != Element::integer)) {
|
||||||
isc_throw(BadValue, "prefix-len is not present in the parsed lease"
|
isc_throw(BadValue, "prefix-len is not present in the parsed lease"
|
||||||
" or it is not a number");
|
" or it is not an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((prefix_len->intValue() < 1) || (prefix_len->intValue() > 128)) {
|
if ((prefix_len->intValue() < 1) || (prefix_len->intValue() > 128)) {
|
||||||
@@ -679,7 +679,7 @@ Lease6::fromElement(const data::ConstElementPtr& element) {
|
|||||||
ConstElementPtr iaid = element->get("iaid");
|
ConstElementPtr iaid = element->get("iaid");
|
||||||
if (!iaid || (iaid->getType() != Element::integer)) {
|
if (!iaid || (iaid->getType() != Element::integer)) {
|
||||||
isc_throw(BadValue, "iaid is not present in the parsed lease"
|
isc_throw(BadValue, "iaid is not present in the parsed lease"
|
||||||
" or it is not a number");
|
" or it is not an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iaid->intValue() < 0) {
|
if (iaid->intValue() < 0) {
|
||||||
@@ -708,7 +708,7 @@ Lease6::fromElement(const data::ConstElementPtr& element) {
|
|||||||
ConstElementPtr preferred_lft = element->get("preferred-lft");
|
ConstElementPtr preferred_lft = element->get("preferred-lft");
|
||||||
if (!preferred_lft || (preferred_lft->getType() != Element::integer)) {
|
if (!preferred_lft || (preferred_lft->getType() != Element::integer)) {
|
||||||
isc_throw(BadValue, "preferred-lft is not present in the parsed lease"
|
isc_throw(BadValue, "preferred-lft is not present in the parsed lease"
|
||||||
" or is not a number");
|
" or is not an integer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferred_lft->intValue() < 0) {
|
if (preferred_lft->intValue() < 0) {
|
||||||
|
@@ -356,7 +356,7 @@ tagged_statements = { {
|
|||||||
"lease_type, iaid, prefix_len, "
|
"lease_type, iaid, prefix_len, "
|
||||||
"fqdn_fwd, fqdn_rev, hostname, "
|
"fqdn_fwd, fqdn_rev, hostname, "
|
||||||
"hwaddr, hwtype, hwaddr_source, "
|
"hwaddr, hwtype, hwaddr_source, "
|
||||||
"state, user_context "
|
"state, user_context, pool_id "
|
||||||
"FROM lease6 "
|
"FROM lease6 "
|
||||||
"WHERE address > ? AND binaddr IS NULL "
|
"WHERE address > ? AND binaddr IS NULL "
|
||||||
"ORDER BY address "
|
"ORDER BY address "
|
||||||
@@ -407,7 +407,7 @@ tagged_statements = { {
|
|||||||
"lease_type, iaid, prefix_len, "
|
"lease_type, iaid, prefix_len, "
|
||||||
"fqdn_fwd, fqdn_rev, hostname, "
|
"fqdn_fwd, fqdn_rev, hostname, "
|
||||||
"hwaddr, hwtype, hwaddr_source, "
|
"hwaddr, hwtype, hwaddr_source, "
|
||||||
"state, user_context "
|
"state, user_context, pool_id "
|
||||||
"FROM lease6 "
|
"FROM lease6 "
|
||||||
"WHERE binaddr IS NOT NULL "
|
"WHERE binaddr IS NOT NULL "
|
||||||
"AND binaddr BETWEEN ? AND ? "
|
"AND binaddr BETWEEN ? AND ? "
|
||||||
@@ -425,7 +425,7 @@ tagged_statements = { {
|
|||||||
"lease_type, iaid, prefix_len, "
|
"lease_type, iaid, prefix_len, "
|
||||||
"fqdn_fwd, fqdn_rev, hostname, "
|
"fqdn_fwd, fqdn_rev, hostname, "
|
||||||
"hwaddr, hwtype, hwaddr_source, "
|
"hwaddr, hwtype, hwaddr_source, "
|
||||||
"state, user_context, binaddr, pool_id) "
|
"state, user_context, pool_id, binaddr) "
|
||||||
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"},
|
"VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"},
|
||||||
{MySqlLeaseMgr::UPDATE_LEASE4,
|
{MySqlLeaseMgr::UPDATE_LEASE4,
|
||||||
"UPDATE lease4 SET address = ?, hwaddr = ?, "
|
"UPDATE lease4 SET address = ?, hwaddr = ?, "
|
||||||
@@ -441,7 +441,7 @@ tagged_statements = { {
|
|||||||
"pref_lifetime = ?, lease_type = ?, iaid = ?, "
|
"pref_lifetime = ?, lease_type = ?, iaid = ?, "
|
||||||
"prefix_len = ?, fqdn_fwd = ?, fqdn_rev = ?, "
|
"prefix_len = ?, fqdn_fwd = ?, fqdn_rev = ?, "
|
||||||
"hostname = ?, hwaddr = ?, hwtype = ?, hwaddr_source = ?, "
|
"hostname = ?, hwaddr = ?, hwtype = ?, hwaddr_source = ?, "
|
||||||
"state = ?, user_context = ?, binaddr = ?, pool_id = ? "
|
"state = ?, user_context = ?, pool_id = ?, binaddr = ? "
|
||||||
"WHERE address = ? AND expire = ?"},
|
"WHERE address = ? AND expire = ?"},
|
||||||
{MySqlLeaseMgr::ALL_LEASE4_STATS,
|
{MySqlLeaseMgr::ALL_LEASE4_STATS,
|
||||||
"SELECT subnet_id, state, leases as state_count "
|
"SELECT subnet_id, state, leases as state_count "
|
||||||
@@ -574,7 +574,26 @@ public:
|
|||||||
/// in all MySqlLeaseMgr::xxx4() calls where it is used.
|
/// in all MySqlLeaseMgr::xxx4() calls where it is used.
|
||||||
|
|
||||||
class MySqlLease4Exchange : public MySqlLeaseExchange {
|
class MySqlLease4Exchange : public MySqlLeaseExchange {
|
||||||
/// @brief Set number of database columns for this lease structure
|
/// These are used for both retrieving data and for looking up
|
||||||
|
/// column labels for logging. Note that their numeric order
|
||||||
|
/// MUST match that of the column order in the Lease4 table.
|
||||||
|
//@{
|
||||||
|
static const size_t ADDRESS_COL = 0;
|
||||||
|
static const size_t HWADDR_COL = 1;
|
||||||
|
static const size_t CLIENT_ID_COL = 2;
|
||||||
|
static const size_t VALID_LIFETIME_COL = 3;
|
||||||
|
static const size_t EXPIRE_COL = 4;
|
||||||
|
static const size_t SUBNET_ID_COL = 5;
|
||||||
|
static const size_t FQDN_FWD_COL = 6;
|
||||||
|
static const size_t FQDN_REV_COL = 7;
|
||||||
|
static const size_t HOSTNAME_COL = 8;
|
||||||
|
static const size_t STATE_COL = 9;
|
||||||
|
static const size_t USER_CONTEXT_COL = 10;
|
||||||
|
static const size_t RELAY_ID_COL = 11;
|
||||||
|
static const size_t REMOTE_ID_COL = 12;
|
||||||
|
static const size_t POOL_ID_COL = 13;
|
||||||
|
//@}
|
||||||
|
/// @brief Number of columns in the table holding DHCPv4 leases.
|
||||||
static const size_t LEASE_COLUMNS = 14;
|
static const size_t LEASE_COLUMNS = 14;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -600,20 +619,20 @@ public:
|
|||||||
std::fill(&error_[0], &error_[LEASE_COLUMNS], MLM_FALSE);
|
std::fill(&error_[0], &error_[LEASE_COLUMNS], MLM_FALSE);
|
||||||
|
|
||||||
// Set the column names (for error messages)
|
// Set the column names (for error messages)
|
||||||
columns_[0] = "address";
|
columns_[ADDRESS_COL] = "address";
|
||||||
columns_[1] = "hwaddr";
|
columns_[HWADDR_COL] = "hwaddr";
|
||||||
columns_[2] = "client_id";
|
columns_[CLIENT_ID_COL] = "client_id";
|
||||||
columns_[3] = "valid_lifetime";
|
columns_[VALID_LIFETIME_COL] = "valid_lifetime";
|
||||||
columns_[4] = "expire";
|
columns_[EXPIRE_COL] = "expire";
|
||||||
columns_[5] = "subnet_id";
|
columns_[SUBNET_ID_COL] = "subnet_id";
|
||||||
columns_[6] = "fqdn_fwd";
|
columns_[FQDN_FWD_COL] = "fqdn_fwd";
|
||||||
columns_[7] = "fqdn_rev";
|
columns_[FQDN_REV_COL] = "fqdn_rev";
|
||||||
columns_[8] = "hostname";
|
columns_[HOSTNAME_COL] = "hostname";
|
||||||
columns_[9] = "state";
|
columns_[STATE_COL] = "state";
|
||||||
columns_[10] = "user_context";
|
columns_[USER_CONTEXT_COL] = "user_context";
|
||||||
columns_[11] = "relay_id";
|
columns_[RELAY_ID_COL] = "relay_id";
|
||||||
columns_[12] = "remote_id";
|
columns_[REMOTE_ID_COL] = "remote_id";
|
||||||
columns_[13] = "pool_id";
|
columns_[POOL_ID_COL] = "pool_id";
|
||||||
BOOST_STATIC_ASSERT(13 < LEASE_COLUMNS);
|
BOOST_STATIC_ASSERT(13 < LEASE_COLUMNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1140,7 +1159,32 @@ private:
|
|||||||
/// in all MySqlLeaseMgr::xxx6() calls where it is used.
|
/// in all MySqlLeaseMgr::xxx6() calls where it is used.
|
||||||
|
|
||||||
class MySqlLease6Exchange : public MySqlLeaseExchange {
|
class MySqlLease6Exchange : public MySqlLeaseExchange {
|
||||||
/// @brief Set number of database columns for this lease structure
|
/// @brief Column numbers for each column in the Lease6 table.
|
||||||
|
/// These are used for both retrieving data and for looking up
|
||||||
|
/// column labels for logging. Note that their numeric order
|
||||||
|
/// MUST match that of the column order in the Lease6 table.
|
||||||
|
//@{
|
||||||
|
static const size_t ADDRESS_COL = 0;
|
||||||
|
static const size_t DUID_COL = 1;
|
||||||
|
static const size_t VALID_LIFETIME_COL = 2;
|
||||||
|
static const size_t EXPIRE_COL = 3;
|
||||||
|
static const size_t SUBNET_ID_COL = 4;
|
||||||
|
static const size_t PREF_LIFETIME_COL = 5;
|
||||||
|
static const size_t LEASE_TYPE_COL = 6;
|
||||||
|
static const size_t IAID_COL = 7;
|
||||||
|
static const size_t PREFIX_LEN_COL = 8;
|
||||||
|
static const size_t FQDN_FWD_COL = 9;
|
||||||
|
static const size_t FQDN_REV_COL = 10;
|
||||||
|
static const size_t HOSTNAME_COL = 11;
|
||||||
|
static const size_t HWADDR_COL = 12;
|
||||||
|
static const size_t HWTYPE_COL = 13;
|
||||||
|
static const size_t HWADDR_SOURCE_COL = 14;
|
||||||
|
static const size_t STATE_COL = 15;
|
||||||
|
static const size_t USER_CONTEXT_COL = 16;
|
||||||
|
static const size_t POOL_ID_COL = 17;
|
||||||
|
static const size_t BINADDR_COL = 18;
|
||||||
|
//@}
|
||||||
|
/// @brief Number of columns in the table holding DHCPv6 leases.
|
||||||
static const size_t LEASE_COLUMNS = 19;
|
static const size_t LEASE_COLUMNS = 19;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -1165,25 +1209,25 @@ public:
|
|||||||
std::fill(&error_[0], &error_[LEASE_COLUMNS], MLM_FALSE);
|
std::fill(&error_[0], &error_[LEASE_COLUMNS], MLM_FALSE);
|
||||||
|
|
||||||
// Set the column names (for error messages)
|
// Set the column names (for error messages)
|
||||||
columns_[0] = "address";
|
columns_[ADDRESS_COL] = "address";
|
||||||
columns_[1] = "duid";
|
columns_[DUID_COL] = "duid";
|
||||||
columns_[2] = "valid_lifetime";
|
columns_[VALID_LIFETIME_COL] = "valid_lifetime";
|
||||||
columns_[3] = "expire";
|
columns_[EXPIRE_COL] = "expire";
|
||||||
columns_[4] = "subnet_id";
|
columns_[SUBNET_ID_COL] = "subnet_id";
|
||||||
columns_[5] = "pref_lifetime";
|
columns_[PREF_LIFETIME_COL] = "pref_lifetime";
|
||||||
columns_[6] = "lease_type";
|
columns_[LEASE_TYPE_COL] = "lease_type";
|
||||||
columns_[7] = "iaid";
|
columns_[IAID_COL] = "iaid";
|
||||||
columns_[8] = "prefix_len";
|
columns_[PREFIX_LEN_COL] = "prefix_len";
|
||||||
columns_[9] = "fqdn_fwd";
|
columns_[FQDN_FWD_COL] = "fqdn_fwd";
|
||||||
columns_[10] = "fqdn_rev";
|
columns_[FQDN_REV_COL] = "fqdn_rev";
|
||||||
columns_[11] = "hostname";
|
columns_[HOSTNAME_COL] = "hostname";
|
||||||
columns_[12] = "hwaddr";
|
columns_[HWADDR_COL] = "hwaddr";
|
||||||
columns_[13] = "hwtype";
|
columns_[HWTYPE_COL] = "hwtype";
|
||||||
columns_[14] = "hwaddr_source";
|
columns_[HWADDR_SOURCE_COL] = "hwaddr_source";
|
||||||
columns_[15] = "state";
|
columns_[STATE_COL] = "state";
|
||||||
columns_[16] = "user_context";
|
columns_[USER_CONTEXT_COL] = "user_context";
|
||||||
columns_[17] = "binaddr";
|
columns_[POOL_ID_COL] = "pool_id";
|
||||||
columns_[18] = "pool_id";
|
columns_[BINADDR_COL] = "binaddr";
|
||||||
BOOST_STATIC_ASSERT(18 < LEASE_COLUMNS);
|
BOOST_STATIC_ASSERT(18 < LEASE_COLUMNS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1427,6 +1471,14 @@ public:
|
|||||||
bind_[16].buffer_type = MYSQL_TYPE_NULL;
|
bind_[16].buffer_type = MYSQL_TYPE_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pool_id: unsigned int
|
||||||
|
// Can use lease_->pool_id_ directly as it is of type uint32_t.
|
||||||
|
bind_[17].buffer_type = MYSQL_TYPE_LONG;
|
||||||
|
bind_[17].buffer = reinterpret_cast<char*>(&lease_->pool_id_);
|
||||||
|
bind_[17].is_unsigned = MLM_TRUE;
|
||||||
|
// bind_[17].is_null = &MLM_FALSE; // commented out for performance
|
||||||
|
// reasons, see memset() above
|
||||||
|
|
||||||
// binaddr: binary(16)
|
// binaddr: binary(16)
|
||||||
binaddr_ = lease->addr_.toBytes();
|
binaddr_ = lease->addr_.toBytes();
|
||||||
if (binaddr_.size() != 16) {
|
if (binaddr_.size() != 16) {
|
||||||
@@ -1434,18 +1486,10 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
binaddr_length_ = 16;
|
binaddr_length_ = 16;
|
||||||
bind_[17].buffer_type = MYSQL_TYPE_BLOB;
|
bind_[18].buffer_type = MYSQL_TYPE_BLOB;
|
||||||
bind_[17].buffer = reinterpret_cast<char*>(&binaddr_[0]);
|
bind_[18].buffer = reinterpret_cast<char*>(&binaddr_[0]);
|
||||||
bind_[17].buffer_length = 16;
|
bind_[18].buffer_length = 16;
|
||||||
bind_[17].length = &binaddr_length_;
|
bind_[18].length = &binaddr_length_;
|
||||||
// bind_[17].is_null = &MLM_FALSE; // commented out for performance
|
|
||||||
// reasons, see memset() above
|
|
||||||
|
|
||||||
// pool_id: unsigned int
|
|
||||||
// Can use lease_->pool_id_ directly as it is of type uint32_t.
|
|
||||||
bind_[18].buffer_type = MYSQL_TYPE_LONG;
|
|
||||||
bind_[18].buffer = reinterpret_cast<char*>(&lease_->pool_id_);
|
|
||||||
bind_[18].is_unsigned = MLM_TRUE;
|
|
||||||
// bind_[18].is_null = &MLM_FALSE; // commented out for performance
|
// bind_[18].is_null = &MLM_FALSE; // commented out for performance
|
||||||
// reasons, see memset() above
|
// reasons, see memset() above
|
||||||
|
|
||||||
|
@@ -367,7 +367,7 @@ PgSqlTaggedStatement tagged_statements[] = {
|
|||||||
"extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
|
"extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
|
||||||
"lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
|
"lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
|
||||||
"hwaddr, hwtype, hwaddr_source, "
|
"hwaddr, hwtype, hwaddr_source, "
|
||||||
"state, user_context "
|
"state, user_context, pool_id "
|
||||||
"FROM lease6 "
|
"FROM lease6 "
|
||||||
"WHERE address > $1 AND binaddr IS NULL "
|
"WHERE address > $1 AND binaddr IS NULL "
|
||||||
"ORDER BY address "
|
"ORDER BY address "
|
||||||
@@ -427,7 +427,7 @@ PgSqlTaggedStatement tagged_statements[] = {
|
|||||||
"extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
|
"extract(epoch from expire)::bigint, subnet_id, pref_lifetime, "
|
||||||
"lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
|
"lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
|
||||||
"hwaddr, hwtype, hwaddr_source, "
|
"hwaddr, hwtype, hwaddr_source, "
|
||||||
"state, user_context "
|
"state, user_context, pool_id "
|
||||||
"FROM lease6 "
|
"FROM lease6 "
|
||||||
"WHERE binaddr IS NOT NULL "
|
"WHERE binaddr IS NOT NULL "
|
||||||
"AND binaddr BETWEEN $1 and $2 "
|
"AND binaddr BETWEEN $1 and $2 "
|
||||||
@@ -448,13 +448,13 @@ PgSqlTaggedStatement tagged_statements[] = {
|
|||||||
{ 19, { OID_VARCHAR, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
|
{ 19, { OID_VARCHAR, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8,
|
||||||
OID_INT8, OID_INT2, OID_INT8, OID_INT2, OID_BOOL, OID_BOOL,
|
OID_INT8, OID_INT2, OID_INT8, OID_INT2, OID_BOOL, OID_BOOL,
|
||||||
OID_VARCHAR, OID_BYTEA, OID_INT2, OID_INT2, OID_INT8, OID_TEXT,
|
OID_VARCHAR, OID_BYTEA, OID_INT2, OID_INT2, OID_INT8, OID_TEXT,
|
||||||
OID_BYTEA, OID_INT8},
|
OID_INT8, OID_BYTEA },
|
||||||
"insert_lease6",
|
"insert_lease6",
|
||||||
"INSERT INTO lease6(address, duid, valid_lifetime, "
|
"INSERT INTO lease6(address, duid, valid_lifetime, "
|
||||||
"expire, subnet_id, pref_lifetime, "
|
"expire, subnet_id, pref_lifetime, "
|
||||||
"lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
|
"lease_type, iaid, prefix_len, fqdn_fwd, fqdn_rev, hostname, "
|
||||||
"hwaddr, hwtype, hwaddr_source, "
|
"hwaddr, hwtype, hwaddr_source, "
|
||||||
"state, user_context, binaddr, pool_id) "
|
"state, user_context, pool_id, binaddr) "
|
||||||
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)" },
|
"VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, $16, $17, $18, $19)" },
|
||||||
|
|
||||||
// UPDATE_LEASE4
|
// UPDATE_LEASE4
|
||||||
@@ -472,14 +472,14 @@ PgSqlTaggedStatement tagged_statements[] = {
|
|||||||
{ 21, { OID_VARCHAR, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8, OID_INT8,
|
{ 21, { OID_VARCHAR, OID_BYTEA, OID_INT8, OID_TIMESTAMP, OID_INT8, OID_INT8,
|
||||||
OID_INT2, OID_INT8, OID_INT2, OID_BOOL, OID_BOOL, OID_VARCHAR,
|
OID_INT2, OID_INT8, OID_INT2, OID_BOOL, OID_BOOL, OID_VARCHAR,
|
||||||
OID_BYTEA, OID_INT2, OID_INT2,
|
OID_BYTEA, OID_INT2, OID_INT2,
|
||||||
OID_INT8, OID_TEXT, OID_BYTEA, OID_INT8, OID_VARCHAR, OID_TIMESTAMP },
|
OID_INT8, OID_TEXT, OID_INT8, OID_BYTEA, OID_VARCHAR, OID_TIMESTAMP },
|
||||||
"update_lease6",
|
"update_lease6",
|
||||||
"UPDATE lease6 SET address = $1, duid = $2, "
|
"UPDATE lease6 SET address = $1, duid = $2, "
|
||||||
"valid_lifetime = $3, expire = $4, subnet_id = $5, "
|
"valid_lifetime = $3, expire = $4, subnet_id = $5, "
|
||||||
"pref_lifetime = $6, lease_type = $7, iaid = $8, "
|
"pref_lifetime = $6, lease_type = $7, iaid = $8, "
|
||||||
"prefix_len = $9, fqdn_fwd = $10, fqdn_rev = $11, hostname = $12, "
|
"prefix_len = $9, fqdn_fwd = $10, fqdn_rev = $11, hostname = $12, "
|
||||||
"hwaddr = $13, hwtype = $14, hwaddr_source = $15, "
|
"hwaddr = $13, hwtype = $14, hwaddr_source = $15, "
|
||||||
"state = $16, user_context = $17, binaddr = $18, pool_id = $19 "
|
"state = $16, user_context = $17, pool_id = $18, binaddr = $19 "
|
||||||
"WHERE address = $20 AND expire = $21" },
|
"WHERE address = $20 AND expire = $21" },
|
||||||
|
|
||||||
// ALL_LEASE4_STATS
|
// ALL_LEASE4_STATS
|
||||||
@@ -628,6 +628,7 @@ private:
|
|||||||
/// These are used for both retrieving data and for looking up
|
/// These are used for both retrieving data and for looking up
|
||||||
/// column labels for logging. Note that their numeric order
|
/// column labels for logging. Note that their numeric order
|
||||||
/// MUST match that of the column order in the Lease4 table.
|
/// MUST match that of the column order in the Lease4 table.
|
||||||
|
//@{
|
||||||
static const size_t ADDRESS_COL = 0;
|
static const size_t ADDRESS_COL = 0;
|
||||||
static const size_t HWADDR_COL = 1;
|
static const size_t HWADDR_COL = 1;
|
||||||
static const size_t CLIENT_ID_COL = 2;
|
static const size_t CLIENT_ID_COL = 2;
|
||||||
@@ -642,6 +643,7 @@ private:
|
|||||||
static const size_t RELAY_ID_COL = 11;
|
static const size_t RELAY_ID_COL = 11;
|
||||||
static const size_t REMOTE_ID_COL = 12;
|
static const size_t REMOTE_ID_COL = 12;
|
||||||
static const size_t POOL_ID_COL = 13;
|
static const size_t POOL_ID_COL = 13;
|
||||||
|
//@}
|
||||||
/// @brief Number of columns in the table holding DHCPv4 leases.
|
/// @brief Number of columns in the table holding DHCPv4 leases.
|
||||||
static const size_t LEASE_COLUMNS = 14;
|
static const size_t LEASE_COLUMNS = 14;
|
||||||
|
|
||||||
@@ -673,6 +675,7 @@ public:
|
|||||||
columns_.push_back("user_context");
|
columns_.push_back("user_context");
|
||||||
columns_.push_back("relay_id");
|
columns_.push_back("relay_id");
|
||||||
columns_.push_back("remote_id");
|
columns_.push_back("remote_id");
|
||||||
|
columns_.push_back("pool_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// @brief Creates the bind array for sending Lease4 data to the database.
|
/// @brief Creates the bind array for sending Lease4 data to the database.
|
||||||
@@ -915,8 +918,8 @@ private:
|
|||||||
static const size_t HWADDR_SOURCE_COL = 14;
|
static const size_t HWADDR_SOURCE_COL = 14;
|
||||||
static const size_t STATE_COL = 15;
|
static const size_t STATE_COL = 15;
|
||||||
static const size_t USER_CONTEXT_COL = 16;
|
static const size_t USER_CONTEXT_COL = 16;
|
||||||
static const size_t BINADDR_COL = 17;
|
static const size_t POOL_ID_COL = 17;
|
||||||
static const size_t POOL_ID_COL = 18;
|
static const size_t BINADDR_COL = 18;
|
||||||
//@}
|
//@}
|
||||||
/// @brief Number of columns in the table holding DHCPv6 leases.
|
/// @brief Number of columns in the table holding DHCPv6 leases.
|
||||||
static const size_t LEASE_COLUMNS = 19;
|
static const size_t LEASE_COLUMNS = 19;
|
||||||
@@ -976,6 +979,10 @@ public:
|
|||||||
columns_.push_back("hwaddr_source");
|
columns_.push_back("hwaddr_source");
|
||||||
columns_.push_back("state");
|
columns_.push_back("state");
|
||||||
columns_.push_back("user_context");
|
columns_.push_back("user_context");
|
||||||
|
columns_.push_back("pool_id");
|
||||||
|
// all columns that are used in insert/update queries but are not also
|
||||||
|
// used in select queries must be added last - the next column is the
|
||||||
|
// first of this kind
|
||||||
columns_.push_back("binaddr");
|
columns_.push_back("binaddr");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1092,11 +1099,11 @@ public:
|
|||||||
}
|
}
|
||||||
bind_array.add(user_context_);
|
bind_array.add(user_context_);
|
||||||
|
|
||||||
addr_bin_ = lease_->addr_.toBytes();
|
|
||||||
bind_array.add(addr_bin_);
|
|
||||||
|
|
||||||
pool_id_str_ = boost::lexical_cast<std::string>(lease->pool_id_);
|
pool_id_str_ = boost::lexical_cast<std::string>(lease->pool_id_);
|
||||||
bind_array.add(pool_id_str_);
|
bind_array.add(pool_id_str_);
|
||||||
|
|
||||||
|
addr_bin_ = lease_->addr_.toBytes();
|
||||||
|
bind_array.add(addr_bin_);
|
||||||
} catch (const std::exception& ex) {
|
} catch (const std::exception& ex) {
|
||||||
isc_throw(DbOperationError,
|
isc_throw(DbOperationError,
|
||||||
"Could not create bind array from Lease6: "
|
"Could not create bind array from Lease6: "
|
||||||
|
@@ -5188,118 +5188,6 @@ ALTER TABLE lease6
|
|||||||
|
|
||||||
UPDATE lease6 SET duid = UNHEX('000000') WHERE duid = UNHEX('00');
|
UPDATE lease6 SET duid = UNHEX('000000') WHERE duid = UNHEX('00');
|
||||||
|
|
||||||
-- Drop and create lease4Upload stored procedure with 255 bytes long client_id.
|
|
||||||
DROP PROCEDURE IF EXISTS lease4Upload;
|
|
||||||
|
|
||||||
-- Create a procedure that inserts a v4 lease from memfile data.
|
|
||||||
DELIMITER $$
|
|
||||||
CREATE PROCEDURE lease4Upload(
|
|
||||||
IN address VARCHAR(15),
|
|
||||||
IN hwaddr VARCHAR(20),
|
|
||||||
IN client_id VARCHAR(255),
|
|
||||||
IN valid_lifetime INT UNSIGNED,
|
|
||||||
IN expire BIGINT UNSIGNED,
|
|
||||||
IN subnet_id INT UNSIGNED,
|
|
||||||
IN fqdn_fwd TINYINT,
|
|
||||||
IN fqdn_rev TINYINT,
|
|
||||||
IN hostname VARCHAR(255),
|
|
||||||
IN state INT UNSIGNED,
|
|
||||||
IN user_context TEXT
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO lease4 (
|
|
||||||
address,
|
|
||||||
hwaddr,
|
|
||||||
client_id,
|
|
||||||
valid_lifetime,
|
|
||||||
expire,
|
|
||||||
subnet_id,
|
|
||||||
fqdn_fwd,
|
|
||||||
fqdn_rev,
|
|
||||||
hostname,
|
|
||||||
state,
|
|
||||||
user_context
|
|
||||||
) VALUES (
|
|
||||||
INET_ATON(address),
|
|
||||||
UNHEX(REPLACE(hwaddr, ':', '')),
|
|
||||||
UNHEX(REPLACE(client_id, ':', '')),
|
|
||||||
valid_lifetime,
|
|
||||||
FROM_UNIXTIME(expire),
|
|
||||||
subnet_id,
|
|
||||||
fqdn_fwd,
|
|
||||||
fqdn_rev,
|
|
||||||
REPLACE(hostname, ',', ','),
|
|
||||||
state,
|
|
||||||
REPLACE(user_context, ',', ',')
|
|
||||||
);
|
|
||||||
END $$
|
|
||||||
DELIMITER ;
|
|
||||||
|
|
||||||
-- Drop and create lease6Upload stored procedure with 130 bytes long duid.
|
|
||||||
DROP PROCEDURE IF EXISTS lease6Upload;
|
|
||||||
|
|
||||||
-- Create a procedure that inserts a v6 lease from memfile data.
|
|
||||||
DELIMITER $$
|
|
||||||
CREATE PROCEDURE lease6Upload(
|
|
||||||
IN address VARCHAR(39),
|
|
||||||
IN duid VARCHAR(130),
|
|
||||||
IN valid_lifetime INT UNSIGNED,
|
|
||||||
IN expire BIGINT UNSIGNED,
|
|
||||||
IN subnet_id INT UNSIGNED,
|
|
||||||
IN pref_lifetime INT UNSIGNED,
|
|
||||||
IN lease_type TINYINT,
|
|
||||||
IN iaid INT UNSIGNED,
|
|
||||||
IN prefix_len TINYINT UNSIGNED,
|
|
||||||
IN fqdn_fwd TINYINT,
|
|
||||||
IN fqdn_rev TINYINT,
|
|
||||||
IN hostname VARCHAR(255),
|
|
||||||
IN hwaddr VARCHAR(64),
|
|
||||||
IN state INT UNSIGNED,
|
|
||||||
IN user_context TEXT,
|
|
||||||
IN hwtype SMALLINT,
|
|
||||||
IN hwaddr_source INT UNSIGNED
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO lease6 (
|
|
||||||
address,
|
|
||||||
duid,
|
|
||||||
valid_lifetime,
|
|
||||||
expire,
|
|
||||||
subnet_id,
|
|
||||||
pref_lifetime,
|
|
||||||
lease_type,
|
|
||||||
iaid,
|
|
||||||
prefix_len,
|
|
||||||
fqdn_fwd,
|
|
||||||
fqdn_rev,
|
|
||||||
hostname,
|
|
||||||
hwaddr,
|
|
||||||
state,
|
|
||||||
user_context,
|
|
||||||
hwtype,
|
|
||||||
hwaddr_source
|
|
||||||
) VALUES (
|
|
||||||
address,
|
|
||||||
UNHEX(REPLACE(duid, ':', '')),
|
|
||||||
valid_lifetime,
|
|
||||||
FROM_UNIXTIME(expire),
|
|
||||||
subnet_id,
|
|
||||||
pref_lifetime,
|
|
||||||
lease_type,
|
|
||||||
iaid,
|
|
||||||
prefix_len,
|
|
||||||
fqdn_fwd,
|
|
||||||
fqdn_rev,
|
|
||||||
REPLACE(hostname, ',', ','),
|
|
||||||
UNHEX(REPLACE(hwaddr, ':', '')),
|
|
||||||
state,
|
|
||||||
REPLACE(user_context, ',', ','),
|
|
||||||
hwtype,
|
|
||||||
hwaddr_source
|
|
||||||
);
|
|
||||||
END $$
|
|
||||||
DELIMITER ;
|
|
||||||
|
|
||||||
-- Add the binary version of the IPv6 address for v6 BLQ prefix filter.
|
-- Add the binary version of the IPv6 address for v6 BLQ prefix filter.
|
||||||
ALTER TABLE lease6
|
ALTER TABLE lease6
|
||||||
ADD COLUMN binaddr BINARY(16) DEFAULT NULL;
|
ADD COLUMN binaddr BINARY(16) DEFAULT NULL;
|
||||||
@@ -5420,7 +5308,7 @@ BEGIN
|
|||||||
UPDATE lease4_pool_stat
|
UPDATE lease4_pool_stat
|
||||||
SET leases = IF(leases > 0, leases - 1, 0)
|
SET leases = IF(leases > 0, leases - 1, 0)
|
||||||
WHERE subnet_id = old_subnet_id AND pool_id = old_pool_id
|
WHERE subnet_id = old_subnet_id AND pool_id = old_pool_id
|
||||||
AND old_state = state;
|
AND state = old_state;
|
||||||
END IF;
|
END IF;
|
||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
@@ -5601,7 +5489,7 @@ SELECT 'address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_r
|
|||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Modify the procedure to output a memfile-ready CSV file.
|
-- Adding support for pool ID in procedure to output a memfile-ready CSV file.
|
||||||
DROP PROCEDURE IF EXISTS lease4DumpData;
|
DROP PROCEDURE IF EXISTS lease4DumpData;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE lease4DumpData()
|
CREATE PROCEDURE lease4DumpData()
|
||||||
@@ -5632,7 +5520,7 @@ BEGIN
|
|||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Modify the procedure to output a memfile-ready CSV file.
|
-- Adding support for pool ID in procedure to output a memfile-ready CSV file.
|
||||||
DROP PROCEDURE IF EXISTS lease6DumpData;
|
DROP PROCEDURE IF EXISTS lease6DumpData;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE lease6DumpData()
|
CREATE PROCEDURE lease6DumpData()
|
||||||
@@ -5661,13 +5549,13 @@ BEGIN
|
|||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Create a procedure that inserts a v4 lease from memfile data.
|
-- Drop and create lease4Upload stored procedure with 255 bytes long client_id and support for pool_id.
|
||||||
DROP PROCEDURE IF EXISTS lease4Upload;
|
DROP PROCEDURE IF EXISTS lease4Upload;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE lease4Upload(
|
CREATE PROCEDURE lease4Upload(
|
||||||
IN address VARCHAR(15),
|
IN address VARCHAR(15),
|
||||||
IN hwaddr VARCHAR(20),
|
IN hwaddr VARCHAR(20),
|
||||||
IN client_id VARCHAR(128),
|
IN client_id VARCHAR(255),
|
||||||
IN valid_lifetime INT UNSIGNED,
|
IN valid_lifetime INT UNSIGNED,
|
||||||
IN expire BIGINT UNSIGNED,
|
IN expire BIGINT UNSIGNED,
|
||||||
IN subnet_id INT UNSIGNED,
|
IN subnet_id INT UNSIGNED,
|
||||||
@@ -5709,12 +5597,12 @@ BEGIN
|
|||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Create a procedure that inserts a v6 lease from memfile data.
|
-- Drop and create lease6Upload stored procedure with 130 bytes long duid and support for pool_id.
|
||||||
DROP PROCEDURE IF EXISTS lease6Upload;
|
DROP PROCEDURE IF EXISTS lease6Upload;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE lease6Upload(
|
CREATE PROCEDURE lease6Upload(
|
||||||
IN address VARCHAR(39),
|
IN address VARCHAR(39),
|
||||||
IN duid VARCHAR(128),
|
IN duid VARCHAR(130),
|
||||||
IN valid_lifetime INT UNSIGNED,
|
IN valid_lifetime INT UNSIGNED,
|
||||||
IN expire BIGINT UNSIGNED,
|
IN expire BIGINT UNSIGNED,
|
||||||
IN subnet_id INT UNSIGNED,
|
IN subnet_id INT UNSIGNED,
|
||||||
|
@@ -76,118 +76,6 @@ ALTER TABLE lease6
|
|||||||
|
|
||||||
UPDATE lease6 SET duid = UNHEX('000000') WHERE duid = UNHEX('00');
|
UPDATE lease6 SET duid = UNHEX('000000') WHERE duid = UNHEX('00');
|
||||||
|
|
||||||
-- Drop and create lease4Upload stored procedure with 255 bytes long client_id.
|
|
||||||
DROP PROCEDURE IF EXISTS lease4Upload;
|
|
||||||
|
|
||||||
-- Create a procedure that inserts a v4 lease from memfile data.
|
|
||||||
DELIMITER $$
|
|
||||||
CREATE PROCEDURE lease4Upload(
|
|
||||||
IN address VARCHAR(15),
|
|
||||||
IN hwaddr VARCHAR(20),
|
|
||||||
IN client_id VARCHAR(255),
|
|
||||||
IN valid_lifetime INT UNSIGNED,
|
|
||||||
IN expire BIGINT UNSIGNED,
|
|
||||||
IN subnet_id INT UNSIGNED,
|
|
||||||
IN fqdn_fwd TINYINT,
|
|
||||||
IN fqdn_rev TINYINT,
|
|
||||||
IN hostname VARCHAR(255),
|
|
||||||
IN state INT UNSIGNED,
|
|
||||||
IN user_context TEXT
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO lease4 (
|
|
||||||
address,
|
|
||||||
hwaddr,
|
|
||||||
client_id,
|
|
||||||
valid_lifetime,
|
|
||||||
expire,
|
|
||||||
subnet_id,
|
|
||||||
fqdn_fwd,
|
|
||||||
fqdn_rev,
|
|
||||||
hostname,
|
|
||||||
state,
|
|
||||||
user_context
|
|
||||||
) VALUES (
|
|
||||||
INET_ATON(address),
|
|
||||||
UNHEX(REPLACE(hwaddr, ':', '')),
|
|
||||||
UNHEX(REPLACE(client_id, ':', '')),
|
|
||||||
valid_lifetime,
|
|
||||||
FROM_UNIXTIME(expire),
|
|
||||||
subnet_id,
|
|
||||||
fqdn_fwd,
|
|
||||||
fqdn_rev,
|
|
||||||
REPLACE(hostname, ',', ','),
|
|
||||||
state,
|
|
||||||
REPLACE(user_context, ',', ',')
|
|
||||||
);
|
|
||||||
END $$
|
|
||||||
DELIMITER ;
|
|
||||||
|
|
||||||
-- Drop and create lease6Upload stored procedure with 130 bytes long duid.
|
|
||||||
DROP PROCEDURE IF EXISTS lease6Upload;
|
|
||||||
|
|
||||||
-- Create a procedure that inserts a v6 lease from memfile data.
|
|
||||||
DELIMITER $$
|
|
||||||
CREATE PROCEDURE lease6Upload(
|
|
||||||
IN address VARCHAR(39),
|
|
||||||
IN duid VARCHAR(130),
|
|
||||||
IN valid_lifetime INT UNSIGNED,
|
|
||||||
IN expire BIGINT UNSIGNED,
|
|
||||||
IN subnet_id INT UNSIGNED,
|
|
||||||
IN pref_lifetime INT UNSIGNED,
|
|
||||||
IN lease_type TINYINT,
|
|
||||||
IN iaid INT UNSIGNED,
|
|
||||||
IN prefix_len TINYINT UNSIGNED,
|
|
||||||
IN fqdn_fwd TINYINT,
|
|
||||||
IN fqdn_rev TINYINT,
|
|
||||||
IN hostname VARCHAR(255),
|
|
||||||
IN hwaddr VARCHAR(64),
|
|
||||||
IN state INT UNSIGNED,
|
|
||||||
IN user_context TEXT,
|
|
||||||
IN hwtype SMALLINT,
|
|
||||||
IN hwaddr_source INT UNSIGNED
|
|
||||||
)
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO lease6 (
|
|
||||||
address,
|
|
||||||
duid,
|
|
||||||
valid_lifetime,
|
|
||||||
expire,
|
|
||||||
subnet_id,
|
|
||||||
pref_lifetime,
|
|
||||||
lease_type,
|
|
||||||
iaid,
|
|
||||||
prefix_len,
|
|
||||||
fqdn_fwd,
|
|
||||||
fqdn_rev,
|
|
||||||
hostname,
|
|
||||||
hwaddr,
|
|
||||||
state,
|
|
||||||
user_context,
|
|
||||||
hwtype,
|
|
||||||
hwaddr_source
|
|
||||||
) VALUES (
|
|
||||||
address,
|
|
||||||
UNHEX(REPLACE(duid, ':', '')),
|
|
||||||
valid_lifetime,
|
|
||||||
FROM_UNIXTIME(expire),
|
|
||||||
subnet_id,
|
|
||||||
pref_lifetime,
|
|
||||||
lease_type,
|
|
||||||
iaid,
|
|
||||||
prefix_len,
|
|
||||||
fqdn_fwd,
|
|
||||||
fqdn_rev,
|
|
||||||
REPLACE(hostname, ',', ','),
|
|
||||||
UNHEX(REPLACE(hwaddr, ':', '')),
|
|
||||||
state,
|
|
||||||
REPLACE(user_context, ',', ','),
|
|
||||||
hwtype,
|
|
||||||
hwaddr_source
|
|
||||||
);
|
|
||||||
END $$
|
|
||||||
DELIMITER ;
|
|
||||||
|
|
||||||
-- Add the binary version of the IPv6 address for v6 BLQ prefix filter.
|
-- Add the binary version of the IPv6 address for v6 BLQ prefix filter.
|
||||||
ALTER TABLE lease6
|
ALTER TABLE lease6
|
||||||
ADD COLUMN binaddr BINARY(16) DEFAULT NULL;
|
ADD COLUMN binaddr BINARY(16) DEFAULT NULL;
|
||||||
@@ -308,7 +196,7 @@ BEGIN
|
|||||||
UPDATE lease4_pool_stat
|
UPDATE lease4_pool_stat
|
||||||
SET leases = IF(leases > 0, leases - 1, 0)
|
SET leases = IF(leases > 0, leases - 1, 0)
|
||||||
WHERE subnet_id = old_subnet_id AND pool_id = old_pool_id
|
WHERE subnet_id = old_subnet_id AND pool_id = old_pool_id
|
||||||
AND old_state = state;
|
AND state = old_state;
|
||||||
END IF;
|
END IF;
|
||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
@@ -489,7 +377,7 @@ SELECT 'address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_r
|
|||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Modify the procedure to output a memfile-ready CSV file.
|
-- Adding support for pool ID in procedure to output a memfile-ready CSV file.
|
||||||
DROP PROCEDURE IF EXISTS lease4DumpData;
|
DROP PROCEDURE IF EXISTS lease4DumpData;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE lease4DumpData()
|
CREATE PROCEDURE lease4DumpData()
|
||||||
@@ -520,7 +408,7 @@ BEGIN
|
|||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Modify the procedure to output a memfile-ready CSV file.
|
-- Adding support for pool ID in procedure to output a memfile-ready CSV file.
|
||||||
DROP PROCEDURE IF EXISTS lease6DumpData;
|
DROP PROCEDURE IF EXISTS lease6DumpData;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE lease6DumpData()
|
CREATE PROCEDURE lease6DumpData()
|
||||||
@@ -549,13 +437,13 @@ BEGIN
|
|||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Create a procedure that inserts a v4 lease from memfile data.
|
-- Drop and create lease4Upload stored procedure with 255 bytes long client_id and support for pool_id.
|
||||||
DROP PROCEDURE IF EXISTS lease4Upload;
|
DROP PROCEDURE IF EXISTS lease4Upload;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE lease4Upload(
|
CREATE PROCEDURE lease4Upload(
|
||||||
IN address VARCHAR(15),
|
IN address VARCHAR(15),
|
||||||
IN hwaddr VARCHAR(20),
|
IN hwaddr VARCHAR(20),
|
||||||
IN client_id VARCHAR(128),
|
IN client_id VARCHAR(255),
|
||||||
IN valid_lifetime INT UNSIGNED,
|
IN valid_lifetime INT UNSIGNED,
|
||||||
IN expire BIGINT UNSIGNED,
|
IN expire BIGINT UNSIGNED,
|
||||||
IN subnet_id INT UNSIGNED,
|
IN subnet_id INT UNSIGNED,
|
||||||
@@ -597,12 +485,12 @@ BEGIN
|
|||||||
END $$
|
END $$
|
||||||
DELIMITER ;
|
DELIMITER ;
|
||||||
|
|
||||||
-- Create a procedure that inserts a v6 lease from memfile data.
|
-- Drop and create lease6Upload stored procedure with 130 bytes long duid and support for pool_id.
|
||||||
DROP PROCEDURE IF EXISTS lease6Upload;
|
DROP PROCEDURE IF EXISTS lease6Upload;
|
||||||
DELIMITER $$
|
DELIMITER $$
|
||||||
CREATE PROCEDURE lease6Upload(
|
CREATE PROCEDURE lease6Upload(
|
||||||
IN address VARCHAR(39),
|
IN address VARCHAR(39),
|
||||||
IN duid VARCHAR(128),
|
IN duid VARCHAR(130),
|
||||||
IN valid_lifetime INT UNSIGNED,
|
IN valid_lifetime INT UNSIGNED,
|
||||||
IN expire BIGINT UNSIGNED,
|
IN expire BIGINT UNSIGNED,
|
||||||
IN subnet_id INT UNSIGNED,
|
IN subnet_id INT UNSIGNED,
|
||||||
|
@@ -5753,7 +5753,7 @@ BEGIN
|
|||||||
UPDATE lease4_pool_stat
|
UPDATE lease4_pool_stat
|
||||||
SET leases = GREATEST(leases - 1, 0)
|
SET leases = GREATEST(leases - 1, 0)
|
||||||
WHERE subnet_id = old_subnet_id AND pool_id = old_pool_id
|
WHERE subnet_id = old_subnet_id AND pool_id = old_pool_id
|
||||||
AND old_state = state;
|
AND state = old_state;
|
||||||
END IF;
|
END IF;
|
||||||
END;
|
END;
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
@@ -5914,7 +5914,7 @@ RETURNS text AS $$
|
|||||||
select cast('address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context,pool_id' as text) as result;
|
select cast('address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context,pool_id' as text) as result;
|
||||||
$$ LANGUAGE SQL;
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
-- Modify the function to output a memfile-ready CSV file.
|
-- Adding support for pool ID in function to output a memfile-ready CSV file.
|
||||||
-- Some columns that are SMALLINT in the lease4 table have their type promoted
|
-- Some columns that are SMALLINT in the lease4 table have their type promoted
|
||||||
-- to INT in the declaration of this function for backwards compatibility with
|
-- to INT in the declaration of this function for backwards compatibility with
|
||||||
-- PostgreSQL versions.
|
-- PostgreSQL versions.
|
||||||
@@ -5957,7 +5957,7 @@ RETURNS TEXT AS $$
|
|||||||
SELECT CAST('address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,state,user_context,hwtype,hwaddr_source,pool_id' AS TEXT) AS result;
|
SELECT CAST('address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,state,user_context,hwtype,hwaddr_source,pool_id' AS TEXT) AS result;
|
||||||
$$ LANGUAGE SQL;
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
-- Modify the function to output a memfile-ready CSV file.
|
-- Adding support for pool ID in function to output a memfile-ready CSV file.
|
||||||
-- Some columns that are SMALLINT in the lease6 table have their type promoted
|
-- Some columns that are SMALLINT in the lease6 table have their type promoted
|
||||||
-- to INT in the declaration of this function for backwards compatibility with
|
-- to INT in the declaration of this function for backwards compatibility with
|
||||||
-- PostgreSQL versions.
|
-- PostgreSQL versions.
|
||||||
@@ -6006,7 +6006,7 @@ RETURNS TABLE (
|
|||||||
ORDER BY address;
|
ORDER BY address;
|
||||||
$$ LANGUAGE SQL;
|
$$ LANGUAGE SQL;
|
||||||
|
|
||||||
-- Create a procedure that inserts a v4 lease from memfile data.
|
-- Adding support for pool id in function that inserts a v4 lease from memfile data.
|
||||||
-- Some columns that are SMALLINT in the lease4 table have their type promoted
|
-- Some columns that are SMALLINT in the lease4 table have their type promoted
|
||||||
-- to INT in the declaration of this function for backwards compatibility with
|
-- to INT in the declaration of this function for backwards compatibility with
|
||||||
-- PostgreSQL versions.
|
-- PostgreSQL versions.
|
||||||
@@ -6055,7 +6055,7 @@ BEGIN
|
|||||||
END
|
END
|
||||||
$$ LANGUAGE plpgsql;
|
$$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
-- Create a procedure that inserts a v6 lease from memfile data.
|
-- Adding support for pool id in function that inserts a v6 lease from memfile data.
|
||||||
-- Some columns that are SMALLINT in the lease6 table have their type promoted
|
-- Some columns that are SMALLINT in the lease6 table have their type promoted
|
||||||
-- to INT in the declaration of this function for backwards compatibility with
|
-- to INT in the declaration of this function for backwards compatibility with
|
||||||
-- PostgreSQL versions.
|
-- PostgreSQL versions.
|
||||||
|
@@ -156,7 +156,7 @@ BEGIN
|
|||||||
UPDATE lease4_pool_stat
|
UPDATE lease4_pool_stat
|
||||||
SET leases = GREATEST(leases - 1, 0)
|
SET leases = GREATEST(leases - 1, 0)
|
||||||
WHERE subnet_id = old_subnet_id AND pool_id = old_pool_id
|
WHERE subnet_id = old_subnet_id AND pool_id = old_pool_id
|
||||||
AND old_state = state;
|
AND state = old_state;
|
||||||
END IF;
|
END IF;
|
||||||
END;
|
END;
|
||||||
\$\$ LANGUAGE plpgsql;
|
\$\$ LANGUAGE plpgsql;
|
||||||
@@ -317,7 +317,7 @@ RETURNS text AS \$\$
|
|||||||
select cast('address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context,pool_id' as text) as result;
|
select cast('address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context,pool_id' as text) as result;
|
||||||
\$\$ LANGUAGE SQL;
|
\$\$ LANGUAGE SQL;
|
||||||
|
|
||||||
-- Modify the function to output a memfile-ready CSV file.
|
-- Adding support for pool ID in function to output a memfile-ready CSV file.
|
||||||
-- Some columns that are SMALLINT in the lease4 table have their type promoted
|
-- Some columns that are SMALLINT in the lease4 table have their type promoted
|
||||||
-- to INT in the declaration of this function for backwards compatibility with
|
-- to INT in the declaration of this function for backwards compatibility with
|
||||||
-- PostgreSQL versions.
|
-- PostgreSQL versions.
|
||||||
@@ -360,7 +360,7 @@ RETURNS TEXT AS \$\$
|
|||||||
SELECT CAST('address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,state,user_context,hwtype,hwaddr_source,pool_id' AS TEXT) AS result;
|
SELECT CAST('address,duid,valid_lifetime,expire,subnet_id,pref_lifetime,lease_type,iaid,prefix_len,fqdn_fwd,fqdn_rev,hostname,hwaddr,state,user_context,hwtype,hwaddr_source,pool_id' AS TEXT) AS result;
|
||||||
\$\$ LANGUAGE SQL;
|
\$\$ LANGUAGE SQL;
|
||||||
|
|
||||||
-- Modify the function to output a memfile-ready CSV file.
|
-- Adding support for pool ID in function to output a memfile-ready CSV file.
|
||||||
-- Some columns that are SMALLINT in the lease6 table have their type promoted
|
-- Some columns that are SMALLINT in the lease6 table have their type promoted
|
||||||
-- to INT in the declaration of this function for backwards compatibility with
|
-- to INT in the declaration of this function for backwards compatibility with
|
||||||
-- PostgreSQL versions.
|
-- PostgreSQL versions.
|
||||||
@@ -409,7 +409,7 @@ RETURNS TABLE (
|
|||||||
ORDER BY address;
|
ORDER BY address;
|
||||||
\$\$ LANGUAGE SQL;
|
\$\$ LANGUAGE SQL;
|
||||||
|
|
||||||
-- Create a procedure that inserts a v4 lease from memfile data.
|
-- Adding support for pool id in function that inserts a v4 lease from memfile data.
|
||||||
-- Some columns that are SMALLINT in the lease4 table have their type promoted
|
-- Some columns that are SMALLINT in the lease4 table have their type promoted
|
||||||
-- to INT in the declaration of this function for backwards compatibility with
|
-- to INT in the declaration of this function for backwards compatibility with
|
||||||
-- PostgreSQL versions.
|
-- PostgreSQL versions.
|
||||||
@@ -458,7 +458,7 @@ BEGIN
|
|||||||
END
|
END
|
||||||
\$\$ LANGUAGE plpgsql;
|
\$\$ LANGUAGE plpgsql;
|
||||||
|
|
||||||
-- Create a procedure that inserts a v6 lease from memfile data.
|
-- Adding support for pool id in function that inserts a v6 lease from memfile data.
|
||||||
-- Some columns that are SMALLINT in the lease6 table have their type promoted
|
-- Some columns that are SMALLINT in the lease6 table have their type promoted
|
||||||
-- to INT in the declaration of this function for backwards compatibility with
|
-- to INT in the declaration of this function for backwards compatibility with
|
||||||
-- PostgreSQL versions.
|
-- PostgreSQL versions.
|
||||||
|
Reference in New Issue
Block a user