-
Notifications
You must be signed in to change notification settings - Fork 0
SQLDriverConnect implementation #28
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
Conversation
cfe56a4 to
730a621
Compare
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.
SQLDriverConnect implementation
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.
SQLDisconnect implementation
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.
Can you check if disconnect() does proper clean-up of the connection? It should closes and drop statements on the connection and end any transactions.
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.
Yes, disconnect() doesn't close statements directly, but the destructor of all ODBCStatement objects from to the connection will be called after the m_statements.clear(); line. m_statements should contain all statements/transactions.
The implementation:
void ODBCConnection::disconnect() {
if (m_isConnected) {
// Ensure that all statements (and corresponding SPI statements) get cleaned
// up before terminating the SPI connection in case they need to be de-allocated in
// the reverse of the allocation order.
m_statements.clear();
m_spiConnection->Close();
m_isConnected = false;
}
}
...src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h
Outdated
Show resolved
Hide resolved
...src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h
Outdated
Show resolved
Hide resolved
...src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h
Outdated
Show resolved
Hide resolved
...src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h
Outdated
Show resolved
Hide resolved
...rc/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h
Outdated
Show resolved
Hide resolved
...rc/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h
Outdated
Show resolved
Hide resolved
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.
This should prompt the dialog based on the driverCompletion variable. Maybe leave integrating the actual dialog to a separate PR but setup the infrastructure and leave TODOs here.
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.
Good call, added TODOs
ccea21f to
a2c2cb5
Compare
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.
Fixed an issue where ExecuteWithDiagnostics attempts to get diagnostics from conn after conn is freed, and results in a seg fault error.
a2c2cb5 to
5dbdcbe
Compare
00d2e3a to
4fd1fe8
Compare
cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc
Outdated
Show resolved
Hide resolved
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.
Catch as const DriverException& if possible
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.
added const, since this is the only usage of DriverException in the file, I will leave the prefix driver::odbcabstraction as is
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.
Micro-optimization. Add a move-version of config.Set() (eg Set(const std::string& key, std::string&& value)) and call it Emplace(). Then use config.Emplace(key, std::move(value)) to avoid copying.
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.
Added Emplace and switched to use it
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.
Can you check if disconnect() does proper clean-up of the connection? It should closes and drop statements on the connection and end any transactions.
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.
This might need to be conditional based on driver manager. Also, this can be a string_view (and GetStringAttribute should probably be reworked to take in string_views?)
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.
I can use string_view here but will just keep using 3.80 as it works
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.
Updated code to make GetStringAttribute take string_views
eb16ca1 to
9672af8
Compare
alinaliBQ
left a comment
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.
@jduo I have addressed all comments
cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc
Outdated
Show resolved
Hide resolved
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.
added const, since this is the only usage of DriverException in the file, I will leave the prefix driver::odbcabstraction as is
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.
Added Emplace and switched to use it
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.
Yes, disconnect() doesn't close statements directly, but the destructor of all ODBCStatement objects from to the connection will be called after the m_statements.clear(); line. m_statements should contain all statements/transactions.
The implementation:
void ODBCConnection::disconnect() {
if (m_isConnected) {
// Ensure that all statements (and corresponding SPI statements) get cleaned
// up before terminating the SPI connection in case they need to be de-allocated in
// the reverse of the allocation order.
m_statements.clear();
m_spiConnection->Close();
m_isConnected = false;
}
}
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.
Updated code to make GetStringAttribute take string_views
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.
Shouldn't this be properties[copy]?
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.
copy holds a copy of the value, we still need to construct a std::string copy for key
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.
Use properties.emplace(std::move(copy), value))
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.
I misunderstood usage of emplace before, I have fixed this now. In SQLConnect, uid and pwd specified in DSN will take precedence
a7d8803 to
ef337f6
Compare
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.
Shouldn't we be using the execute with diagnostics wrapper here?
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.
There was a bug that I ran into and had to remove the wrapper. The issue is that ExecuteWithDiagnostics calls GetDiagnostics().HasError() at the end of lambda function execution, and it will assume that conn is still a valid pointer. But GetDiagnostics() will fail because conn has been destructed. I didn't find any exceptions to be thrown inside releaseConnection call so it should be ok
ab159f4 to
2779187
Compare
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.
Minor nit picking, but might be clearer to be passing in connection pointer instead of conn, even thought is pointing to same data.
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.
Good catch, I have moved the connection pointer creation code to be inside the ExecuteWithDiagnostics call so conn can still be passed
Implement stubs for SQLGetInfo, SQLGetDiagField and SQLGetDiagRec Separate RegisterDsn and UnregisterDsn from windows build Update code to save driver value from connection string Add ReadMes for ODBC and tests Fix test issues with string_view Address code reviews Update entry_points.cc to fix build issue Remove Dremio references Use emplace properly Address comment from Rob and add SQLDisconnect test case
c98f368 to
ce4a14e
Compare
|
All comments have been addressed. |
Implements SQLDriverConnect