2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-05 00:15:17 +00:00

[5469] Moved to composite index in C++ code too

This commit is contained in:
Francis Dupont
2018-01-17 19:28:57 +01:00
parent 04911b24ee
commit e0abc5ac7c
13 changed files with 96 additions and 42 deletions

View File

@@ -189,7 +189,7 @@ tagged_statements = { {
"FROM lease6 "
"WHERE duid = ? AND iaid = ? AND subnet_id = ? "
"AND lease_type = ?"},
{MySqlLeaseMgr::GET_LEASE6_SUBID,
{MySqlLeaseMgr::GET_LEASE6_SUBID_TYPE,
"SELECT address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
"lease_type, iaid, prefix_len, "
@@ -197,7 +197,7 @@ tagged_statements = { {
"hwaddr, hwtype, hwaddr_source, "
"state "
"FROM lease6 "
"WHERE subnet_id = ?"},
"WHERE subnet_id = ? and lease_type = ?"},
{MySqlLeaseMgr::GET_LEASE6_EXPIRE,
"SELECT address, duid, valid_lifetime, "
"expire, subnet_id, pref_lifetime, "
@@ -1927,12 +1927,14 @@ MySqlLeaseMgr::getLeases6(Lease::Type lease_type,
}
Lease6Collection
MySqlLeaseMgr::getLeases6(SubnetID subnet_id) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL, DHCPSRV_MYSQL_GET_SUBID6)
.arg(subnet_id);
MySqlLeaseMgr::getLeases6(SubnetID subnet_id, Lease::Type type) const {
LOG_DEBUG(dhcpsrv_logger, DHCPSRV_DBG_TRACE_DETAIL,
DHCPSRV_MYSQL_GET_SUBID_TYPE6)
.arg(subnet_id)
.arg(Lease::typeToText(type));
// Set up the WHERE clause value
MYSQL_BIND inbind[1];
MYSQL_BIND inbind[2];
memset(inbind, 0, sizeof(inbind));
// Subnet ID
@@ -1940,9 +1942,14 @@ MySqlLeaseMgr::getLeases6(SubnetID subnet_id) const {
inbind[0].buffer = reinterpret_cast<char*>(&subnet_id);
inbind[0].is_unsigned = MLM_TRUE;
// LEASE_TYPE
inbind[1].buffer_type = MYSQL_TYPE_TINY;
inbind[1].buffer = reinterpret_cast<char*>(&type);
inbind[1].is_unsigned = MLM_TRUE;
// ... and get the data
Lease6Collection result;
getLeaseCollection(GET_LEASE6_SUBID, inbind, result);
getLeaseCollection(GET_LEASE6_SUBID_TYPE, inbind, result);
return (result);
}