1818// flight_sql_connection.h needs to be included first due to conflicts with windows.h
1919#include " arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h"
2020
21- #include < arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h>
22- #include < arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h>
23- #include < arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h>
24- #include < arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h>
25- #include < arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h>
26- #include < arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h>
27-
2821#include " arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h"
22+ #include " arrow/flight/sql/odbc/flight_sql/include/flight_sql/flight_sql_driver.h"
23+ #include " arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h"
24+ #include " arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/logger.h"
2925#include " arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h"
26+ #include " arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h"
27+ #include " arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h"
28+ #include " arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h"
29+ #include " arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/spi/connection.h"
3030
3131#if defined _WIN32 || defined _WIN64
3232// For displaying DSN Window
3535
3636// odbc_api includes windows.h, which needs to be put behind winsock2.h.
3737// odbc_environment.h includes winsock2.h
38- #include < arrow/flight/sql/odbc/odbc_api.h>
38+ #include " arrow/flight/sql/odbc/odbc_api.h"
3939
4040namespace arrow {
4141SQLRETURN SQLAllocHandle (SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE * result) {
42+ LOG_DEBUG (" SQLAllocHandle called with type: {}, parent: {}, result: {}" , type, parent,
43+ fmt::ptr (result));
44+
4245 *result = nullptr ;
4346
4447 switch (type) {
@@ -93,6 +96,8 @@ SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result)
9396}
9497
9598SQLRETURN SQLFreeHandle (SQLSMALLINT type, SQLHANDLE handle) {
99+ LOG_DEBUG (" SQLFreeHandle called with type: {}, handle: {}" , type, handle);
100+
96101 switch (type) {
97102 case SQL_HANDLE_ENV : {
98103 using ODBC ::ODBCEnvironment;
@@ -160,6 +165,12 @@ SQLRETURN SQLGetDiagFieldW(SQLSMALLINT handleType, SQLHANDLE handle,
160165 using ODBC ::ODBCConnection;
161166 using ODBC ::ODBCEnvironment;
162167
168+ LOG_DEBUG (
169+ " SQLGetDiagFieldW called with handleType: {}, handle: {}, recNumber: {}, "
170+ " diagIdentifier: {}, diagInfoPtr: {}, bufferLength: {}, stringLengthPtr: {}" ,
171+ handleType, handle, recNumber, diagIdentifier, diagInfoPtr, bufferLength,
172+ fmt::ptr (stringLengthPtr));
173+
163174 if (!handle) {
164175 return SQL_INVALID_HANDLE ;
165176 }
@@ -369,6 +380,13 @@ SQLRETURN SQLGetDiagRecW(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT r
369380 using ODBC ::ODBCConnection;
370381 using ODBC ::ODBCEnvironment;
371382
383+ LOG_DEBUG (
384+ " SQLGetDiagRecW called with handleType: {}, handle: {}, recNumber: {}, "
385+ " sqlState: {}, nativeErrorPtr: {}, messageText: {}, bufferLength: {}, "
386+ " textLengthPtr: {}" ,
387+ handleType, handle, recNumber, fmt::ptr (sqlState), fmt::ptr (nativeErrorPtr),
388+ fmt::ptr (messageText), bufferLength, fmt::ptr (textLengthPtr));
389+
372390 if (!handle) {
373391 return SQL_INVALID_HANDLE ;
374392 }
@@ -438,10 +456,15 @@ SQLRETURN SQLGetDiagRecW(SQLSMALLINT handleType, SQLHANDLE handle, SQLSMALLINT r
438456}
439457
440458SQLRETURN SQLGetEnvAttr (SQLHENV env, SQLINTEGER attr, SQLPOINTER valuePtr,
441- SQLINTEGER bufferLen , SQLINTEGER * strLenPtr) {
459+ SQLINTEGER bufferLength , SQLINTEGER * strLenPtr) {
442460 using driver::odbcabstraction::DriverException;
443461 using ODBC ::ODBCEnvironment;
444462
463+ LOG_DEBUG (
464+ " SQLGetEnvAttr called with env: {}, attr: {}, valuePtr: {}, "
465+ " bufferLength: {}, strLenPtr: {}" ,
466+ env, attr, valuePtr, bufferLength, fmt::ptr (strLenPtr));
467+
445468 ODBCEnvironment* environment = reinterpret_cast <ODBCEnvironment*>(env);
446469
447470 return ODBCEnvironment::ExecuteWithDiagnostics (environment, SQL_ERROR , [=]() {
@@ -498,6 +521,11 @@ SQLRETURN SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER valuePtr,
498521 using driver::odbcabstraction::DriverException;
499522 using ODBC ::ODBCEnvironment;
500523
524+ LOG_DEBUG (
525+ " SQLSetEnvAttr called with env: {}, attr: {}, valuePtr: {}, "
526+ " strLen: {}" ,
527+ env, attr, valuePtr, strLen);
528+
501529 ODBCEnvironment* environment = reinterpret_cast <ODBCEnvironment*>(env);
502530
503531 return ODBCEnvironment::ExecuteWithDiagnostics (environment, SQL_ERROR , [=]() {
@@ -557,6 +585,14 @@ SQLRETURN SQLDriverConnectW(SQLHDBC conn, SQLHWND windowHandle,
557585 using driver::odbcabstraction::DriverException;
558586 using ODBC ::ODBCConnection;
559587
588+ LOG_DEBUG (
589+ " SQLDriverConnectW called with conn: {}, windowHandle: {}, inConnectionString: {}, "
590+ " inConnectionStringLen: {}, outConnectionString: {}, outConnectionStringBufferLen: "
591+ " {}, outConnectionStringLen: {}, driverCompletion: {}" ,
592+ conn, fmt::ptr (windowHandle), fmt::ptr (inConnectionString), inConnectionStringLen,
593+ fmt::ptr (outConnectionString), outConnectionStringBufferLen,
594+ fmt::ptr (outConnectionStringLen), driverCompletion);
595+
560596 return ODBCConnection::ExecuteWithDiagnostics (conn, SQL_ERROR , [=]() {
561597 ODBCConnection* connection = reinterpret_cast <ODBCConnection*>(conn);
562598 std::string connection_string =
@@ -621,6 +657,12 @@ SQLRETURN SQLConnectW(SQLHDBC conn, SQLWCHAR* dsnName, SQLSMALLINT dsnNameLen,
621657
622658 using ODBC ::SqlWcharToString;
623659
660+ LOG_DEBUG (
661+ " SQLConnectW called with conn: {}, dsnName: {}, dsnNameLen: {}, userName: {}, "
662+ " userNameLen: {}, password: {}, passwordLen: {}" ,
663+ conn, fmt::ptr (dsnName), dsnNameLen, fmt::ptr (userName), userNameLen,
664+ fmt::ptr (password), passwordLen);
665+
624666 return ODBCConnection::ExecuteWithDiagnostics (conn, SQL_ERROR , [=]() {
625667 ODBCConnection* connection = reinterpret_cast <ODBCConnection*>(conn);
626668 std::string dsn = SqlWcharToString (dsnName, dsnNameLen);
@@ -649,6 +691,8 @@ SQLRETURN SQLConnectW(SQLHDBC conn, SQLWCHAR* dsnName, SQLSMALLINT dsnNameLen,
649691SQLRETURN SQLDisconnect (SQLHDBC conn) {
650692 using ODBC ::ODBCConnection;
651693
694+ LOG_DEBUG (" SQLDisconnect called with conn: {}" , conn);
695+
652696 return ODBCConnection::ExecuteWithDiagnostics (conn, SQL_ERROR , [=]() {
653697 ODBCConnection* connection = reinterpret_cast <ODBCConnection*>(conn);
654698
@@ -663,6 +707,11 @@ SQLRETURN SQLGetInfoW(SQLHDBC conn, SQLUSMALLINT infoType, SQLPOINTER infoValueP
663707 // TODO: complete implementation of SQLGetInfoW and write tests
664708 using ODBC ::ODBCConnection;
665709
710+ LOG_DEBUG (
711+ " SQLGetInfoW called with conn: {}, infoType: {}, infoValuePtr: {}, bufLen: {}, "
712+ " length: {}" ,
713+ conn, infoType, infoValuePtr, bufLen, fmt::ptr (length));
714+
666715 return ODBCConnection::ExecuteWithDiagnostics (conn, SQL_ERROR , [=]() {
667716 ODBCConnection* connection = reinterpret_cast <ODBCConnection*>(conn);
668717
0 commit comments