-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[ODBC] Rework Connect to the ODBC driver and add functionality to set all DuckDB configurations in the Connection String #10692
Conversation
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.
Thanks for the PR! Looks good. Some comments from my side
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.
Looks great! I added a few nits.
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.
Thanks for the fixes! LGTM - some minor nits but nothing blocking, feel free to pick up if you want at some point in the future
SQLINTEGER *id = new SQLINTEGER[TABLE_SIZE[size[i]]]; | ||
SQLLEN *id_ind = new SQLLEN[TABLE_SIZE[size[i]]]; | ||
auto *id = new SQLINTEGER[TABLE_SIZE[i]]; | ||
auto *id_ind = new SQLLEN[TABLE_SIZE[i]]; |
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.
nit: using unique_ptr
here would clean up the code a bit and prevent memory from leaking in case of a failure
#include <utility> | ||
|
||
#if WIN32 | ||
#include <windows.h> |
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.
nit: we have duckdb/common/windows.hpp
that can be used for this
return SQL_SUCCESS; | ||
} | ||
|
||
while ((row_pos = input_str.find(ROW_DEL)) != std::string::npos) { |
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.
nit: I think this code could be simplified somewhat by using StringUtil::Split
SQLRETURN Connect::FindKeyValPair(const std::string &row) { | ||
string key; | ||
|
||
size_t val_pos = row.find(KEY_VAL_DEL); |
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.
Same here - StringUtil::Split
could simplify the code here
Merge pull request duckdb/duckdb#10796 from yiyuanliu/lyy/arrow-map Merge pull request duckdb/duckdb#10692 from maiadegraaf/ODBC_Connect Merge pull request duckdb/duckdb#10814 from szarnyasg/update-readme
Previously, when connecting to the ODBC driver using either
SQLDriverConnect
or with a populatedODBC.ini
, only theDSN
anddatabase
fields would be read, with the rest being ignored. There were also no tests for reading from theODBC.ini
fileAs of this PR, this has been reworked. The entire connection string is now parsed and errors are correctly returned in the case of an unrecognized attribute or any other issues that are encountered.
Now all DuckDB configurations can be set.
Special mention:
allow_unsigned_extensions
: Allows unsigned extensions to be loaded-unsigned
option in the ODBC driver #5355access_mode
: Allows the user to open the database in eitherREAD_ONLY
orREAD_WRITE
modeFinally, I've added extensive testing for both reading from the connection string as well as reading from the
ODBC.ini
file.