mirror of
https://github.com/rbock/sqlpp11.git
synced 2024-11-16 12:51:13 +08:00
MySQL SSL & read_timeout options, and bind blob result bugfix (#577)
This commit is contained in:
parent
f6cb4d311a
commit
e6bd90c489
@ -210,7 +210,7 @@ namespace sqlpp
|
|||||||
param.is_unsigned = false;
|
param.is_unsigned = false;
|
||||||
param.error = &meta_data.bound_error;
|
param.error = &meta_data.bound_error;
|
||||||
}
|
}
|
||||||
void _bind_blob_result(size_t index, const char** value, size_t* len)
|
void _bind_blob_result(size_t index, const uint8_t** value, size_t* len)
|
||||||
{
|
{
|
||||||
if (_handle->debug)
|
if (_handle->debug)
|
||||||
std::cerr << "MySQL debug: binding text result " << static_cast<const void*>(*value) << " at index: " << index
|
std::cerr << "MySQL debug: binding text result " << static_cast<const void*>(*value) << " at index: " << index
|
||||||
@ -220,7 +220,7 @@ namespace sqlpp
|
|||||||
meta_data.index = index;
|
meta_data.index = index;
|
||||||
meta_data.len = len;
|
meta_data.len = len;
|
||||||
meta_data.is_null = nullptr;
|
meta_data.is_null = nullptr;
|
||||||
meta_data.text_buffer = value;
|
meta_data.text_buffer = reinterpret_cast<const char **>(value);
|
||||||
if (meta_data.bound_text_buffer.empty())
|
if (meta_data.bound_text_buffer.empty())
|
||||||
meta_data.bound_text_buffer.resize(8);
|
meta_data.bound_text_buffer.resize(8);
|
||||||
|
|
||||||
@ -318,6 +318,9 @@ namespace sqlpp
|
|||||||
void _post_bind_text_result(size_t /* index */, const char** /* text */, size_t* /* len */)
|
void _post_bind_text_result(size_t /* index */, const char** /* text */, size_t* /* len */)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
void _post_bind_blob_result(size_t /* index */, const uint8_t** /* value */, size_t* /* len */)
|
||||||
|
{
|
||||||
|
}
|
||||||
void _post_bind_date_result(size_t index, ::sqlpp::chrono::day_point* value, bool* is_null)
|
void _post_bind_date_result(size_t index, ::sqlpp::chrono::day_point* value, bool* is_null)
|
||||||
{
|
{
|
||||||
if (_handle->debug)
|
if (_handle->debug)
|
||||||
|
@ -44,12 +44,18 @@ namespace sqlpp
|
|||||||
std::string charset{"utf8"};
|
std::string charset{"utf8"};
|
||||||
bool debug{false};
|
bool debug{false};
|
||||||
unsigned int connect_timeout_seconds{0}; // 0 = do not override MySQL library default
|
unsigned int connect_timeout_seconds{0}; // 0 = do not override MySQL library default
|
||||||
|
bool ssl{false};
|
||||||
|
std::string ssl_key, ssl_cert, ssl_ca, ssl_capath, ssl_cipher;
|
||||||
|
unsigned int read_timeout{0};
|
||||||
|
|
||||||
bool operator==(const connection_config& other) const
|
bool operator==(const connection_config& other) const
|
||||||
{
|
{
|
||||||
return (other.host == host and other.user == user and other.password == password and
|
return (other.host == host and other.user == user and other.password == password and
|
||||||
other.database == database and other.charset == charset and other.debug == debug and
|
other.database == database and other.charset == charset and other.debug == debug and
|
||||||
other.connect_timeout_seconds == connect_timeout_seconds);
|
other.connect_timeout_seconds == connect_timeout_seconds and other.ssl == ssl and
|
||||||
|
other.ssl_key == ssl_key and other.ssl_cert == ssl_cert and other.ssl_ca == ssl_ca and
|
||||||
|
other.ssl_capath == ssl_capath and other.ssl_cipher == ssl_cipher and
|
||||||
|
other.read_timeout == read_timeout);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(const connection_config& other) const
|
bool operator!=(const connection_config& other) const
|
||||||
|
@ -46,6 +46,36 @@ namespace sqlpp
|
|||||||
throw sqlpp::exception{"MySQL: could not set option MYSQL_OPT_CONNECT_TIMEOUT"};
|
throw sqlpp::exception{"MySQL: could not set option MYSQL_OPT_CONNECT_TIMEOUT"};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.read_timeout > 0 &&
|
||||||
|
mysql_options(mysql, MYSQL_OPT_READ_TIMEOUT, &config.read_timeout))
|
||||||
|
{
|
||||||
|
throw sqlpp::exception("MySQL: could not set option MYSQL_OPT_READ_TIMEOUT");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (config.ssl)
|
||||||
|
{
|
||||||
|
if (!config.ssl_key.empty() && mysql_options(mysql, MYSQL_OPT_SSL_KEY, config.ssl_key.c_str()))
|
||||||
|
{
|
||||||
|
throw sqlpp::exception("MySQL: could not set option MYSQL_OPT_SSL_KEY");
|
||||||
|
}
|
||||||
|
if (!config.ssl_cert.empty() && mysql_options(mysql, MYSQL_OPT_SSL_CERT, config.ssl_cert.c_str()))
|
||||||
|
{
|
||||||
|
throw sqlpp::exception("MySQL: could not set option MYSQL_OPT_SSL_CERT");
|
||||||
|
}
|
||||||
|
if (!config.ssl_ca.empty() && mysql_options(mysql, MYSQL_OPT_SSL_CA, config.ssl_ca.c_str()))
|
||||||
|
{
|
||||||
|
throw sqlpp::exception("MySQL: could not set option MYSQL_OPT_SSL_CA");
|
||||||
|
}
|
||||||
|
if (!config.ssl_capath.empty() && mysql_options(mysql, MYSQL_OPT_SSL_CAPATH, config.ssl_capath.c_str()))
|
||||||
|
{
|
||||||
|
throw sqlpp::exception("MySQL: could not set option MYSQL_OPT_SSL_CAPATH");
|
||||||
|
}
|
||||||
|
if (!config.ssl_cipher.empty() && mysql_options(mysql, MYSQL_OPT_SSL_CIPHER, config.ssl_cipher.c_str()))
|
||||||
|
{
|
||||||
|
throw sqlpp::exception("MySQL: could not set option MYSQL_OPT_SSL_CIPHER");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!mysql_real_connect(mysql, config.host.empty() ? nullptr : config.host.c_str(),
|
if (!mysql_real_connect(mysql, config.host.empty() ? nullptr : config.host.c_str(),
|
||||||
config.user.empty() ? nullptr : config.user.c_str(),
|
config.user.empty() ? nullptr : config.user.c_str(),
|
||||||
config.password.empty() ? nullptr : config.password.c_str(), nullptr, config.port,
|
config.password.empty() ? nullptr : config.password.c_str(), nullptr, config.port,
|
||||||
|
Loading…
Reference in New Issue
Block a user