15#include <boost/date_time/posix_time/conversion.hpp>
16#include <boost/date_time/posix_time/posix_time.hpp>
17#include <boost/shared_ptr.hpp>
20#include <mysqld_error.h>
51 static const enum_field_types
column_type = MYSQL_TYPE_STRING;
59 static const enum_field_types
column_type = MYSQL_TYPE_TIMESTAMP;
60 static const size_t length =
sizeof(MYSQL_TIME);
61 static const bool am_unsignged =
false;
169 return (bind_.buffer_type);
226 std::vector<uint8_t>
getBlob()
const;
258 const T* value =
reinterpret_cast<const T*
>(&buffer_[0]);
277 return (default_value);
326 boost::posix_time::ptime
377 template<
typename Iterator>
380 std::distance(begin, end)));
381 binding->setBufferValue(begin, end);
395 binding->setValue<T>(0);
411 binding->setValue(value);
507 MYSQL_TIME& output_time);
515 MYSQL_TIME& output_time);
537 const uint32_t valid_lifetime,
558 uint32_t valid_lifetime,
567 static boost::posix_time::ptime
579 MySqlBinding(enum_field_types buffer_type,
const size_t length);
589 template<
typename Iterator>
590 void setBufferValue(Iterator begin, Iterator end) {
591 length_ = std::distance(begin, end);
592 buffer_.assign(begin, end);
599 if (buffer_.empty()) {
602 bind_.buffer = &buffer_[0];
603 bind_.buffer_length = length_;
609 void setBufferLength(
const unsigned long length);
618 void setValue(T value) {
619 memcpy(
static_cast<void*
>(&buffer_[0]),
reinterpret_cast<char*
>(&value),
621 bind_.buffer = &buffer_[0];
629 void setTimestampValue(
const boost::posix_time::ptime& timestamp);
640 void validateAccess()
const {
643 isc_throw(InvalidOperation,
"retrieved value is null");
647 isc_throw(InvalidOperation,
"mismatched column type");
652 std::vector<uint8_t> buffer_;
655 unsigned long length_;
MySQL binding used in prepared statements.
static void convertFromDatabaseTime(const MYSQL_TIME &expire, uint32_t valid_lifetime, time_t &cltt)
Converts Database Time to Lease Times.
static MySqlBindingPtr condCreateBool(const util::Optional< bool > &value)
Conditionally creates binding of uint8_t type representing a boolean value if provided value is speci...
std::vector< uint8_t > getBlobOrDefault(const std::vector< uint8_t > &default_value) const
Returns value held in the binding as blob.
std::vector< uint8_t > getBlob() const
Returns value held in the binding as blob.
static MySqlBindingPtr condCreateString(const util::Optional< std::string > &value)
Conditionally creates binding of text type for sending data if provided value is unspecified.
static MySqlBindingPtr createString(const unsigned long length)
Creates binding of text type for receiving data.
static MySqlBindingPtr createInteger(T value)
Creates binding of numeric type for sending data.
T getIntegerOrDefault(T default_value) const
Returns numeric value held in the binding.
bool amNull() const
Checks if the bound value is NULL.
std::string getString() const
Returns value held in the binding as string.
static MySqlBindingPtr createInteger()
Creates binding of numeric type for receiving data.
data::ElementPtr getJSON() const
Returns value held in the binding as JSON.
std::string getStringOrDefault(const std::string &default_value) const
Returns value held in the binding as string.
static MySqlBindingPtr createBlob(Iterator begin, Iterator end)
Creates binding of blob type for sending data.
static MySqlBindingPtr createTimestamp()
Creates binding of timestamp type for receiving data.
enum_field_types getType() const
Returns MySQL column type for the binding.
static MySqlBindingPtr condCreateInteger(const util::Optional< T > &value)
Conditionally creates binding of numeric type for sending data if provided value is specified.
static MySqlBindingPtr createFloat(const float value)
Creates binding having a float type for sending data.
float getFloat() const
Returns float value held in the binding.
static MySqlBindingPtr createNull()
Creates binding encapsulating a NULL value.
MYSQL_BIND & getMySqlBinding()
Returns reference to the native binding.
bool getBool() const
Returns boolean value held in the binding.
static MySqlBindingPtr createBool()
Creates binding having a bool type for receiving data.
boost::posix_time::ptime getTimestamp() const
Returns timestamp value held in the binding.
static MySqlBindingPtr createBlob(const unsigned long length)
Creates binding of blob type for receiving data.
static void convertToDatabaseTime(const time_t input_time, MYSQL_TIME &output_time)
Converts time_t value to database time.
static MySqlBindingPtr condCreateIPv4Address(const util::Optional< asiolink::IOAddress > &value)
Conditionally creates binding of uint32_t type representing an IPv4 address if provided value is spec...
static MySqlBindingPtr condCreateFloat(const util::Optional< T > &value)
Conditionally creates binding of float type for sending data if provided value is specified.
T getInteger() const
Returns numeric value held in the binding.
boost::posix_time::ptime getTimestampOrDefault(const boost::posix_time::ptime &default_value) const
Returns timestamp value held in the binding.
A template representing an optional value.
T get() const
Retrieves the encapsulated value.
void unspecified(bool unspecified)
Modifies the flag that indicates whether the value is specified or unspecified.
#define isc_throw(type, stream)
A shortcut macro to insert known values into exception arguments.
boost::shared_ptr< Element > ElementPtr
const my_bool MLM_FALSE
MySQL false value.
boost::shared_ptr< MySqlBinding > MySqlBindingPtr
Shared pointer to the Binding class.
const my_bool MLM_TRUE
MySQL true value.
bool my_bool
my_bool type in MySQL 8.x.
std::vector< MySqlBindingPtr > MySqlBindingCollection
Collection of bindings.
Defines the logger used by the top-level component of kea-lfc.
Trait class for column types supported in MySQL.
static const size_t length
Length of data in this column.
static const bool am_unsigned
Boolean value indicating if the numeric value is unsigned.
static const enum_field_types column_type
Column type represented in MySQL C API.