-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ongoing fixes #356
Ongoing fixes #356
Changes from 16 commits
c8120b0
21bf870
e8d2507
dee1ef8
0c59a97
c7ff1e5
6341a97
b65ba52
7840059
a48fc58
703b666
4ab314c
4bfdda7
8b983ab
376c471
67b36ef
3a24d04
be6f4df
045ff6e
b1567af
ce0b113
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,20 @@ Connection::Connection(Environment & environment) | |
resetConfiguration(); | ||
} | ||
|
||
const TypeInfo & Connection::getTypeInfo(const std::string & type_name, const std::string & type_name_without_parameters) const { | ||
auto tmp_type_name = type_name; | ||
auto tmp_type_name_without_parameters = type_name_without_parameters; | ||
|
||
const auto tmp_type_without_parameters_id = convertUnparametrizedTypeNameToTypeId(tmp_type_name_without_parameters); | ||
|
||
if (huge_int_as_string && tmp_type_without_parameters_id == DataSourceTypeId::UInt64) { | ||
tmp_type_name = "String"; | ||
tmp_type_name_without_parameters = "String"; | ||
} | ||
|
||
return getParent().getTypeInfo(tmp_type_name, tmp_type_name_without_parameters); | ||
} | ||
|
||
void Connection::connect(const std::string & connection_string) { | ||
if (session && session->connected()) | ||
throw SqlException("Connection name in use", "08002"); | ||
|
@@ -132,6 +146,10 @@ void Connection::connect(const std::string & connection_string) { | |
session->setKeepAlive(true); | ||
session->setTimeout(Poco::Timespan(connection_timeout, 0), Poco::Timespan(timeout, 0), Poco::Timespan(timeout, 0)); | ||
session->setKeepAliveTimeout(Poco::Timespan(86400, 0)); | ||
|
||
if (verify_connection_early) { | ||
verifyConnection(); | ||
} | ||
} | ||
|
||
void Connection::resetConfiguration() { | ||
|
@@ -238,6 +256,13 @@ void Connection::setConfiguration(const key_value_map_t & cs_fields, const key_v | |
timeout = typed_value; | ||
} | ||
} | ||
else if (Poco::UTF8::icompare(key, INI_VERIFY_CONNECTION_EARLY) == 0) { | ||
recognized_key = true; | ||
valid_value = (value.empty() || isYesOrNo(value)); | ||
if (valid_value) { | ||
verify_connection_early = isYes(value); | ||
} | ||
} | ||
else if (Poco::UTF8::icompare(key, INI_SSLMODE) == 0) { | ||
recognized_key = true; | ||
valid_value = ( | ||
|
@@ -285,6 +310,13 @@ void Connection::setConfiguration(const key_value_map_t & cs_fields, const key_v | |
database = value; | ||
} | ||
} | ||
else if (Poco::UTF8::icompare(key, INI_HUGE_INT_AS_STRING) == 0) { | ||
recognized_key = true; | ||
valid_value = (value.empty() || isYesOrNo(value)); | ||
if (valid_value) { | ||
huge_int_as_string = isYes(value); | ||
} | ||
} | ||
else if (Poco::UTF8::icompare(key, INI_STRINGMAXLENGTH) == 0) { | ||
recognized_key = true; | ||
unsigned int typed_value = 0; | ||
|
@@ -445,6 +477,13 @@ void Connection::setConfiguration(const key_value_map_t & cs_fields, const key_v | |
stringmaxlength = TypeInfo::string_max_size; | ||
} | ||
|
||
void Connection::verifyConnection() { | ||
LOG("Verifying connection and credentials..."); | ||
auto & statement = allocateChild<Statement>(); | ||
statement.executeQuery("SELECT 1"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, I should have added a proper cleanup there. Will fix. |
||
statement.deallocateSelf(); | ||
} | ||
|
||
std::string Connection::buildCredentialsString() const { | ||
std::ostringstream user_password_base64; | ||
Poco::Base64Encoder base64_encoder(user_password_base64, Poco::BASE64_URL_ENCODING); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about other wide types, like
Int128
,UInt128
,Decimal128
and wider?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Int128
/UInt128
are not supported in the driver yet.Decimal128
is extracted as string or double anyway (there is no standard Decimal C type), so no need to alter the way it is reported to the ODBC clients.