MCPcopy Create free account
hub / github.com/apache/arrow / SQLConnect

Function SQLConnect

cpp/src/arrow/flight/sql/odbc/odbc_api.cc:918–956  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

916}
917
918SQLRETURN SQLConnect(SQLHDBC conn, SQLWCHAR* dsn_name, SQLSMALLINT dsn_name_len,
919 SQLWCHAR* user_name, SQLSMALLINT user_name_len, SQLWCHAR* password,
920 SQLSMALLINT password_len) {
921 ARROW_LOG(DEBUG) << "SQLConnectW called with conn: " << conn
922 << ", dsn_name: " << static_cast<const void*>(dsn_name)
923 << ", dsn_name_len: " << dsn_name_len
924 << ", user_name: " << static_cast<const void*>(user_name)
925 << ", user_name_len: " << user_name_len
926 << ", password: " << static_cast<const void*>(password)
927 << ", password_len: " << password_len;
928
929 using ODBC::ODBCConnection;
930
931 using ODBC::SqlWcharToString;
932
933 return ODBCConnection::ExecuteWithDiagnostics(conn, SQL_ERROR, [=]() {
934 ODBCConnection* connection = reinterpret_cast<ODBCConnection*>(conn);
935 std::string dsn = SqlWcharToString(dsn_name, dsn_name_len);
936
937 config::Configuration config;
938 config.LoadDsn(dsn);
939
940 if (user_name) {
941 std::string uid = SqlWcharToString(user_name, user_name_len);
942 config.Emplace(FlightSqlConnection::UID, std::move(uid));
943 }
944
945 if (password) {
946 std::string pwd = SqlWcharToString(password, password_len);
947 config.Emplace(FlightSqlConnection::PWD, std::move(pwd));
948 }
949
950 std::vector<std::string_view> missing_properties;
951
952 connection->Connect(dsn, config.GetProperties(), missing_properties);
953
954 return SQL_SUCCESS;
955 });
956}
957
958SQLRETURN SQLDisconnect(SQLHDBC conn) {
959 ARROW_LOG(DEBUG) << "SQLDisconnect called with conn: " << conn;

Callers 2

TYPED_TESTFunction · 0.50
TEST_FFunction · 0.50

Calls 5

SqlWcharToStringFunction · 0.85
LoadDsnMethod · 0.80
EmplaceMethod · 0.45
ConnectMethod · 0.45
GetPropertiesMethod · 0.45

Tested by 2

TYPED_TESTFunction · 0.40
TEST_FFunction · 0.40