}
void
-MySqlLeaseMgr::deleteExtendedInfo6(const IOAddress& /* addr */) {
- isc_throw(NotImplemented, "MySqlLeaseMgr::deleteExtendedInfo6 not implemented");
+MySqlLeaseMgr::deleteExtendedInfo6(const IOAddress& addr) {
+ deleteRelayId6(addr);
+ deleteRemoteId6(addr);
+}
+
+void
+MySqlLeaseMgr::deleteRelayId6(const IOAddress& addr) {
+ // Get a context.
+ MySqlLeaseContextAlloc get_context(*this);
+ MySqlLeaseContextPtr ctx = get_context.ctx_;
+
+ // Bind the lease address.
+ MYSQL_BIND bind[1];
+ memset(bind, 0, sizeof(bind));
+
+ std::vector<uint8_t> addr_data = addr.toBytes();
+ // Do not check the address length as it does not really matter.
+ unsigned long addr_length = addr_data.size();
+ bind[0].buffer_type = MYSQL_TYPE_BLOB;
+ bind[0].buffer = reinterpret_cast<char*>(&addr_data[0]);
+ bind[0].buffer_length = addr_length;
+ bind[0].length = &addr_length;
+
+ // Delete from lease6_relay_id table.
+ StatementIndex stindex = DELETE_RELAY_ID6;
+
+ // Bind the input parameters to the statement.
+ int status = mysql_stmt_bind_param(ctx->conn_.statements_[stindex], bind);
+ checkError(ctx, status, stindex, "unable to bind WHERE clause parameter");
+
+ // Execute.
+ status = MysqlExecuteStatement(ctx->conn_.statements_[stindex]);
+ checkError(ctx, status, stindex, "unable to execute");
+}
+
+void
+MySqlLeaseMgr::deleteRemoteId6(const IOAddress& addr) {
+ // Get a context.
+ MySqlLeaseContextAlloc get_context(*this);
+ MySqlLeaseContextPtr ctx = get_context.ctx_;
+
+ // Bind the lease address.
+ MYSQL_BIND bind[1];
+ memset(bind, 0, sizeof(bind));
+
+ std::vector<uint8_t> addr_data = addr.toBytes();
+ // Do not check the address length as it does not really matter.
+ unsigned long addr_length = addr_data.size();
+ bind[0].buffer_type = MYSQL_TYPE_BLOB;
+ bind[0].buffer = reinterpret_cast<char*>(&addr_data[0]);
+ bind[0].buffer_length = addr_length;
+ bind[0].length = &addr_length;
+
+ // Delete from lease6_remote_id table.
+ StatementIndex stindex = DELETE_REMOTE_ID6;
+
+ // Bind the input parameters to the statement.
+ int status = mysql_stmt_bind_param(ctx->conn_.statements_[stindex], bind);
+ checkError(ctx, status, stindex, "unable to bind WHERE clause parameter");
+
+ // Execute.
+ status = MysqlExecuteStatement(ctx->conn_.statements_[stindex]);
+ checkError(ctx, status, stindex, "unable to execute");
}
void
int status, StatementIndex index,
const char* what) const;
+public:
/// The following queries are used to fulfill Bulk Lease Query
/// queries. They rely on relay data contained in lease's
/// user-context when the extended-store-info flag is enabled.
/// @brief Wipe by-relay-id table (v6).
virtual void wipeExtendedInfoTables6() override;
+private:
/// @brief Context RAII allocator.
class MySqlLeaseContextAlloc {
public:
const std::vector<uint8_t>& remote_id) override;
private:
+ /// @brief Delete lease6 extended info from by-relay-id table.
+ ///
+ /// @param addr The address of the lease.
+ void deleteRelayId6(const isc::asiolink::IOAddress& addr);
+
+ /// @brief Delete lease6 extended info from by-remote-id table.
+ ///
+ /// @param addr The address of the lease.
+ void deleteRemoteId6(const isc::asiolink::IOAddress& addr);
// Members
}
void
-PgSqlLeaseMgr::deleteExtendedInfo6(const IOAddress& /* addr */) {
- isc_throw(NotImplemented, "PgSqlLeaseMgr::deleteExtendedInfo6 not implemented");
+PgSqlLeaseMgr::deleteExtendedInfo6(const IOAddress& addr) {
+ deleteRelayId6(addr);
+ deleteRemoteId6(addr);
+}
+
+void
+PgSqlLeaseMgr::deleteRelayId6(const IOAddress& addr) {
+ // Set up the WHERE clause value.
+ PsqlBindArray bind_array;
+
+ std::vector<uint8_t> addr_data = addr.toBytes();
+ // Do not check the address length as it does not really matter.
+ bind_array.add(addr_data);
+
+ // Get a context.
+ PgSqlLeaseContextAlloc get_context(*this);
+ PgSqlLeaseContextPtr ctx = get_context.ctx_;
+
+ // Delete from lease6_relay_id table.
+ StatementIndex stindex = DELETE_RELAY_ID6;
+
+ PgSqlResult r(PQexecPrepared(ctx->conn_, tagged_statements[stindex].name,
+ tagged_statements[stindex].nbparams,
+ &bind_array.values_[0],
+ &bind_array.lengths_[0],
+ &bind_array.formats_[0], 0));
+
+ int s = PQresultStatus(r);
+
+ if (s != PGRES_COMMAND_OK) {
+ ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
+ }
+}
+
+void
+PgSqlLeaseMgr::deleteRemoteId6(const IOAddress& addr) {
+ // Set up the WHERE clause value.
+ PsqlBindArray bind_array;
+
+ std::vector<uint8_t> addr_data = addr.toBytes();
+ // Do not check the address length as it does not really matter.
+ bind_array.add(addr_data);
+
+ // Get a context.
+ PgSqlLeaseContextAlloc get_context(*this);
+ PgSqlLeaseContextPtr ctx = get_context.ctx_;
+
+ // Delete from lease6_remote_id table.
+ StatementIndex stindex = DELETE_REMOTE_ID6;
+
+ PgSqlResult r(PQexecPrepared(ctx->conn_, tagged_statements[stindex].name,
+ tagged_statements[stindex].nbparams,
+ &bind_array.values_[0],
+ &bind_array.lengths_[0],
+ &bind_array.formats_[0], 0));
+
+ int s = PQresultStatus(r);
+
+ if (s != PGRES_COMMAND_OK) {
+ ctx->conn_.checkStatementError(r, tagged_statements[stindex]);
+ }
}
void
std::string
checkLimits(isc::data::ConstElementPtr const& user_context, StatementIndex const stindex) const;
+public:
/// @brief Checks if the IPv4 lease limits set in the given user context are exceeded.
/// PostgreSQL implementation.
///
/// @brief Write V6 leases to a file.
virtual void writeLeases6(const std::string& /*filename*/) override;
+private:
/// @brief Context RAII allocator.
class PgSqlLeaseContextAlloc {
public:
const std::vector<uint8_t>& remote_id) override;
private:
+ /// @brief Delete lease6 extended info from by-relay-id table.
+ ///
+ /// @param addr The address of the lease.
+ void deleteRelayId6(const isc::asiolink::IOAddress& addr);
+
+ /// @brief Delete lease6 extended info from by-remote-id table.
+ ///
+ /// @param addr The address of the lease.
+ void deleteRemoteId6(const isc::asiolink::IOAddress& addr);
// Members