diff --git a/cpp/src/arrow/flight/sql/odbc/entry_points.cc b/cpp/src/arrow/flight/sql/odbc/entry_points.cc index 6801868a3cc..c8f66450128 100644 --- a/cpp/src/arrow/flight/sql/odbc/entry_points.cc +++ b/cpp/src/arrow/flight/sql/odbc/entry_points.cc @@ -34,5 +34,286 @@ #include "arrow/util/logging.h" SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) { - return SQL_INVALID_HANDLE; + return arrow::flight::sql::odbc::SQLAllocHandle(type, parent, result); +} + +SQLRETURN SQL_API SQLAllocEnv(SQLHENV* env) { + return arrow::flight::sql::odbc::SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, env); +} + +SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC* conn) { + return arrow::flight::sql::odbc::SQLAllocHandle(SQL_HANDLE_DBC, env, conn); +} + +SQLRETURN SQL_API SQLAllocStmt(SQLHDBC conn, SQLHSTMT* stmt) { + return arrow::flight::sql::odbc::SQLAllocHandle(SQL_HANDLE_STMT, conn, stmt); +} + +SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle) { + return arrow::flight::sql::odbc::SQLFreeHandle(type, handle); +} + +SQLRETURN SQL_API SQLFreeEnv(SQLHENV env) { + return arrow::flight::sql::odbc::SQLFreeHandle(SQL_HANDLE_ENV, env); +} + +SQLRETURN SQL_API SQLFreeConnect(SQLHDBC conn) { + return arrow::flight::sql::odbc::SQLFreeHandle(SQL_HANDLE_DBC, conn); +} + +SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option) { + return arrow::flight::sql::odbc::SQLFreeStmt(stmt, option); +} + +SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT handle_type, SQLHANDLE handle, + SQLSMALLINT rec_number, SQLSMALLINT diag_identifier, + SQLPOINTER diag_info_ptr, SQLSMALLINT buffer_length, + SQLSMALLINT* string_length_ptr) { + return arrow::flight::sql::odbc::SQLGetDiagField(handle_type, handle, rec_number, + diag_identifier, diag_info_ptr, + buffer_length, string_length_ptr); +} + +SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT handle_type, SQLHANDLE handle, + SQLSMALLINT rec_number, SQLWCHAR* sql_state, + SQLINTEGER* native_error_ptr, SQLWCHAR* message_text, + SQLSMALLINT buffer_length, SQLSMALLINT* text_length_ptr) { + return arrow::flight::sql::odbc::SQLGetDiagRec( + handle_type, handle, rec_number, sql_state, native_error_ptr, message_text, + buffer_length, text_length_ptr); +} + +SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr, + SQLINTEGER buffer_len, SQLINTEGER* str_len_ptr) { + return arrow::flight::sql::odbc::SQLGetEnvAttr(env, attr, value_ptr, buffer_len, + str_len_ptr); +} + +SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr, + SQLINTEGER str_len) { + return arrow::flight::sql::odbc::SQLSetEnvAttr(env, attr, value_ptr, str_len); +} + +SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC conn, SQLINTEGER attribute, + SQLPOINTER value_ptr, SQLINTEGER buffer_length, + SQLINTEGER* string_length_ptr) { + return arrow::flight::sql::odbc::SQLGetConnectAttr(conn, attribute, value_ptr, + buffer_length, string_length_ptr); +} + +SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC conn, SQLINTEGER attr, SQLPOINTER value, + SQLINTEGER value_len) { + return arrow::flight::sql::odbc::SQLSetConnectAttr(conn, attr, value, value_len); +} + +SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn, SQLUSMALLINT info_type, + SQLPOINTER info_value_ptr, SQLSMALLINT buf_len, + SQLSMALLINT* length) { + return arrow::flight::sql::odbc::SQLGetInfo(conn, info_type, info_value_ptr, buf_len, + length); +} + +SQLRETURN SQL_API SQLDriverConnect(SQLHDBC conn, SQLHWND window_handle, + SQLWCHAR* in_connection_string, + SQLSMALLINT in_connection_stringLen, + SQLWCHAR* out_connection_string, + SQLSMALLINT out_connection_string_buffer_len, + SQLSMALLINT* out_connection_string_len, + SQLUSMALLINT driver_completion) { + return arrow::flight::sql::odbc::SQLDriverConnect( + conn, window_handle, in_connection_string, in_connection_stringLen, + out_connection_string, out_connection_string_buffer_len, out_connection_string_len, + driver_completion); +} + +SQLRETURN SQL_API SQLConnect(SQLHDBC conn, SQLWCHAR* dsn_name, SQLSMALLINT dsn_name_len, + SQLWCHAR* user_name, SQLSMALLINT user_name_len, + SQLWCHAR* password, SQLSMALLINT password_len) { + return arrow::flight::sql::odbc::SQLConnect(conn, dsn_name, dsn_name_len, user_name, + user_name_len, password, password_len); +} + +SQLRETURN SQL_API SQLDisconnect(SQLHDBC conn) { + return arrow::flight::sql::odbc::SQLDisconnect(conn); +} + +SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, + SQLPOINTER value_ptr, SQLINTEGER buffer_length, + SQLINTEGER* string_length_ptr) { + return arrow::flight::sql::odbc::SQLGetStmtAttr(stmt, attribute, value_ptr, + buffer_length, string_length_ptr); +} + +SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLWCHAR* query_text, + SQLINTEGER text_length) { + return arrow::flight::sql::odbc::SQLExecDirect(stmt, query_text, text_length); +} + +SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt) { + return arrow::flight::sql::odbc::SQLFetch(stmt); +} + +SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT fetch_orientation, + SQLLEN fetch_offset, SQLULEN* row_count_ptr, + SQLUSMALLINT* row_status_array) { + return arrow::flight::sql::odbc::SQLExtendedFetch(stmt, fetch_orientation, fetch_offset, + row_count_ptr, row_status_array); +} + +SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT fetch_orientation, + SQLLEN fetch_offset) { + return arrow::flight::sql::odbc::SQLFetchScroll(stmt, fetch_orientation, fetch_offset); +} + +SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt, SQLUSMALLINT record_number, + SQLSMALLINT c_type, SQLPOINTER data_ptr, + SQLLEN buffer_length, SQLLEN* indicator_ptr) { + return arrow::flight::sql::odbc::SQLGetData(stmt, record_number, c_type, data_ptr, + buffer_length, indicator_ptr); +} + +SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLWCHAR* query_text, + SQLINTEGER text_length) { + return arrow::flight::sql::odbc::SQLPrepare(stmt, query_text, text_length); +} + +SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt) { + return arrow::flight::sql::odbc::SQLExecute(stmt); +} + +SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT record_number, + SQLSMALLINT c_type, SQLPOINTER data_ptr, + SQLLEN buffer_length, SQLLEN* indicator_ptr) { + return arrow::flight::sql::odbc::SQLBindCol(stmt, record_number, c_type, data_ptr, + buffer_length, indicator_ptr); +} + +SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt) { + ARROW_LOG(DEBUG) << "SQLCancel called with stmt: " << stmt; + return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { + throw driver::odbcabstraction::DriverException("SQLCancel is not implemented", + "IM001"); + return SQL_ERROR; + }); +} + +SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt) { + return arrow::flight::sql::odbc::SQLCloseCursor(stmt); +} + +SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT record_number, + SQLUSMALLINT field_identifier, + SQLPOINTER character_attribute_ptr, + SQLSMALLINT buffer_length, SQLSMALLINT* output_length, + SQLLEN* numeric_attribute_ptr) { + return arrow::flight::sql::odbc::SQLColAttribute(stmt, record_number, field_identifier, + character_attribute_ptr, buffer_length, + output_length, numeric_attribute_ptr); +} + +SQLRETURN SQL_API SQLTables(SQLHSTMT stmt, SQLWCHAR* catalog_name, + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, + SQLSMALLINT table_name_length, SQLWCHAR* table_type, + SQLSMALLINT table_type_length) { + return arrow::flight::sql::odbc::SQLTables( + stmt, catalog_name, catalog_name_length, schema_name, schema_name_length, + table_name, table_name_length, table_type, table_type_length); +} + +SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt, SQLWCHAR* catalog_name, + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, + SQLSMALLINT table_name_length, SQLWCHAR* columnName, + SQLSMALLINT column_name_length) { + return arrow::flight::sql::odbc::SQLColumns( + stmt, catalog_name, catalog_name_length, schema_name, schema_name_length, + table_name, table_name_length, columnName, column_name_length); +} + +SQLRETURN SQL_API SQLForeignKeys( + SQLHSTMT stmt, SQLWCHAR* pk_catalog_name, SQLSMALLINT pk_catalog_name_length, + SQLWCHAR* pk_schema_name, SQLSMALLINT pk_schema_name_length, SQLWCHAR* pk_table_name, + SQLSMALLINT pk_table_name_length, SQLWCHAR* fk_catalog_name, + SQLSMALLINT fk_catalog_name_length, SQLWCHAR* fk_schema_name, + SQLSMALLINT fk_schema_name_length, SQLWCHAR* fk_table_name, + SQLSMALLINT fk_table_name_length) { + ARROW_LOG(DEBUG) << "SQLForeignKeysW called with stmt: " << stmt + << ", pk_catalog_name: " << static_cast(pk_catalog_name) + << ", pk_catalog_name_length: " << pk_catalog_name_length + << ", pk_schema_name: " << static_cast(pk_schema_name) + << ", pk_schema_name_length: " << pk_schema_name_length + << ", pk_table_name: " << static_cast(pk_table_name) + << ", pk_table_name_length: " << pk_table_name_length + << ", fk_catalog_name: " << static_cast(fk_catalog_name) + << ", fk_catalog_name_length: " << fk_catalog_name_length + << ", fk_schema_name: " << static_cast(fk_schema_name) + << ", fk_schema_name_length: " << fk_schema_name_length + << ", fk_table_name: " << static_cast(fk_table_name) + << ", fk_table_name_length: " << fk_table_name_length; + return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { + throw driver::odbcabstraction::DriverException("SQLForeignKeysW is not implemented", + "IM001"); + return SQL_ERROR; + }); +} + +SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT data_type) { + return arrow::flight::sql::odbc::SQLGetTypeInfo(stmt, data_type); +} + +SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt) { + return arrow::flight::sql::odbc::SQLMoreResults(stmt); +} + +SQLRETURN SQL_API SQLNativeSql(SQLHDBC conn, SQLWCHAR* in_statement_text, + SQLINTEGER in_statement_text_length, + SQLWCHAR* out_statement_text, SQLINTEGER buffer_length, + SQLINTEGER* out_statement_text_length) { + return arrow::flight::sql::odbc::SQLNativeSql( + conn, in_statement_text, in_statement_text_length, out_statement_text, + buffer_length, out_statement_text_length); +} + +SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT* column_count_ptr) { + return arrow::flight::sql::odbc::SQLNumResultCols(stmt, column_count_ptr); +} + +SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN* row_count_ptr) { + return arrow::flight::sql::odbc::SQLRowCount(stmt, row_count_ptr); +} + +SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt, SQLWCHAR* catalog_name, + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, + SQLSMALLINT table_name_length) { + ARROW_LOG(DEBUG) << "SQLPrimaryKeysW called with stmt: " << stmt + << ", catalog_name: " << static_cast(catalog_name) + << ", catalog_name_length: " << catalog_name_length + << ", schema_name: " << static_cast(schema_name) + << ", schema_name_length: " << schema_name_length + << ", table_name: " << static_cast(table_name) + << ", table_name_length: " << table_name_length; + return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { + throw driver::odbcabstraction::DriverException("SQLPrimaryKeysW is not implemented", + "IM001"); + return SQL_ERROR; + }); +} + +SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, + SQLPOINTER value_ptr, SQLINTEGER stringLength) { + return arrow::flight::sql::odbc::SQLSetStmtAttr(stmt, attribute, value_ptr, + stringLength); +} + +SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt, SQLUSMALLINT column_number, + SQLWCHAR* column_name, SQLSMALLINT buffer_length, + SQLSMALLINT* name_length_ptr, SQLSMALLINT* data_type_ptr, + SQLULEN* column_size_ptr, + SQLSMALLINT* decimal_digits_ptr, + SQLSMALLINT* nullable_ptr) { + return arrow::flight::sql::odbc::SQLDescribeCol( + stmt, column_number, column_name, buffer_length, name_length_ptr, data_type_ptr, + column_size_ptr, decimal_digits_ptr, nullable_ptr); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc index 718b4a1d52b..be432ccd01e 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc @@ -313,7 +313,7 @@ int DsnConfigurationWindow::CreatePropertiesGroup(int pos_x, int pos_y, int size const auto keys = config_.GetCustomKeys(); for (const auto& key : keys) { - property_list_->ListAddItem({std::string(key), config.Get(key)}); + property_list_->ListAddItem({std::string(key), config_.Get(key)}); } SendMessage(property_list_->GetHandle(), LVM_SETEXTENDEDLISTVIEWSTYLE, diff --git a/cpp/src/arrow/flight/sql/odbc/odbc_api.cc b/cpp/src/arrow/flight/sql/odbc/odbc_api.cc index 865066796c1..76ebd990f99 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbc_api.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbc_api.cc @@ -36,7 +36,374 @@ SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) ARROW_LOG(DEBUG) << "SQLAllocHandle called with type: " << type << ", parent: " << parent << ", result: " << static_cast(result); + // GH-46096 TODO: Implement SQLAllocEnv + // GH-46097 TODO: Implement SQLAllocConnect, pre-requisite requires SQLAllocEnv + // implementation + // GH-47706 TODO: Implement SQLAllocStmt, pre-requisite requires + // SQLDriverConnect implementation + + // GH-47707 TODO: Implement SQL_HANDLE_DESC for + // descriptor handle, pre-requisite requires SQLAllocStmt + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle) { + ARROW_LOG(DEBUG) << "SQLFreeHandle called with type: " << type + << ", handle: " << handle; + // GH-46096 TODO: Implement SQLFreeEnv + // GH-46097 TODO: Implement SQLFreeConnect + // GH-47706 TODO: Implement SQLFreeStmt + // GH-47707 TODO: Implement SQL_HANDLE_DESC for descriptor handle + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLFreeStmt(SQLHSTMT handle, SQLUSMALLINT option) { + ARROW_LOG(DEBUG) << "SQLFreeStmt called with handle: " << handle + << ", option: " << option; + // GH-47706 TODO: Implement SQLFreeStmt + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLGetDiagField(SQLSMALLINT handle_type, SQLHANDLE handle, + SQLSMALLINT rec_number, SQLSMALLINT diag_identifier, + SQLPOINTER diag_info_ptr, SQLSMALLINT buffer_length, + SQLSMALLINT* string_length_ptr) { + // GH-46573 TODO: Implement additional fields types + ARROW_LOG(DEBUG) << "SQLGetDiagFieldW called with handle_type: " << handle_type + << ", handle: " << handle << ", rec_number: " << rec_number + << ", diag_identifier: " << diag_identifier + << ", diag_info_ptr: " << diag_info_ptr + << ", buffer_length: " << buffer_length << ", string_length_ptr: " + << static_cast(string_length_ptr); + // GH-46575 TODO: Implement SQLGetDiagField + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLGetDiagRec(SQLSMALLINT handle_type, SQLHANDLE handle, SQLSMALLINT rec_number, + SQLWCHAR* sql_state, SQLINTEGER* native_error_ptr, + SQLWCHAR* message_text, SQLSMALLINT buffer_length, + SQLSMALLINT* text_length_ptr) { + ARROW_LOG(DEBUG) << "SQLGetDiagRecW called with handle_type: " << handle_type + << ", handle: " << handle << ", rec_number: " << rec_number + << ", sql_state: " << static_cast(sql_state) + << ", native_error_ptr: " << static_cast(native_error_ptr) + << ", message_text: " << static_cast(message_text) + << ", buffer_length: " << buffer_length + << ", text_length_ptr: " << static_cast(text_length_ptr); + // GH-46575 TODO: Implement SQLGetDiagRec + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr, + SQLINTEGER buffer_length, SQLINTEGER* str_len_ptr) { + ARROW_LOG(DEBUG) << "SQLGetEnvAttr called with env: " << env << ", attr: " << attr + << ", value_ptr: " << value_ptr << ", buffer_length: " << buffer_length + << ", str_len_ptr: " << static_cast(str_len_ptr); + // GH-46575 TODO: Implement SQLGetEnvAttr + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr, + SQLINTEGER str_len) { + ARROW_LOG(DEBUG) << "SQLSetEnvAttr called with env: " << env << ", attr: " << attr + << ", value_ptr: " << value_ptr << ", str_len: " << str_len; + // GH-46575 TODO: Implement SQLSetEnvAttr + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLGetConnectAttr(SQLHDBC conn, SQLINTEGER attribute, SQLPOINTER value_ptr, + SQLINTEGER buffer_length, SQLINTEGER* string_length_ptr) { + ARROW_LOG(DEBUG) << "SQLGetConnectAttrW called with conn: " << conn + << ", attribute: " << attribute << ", value_ptr: " << value_ptr + << ", buffer_length: " << buffer_length << ", string_length_ptr: " + << static_cast(string_length_ptr); + // GH-47708 TODO: Implement SQLGetConnectAttr + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLSetConnectAttr(SQLHDBC conn, SQLINTEGER attr, SQLPOINTER value_ptr, + SQLINTEGER value_len) { + ARROW_LOG(DEBUG) << "SQLSetConnectAttrW called with conn: " << conn + << ", attr: " << attr << ", value_ptr: " << value_ptr + << ", value_len: " << value_len; + // GH-47708 TODO: Implement SQLSetConnectAttr + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLDriverConnect(SQLHDBC conn, SQLHWND window_handle, + SQLWCHAR* in_connection_string, + SQLSMALLINT in_connection_string_len, + SQLWCHAR* out_connection_string, + SQLSMALLINT out_connection_string_buffer_len, + SQLSMALLINT* out_connection_string_len, + SQLUSMALLINT driver_completion) { + ARROW_LOG(DEBUG) << "SQLDriverConnectW called with conn: " << conn + << ", window_handle: " << static_cast(window_handle) + << ", in_connection_string: " + << static_cast(in_connection_string) + << ", in_connection_string_len: " << in_connection_string_len + << ", out_connection_string: " + << static_cast(out_connection_string) + << ", out_connection_string_buffer_len: " + << out_connection_string_buffer_len << ", out_connection_string_len: " + << static_cast(out_connection_string_len) + << ", driver_completion: " << driver_completion; + // GH-46449 TODO: Implement FILEDSN and SAVEFILE keywords according to the spec + + // GH-46560 TODO: Copy connection string properly in SQLDriverConnect according to the + // spec + + // GH-46574 TODO: Implement SQLDriverConnect + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLConnect(SQLHDBC conn, SQLWCHAR* dsn_name, SQLSMALLINT dsn_name_len, + SQLWCHAR* user_name, SQLSMALLINT user_name_len, SQLWCHAR* password, + SQLSMALLINT password_len) { + ARROW_LOG(DEBUG) << "SQLConnectW called with conn: " << conn + << ", dsn_name: " << static_cast(dsn_name) + << ", dsn_name_len: " << dsn_name_len + << ", user_name: " << static_cast(user_name) + << ", user_name_len: " << user_name_len + << ", password: " << static_cast(password) + << ", password_len: " << password_len; + // GH-46574 TODO: Implement SQLConnect + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLDisconnect(SQLHDBC conn) { + ARROW_LOG(DEBUG) << "SQLDisconnect called with conn: " << conn; + // GH-46574 TODO: Implement SQLDisconnect + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLGetInfo(SQLHDBC conn, SQLUSMALLINT info_type, SQLPOINTER info_value_ptr, + SQLSMALLINT buf_len, SQLSMALLINT* string_length_ptr) { + ARROW_LOG(DEBUG) << "SQLGetInfoW called with conn: " << conn + << ", info_type: " << info_type + << ", info_value_ptr: " << info_value_ptr << ", buf_len: " << buf_len + << ", string_length_ptr: " + << static_cast(string_length_ptr); + // GH-47709 TODO: Implement SQLGetInfo + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER value_ptr, + SQLINTEGER buffer_length, SQLINTEGER* string_length_ptr) { + ARROW_LOG(DEBUG) << "SQLGetStmtAttrW called with stmt: " << stmt + << ", attribute: " << attribute << ", value_ptr: " << value_ptr + << ", buffer_length: " << buffer_length << ", string_length_ptr: " + << static_cast(string_length_ptr); + // GH-47710 TODO: Implement SQLGetStmtAttr + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER value_ptr, + SQLINTEGER string_length) { + ARROW_LOG(DEBUG) << "SQLSetStmtAttrW called with stmt: " << stmt + << ", attribute: " << attribute << ", value_ptr: " << value_ptr + << ", string_length: " << string_length; + // GH-47710 TODO: Implement SQLSetStmtAttr + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLExecDirect(SQLHSTMT stmt, SQLWCHAR* query_text, SQLINTEGER text_length) { + ARROW_LOG(DEBUG) << "SQLExecDirectW called with stmt: " << stmt + << ", query_text: " << static_cast(query_text) + << ", text_length: " << text_length; + // GH-47711 TODO: Implement SQLExecDirect + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLPrepare(SQLHSTMT stmt, SQLWCHAR* query_text, SQLINTEGER text_length) { + ARROW_LOG(DEBUG) << "SQLPrepareW called with stmt: " << stmt + << ", query_text: " << static_cast(query_text) + << ", text_length: " << text_length; + // GH-47712 TODO: Implement SQLPrepare + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLExecute(SQLHSTMT stmt) { + ARROW_LOG(DEBUG) << "SQLExecute called with stmt: " << stmt; + // GH-47712 TODO: Implement SQLExecute + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLFetch(SQLHSTMT stmt) { + ARROW_LOG(DEBUG) << "SQLFetch called with stmt: " << stmt; + // GH-47713 TODO: Implement SQLFetch + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT fetch_orientation, + SQLLEN fetch_offset, SQLULEN* row_count_ptr, + SQLUSMALLINT* row_status_array) { + // GH-47110 TODO: SQLExtendedFetch should return SQL_SUCCESS_WITH_INFO for certain diag + // states + ARROW_LOG(DEBUG) << "SQLExtendedFetch called with stmt: " << stmt + << ", fetch_orientation: " << fetch_orientation + << ", fetch_offset: " << fetch_offset + << ", row_count_ptr: " << static_cast(row_count_ptr) + << ", row_status_array: " + << static_cast(row_status_array); + // GH-47714 TODO: Implement SQLExtendedFetch + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT fetch_orientation, + SQLLEN fetch_offset) { + ARROW_LOG(DEBUG) << "SQLFetchScroll called with stmt: " << stmt + << ", fetch_orientation: " << fetch_orientation + << ", fetch_offset: " << fetch_offset; + // GH-47715 TODO: Implement SQLFetchScroll + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT record_number, SQLSMALLINT c_type, + SQLPOINTER data_ptr, SQLLEN buffer_length, SQLLEN* indicator_ptr) { + ARROW_LOG(DEBUG) << "SQLBindCol called with stmt: " << stmt + << ", record_number: " << record_number << ", c_type: " << c_type + << ", data_ptr: " << data_ptr << ", buffer_length: " << buffer_length + << ", indicator_ptr: " << static_cast(indicator_ptr); + // GH-47716 TODO: Implement SQLBindCol + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLCloseCursor(SQLHSTMT stmt) { + ARROW_LOG(DEBUG) << "SQLCloseCursor called with stmt: " << stmt; + // GH-47717 TODO: Implement SQLCloseCursor + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLGetData(SQLHSTMT stmt, SQLUSMALLINT record_number, SQLSMALLINT c_type, + SQLPOINTER data_ptr, SQLLEN buffer_length, SQLLEN* indicator_ptr) { + // GH-46979 TODO: support SQL_C_GUID data type + // GH-46980 TODO: support Interval data types + // GH-46985 TODO: return warning message instead of error on float truncation case + ARROW_LOG(DEBUG) << "SQLGetData called with stmt: " << stmt + << ", record_number: " << record_number << ", c_type: " << c_type + << ", data_ptr: " << data_ptr << ", buffer_length: " << buffer_length + << ", indicator_ptr: " << static_cast(indicator_ptr); + // GH-47713 TODO: Implement SQLGetData + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLMoreResults(SQLHSTMT stmt) { + ARROW_LOG(DEBUG) << "SQLMoreResults called with stmt: " << stmt; + // GH-47713 TODO: Implement SQLMoreResults + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT* column_count_ptr) { + ARROW_LOG(DEBUG) << "SQLNumResultCols called with stmt: " << stmt + << ", column_count_ptr: " + << static_cast(column_count_ptr); + // GH-47713 TODO: Implement SQLNumResultCols + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLRowCount(SQLHSTMT stmt, SQLLEN* row_count_ptr) { + ARROW_LOG(DEBUG) << "SQLRowCount called with stmt: " << stmt + << ", column_count_ptr: " << static_cast(row_count_ptr); + // GH-47713 TODO: Implement SQLRowCount + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLTables(SQLHSTMT stmt, SQLWCHAR* catalog_name, + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, + SQLSMALLINT table_name_length, SQLWCHAR* table_type, + SQLSMALLINT table_type_length) { + ARROW_LOG(DEBUG) << "SQLTablesW called with stmt: " << stmt + << ", catalog_name: " << static_cast(catalog_name) + << ", catalog_name_length: " << catalog_name_length + << ", schema_name: " << static_cast(schema_name) + << ", schema_name_length: " << schema_name_length + << ", table_name: " << static_cast(table_name) + << ", table_name_length: " << table_name_length + << ", table_type: " << static_cast(table_type) + << ", table_type_length: " << table_type_length; + // GH-47719 TODO: Implement SQLTables + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLColumns(SQLHSTMT stmt, SQLWCHAR* catalog_name, + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, + SQLSMALLINT table_name_length, SQLWCHAR* column_name, + SQLSMALLINT column_name_length) { + // GH-47159 TODO: Return NUM_PREC_RADIX based on whether COLUMN_SIZE contains number of + // digits or bits + ARROW_LOG(DEBUG) << "SQLColumnsW called with stmt: " << stmt + << ", catalog_name: " << static_cast(catalog_name) + << ", catalog_name_length: " << catalog_name_length + << ", schema_name: " << static_cast(schema_name) + << ", schema_name_length: " << schema_name_length + << ", table_name: " << static_cast(table_name) + << ", table_name_length: " << table_name_length + << ", column_name: " << static_cast(column_name) + << ", column_name_length: " << column_name_length; + // GH-47720 TODO: Implement SQLColumns + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT record_number, + SQLUSMALLINT field_identifier, + SQLPOINTER character_attribute_ptr, SQLSMALLINT buffer_length, + SQLSMALLINT* output_length, SQLLEN* numeric_attribute_ptr) { + ARROW_LOG(DEBUG) << "SQLColAttributeW called with stmt: " << stmt + << ", record_number: " << record_number + << ", field_identifier: " << field_identifier + << ", character_attribute_ptr: " << character_attribute_ptr + << ", buffer_length: " << buffer_length + << ", output_length: " << static_cast(output_length) + << ", numeric_attribute_ptr: " + << static_cast(numeric_attribute_ptr); + // GH-47721 TODO: Implement SQLColAttribute, pre-requisite requires SQLColumns + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT data_type) { + // GH-47237 TODO: return SQL_PRED_CHAR and SQL_PRED_BASIC for + // appropriate data types in `SEARCHABLE` field + ARROW_LOG(DEBUG) << "SQLGetTypeInfoW called with stmt: " << stmt + << " data_type: " << data_type; + // GH-47722 TODO: Implement SQLGetTypeInfo + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLNativeSql(SQLHDBC conn, SQLWCHAR* in_statement_text, + SQLINTEGER in_statement_text_length, SQLWCHAR* out_statement_text, + SQLINTEGER buffer_length, SQLINTEGER* out_statement_text_length) { + ARROW_LOG(DEBUG) << "SQLNativeSqlW called with connection_handle: " << conn + << ", in_statement_text: " + << static_cast(in_statement_text) + << ", in_statement_text_length: " << in_statement_text_length + << ", out_statement_text: " + << static_cast(out_statement_text) + << ", buffer_length: " << buffer_length + << ", out_statement_text_length: " + << static_cast(out_statement_text_length); + // GH-47723 TODO: Implement SQLNativeSql + return SQL_INVALID_HANDLE; +} + +SQLRETURN SQLDescribeCol(SQLHSTMT stmt, SQLUSMALLINT column_number, SQLWCHAR* column_name, + SQLSMALLINT buffer_length, SQLSMALLINT* name_length_ptr, + SQLSMALLINT* data_type_ptr, SQLULEN* column_size_ptr, + SQLSMALLINT* decimal_digits_ptr, SQLSMALLINT* nullable_ptr) { + ARROW_LOG(DEBUG) << "SQLDescribeColW called with stmt: " << stmt + << ", column_number: " << column_number + << ", column_name: " << static_cast(column_name) + << ", buffer_length: " << buffer_length + << ", name_length_ptr: " << static_cast(name_length_ptr) + << ", data_type_ptr: " << static_cast(data_type_ptr) + << ", column_size_ptr: " << static_cast(column_size_ptr) + << ", decimal_digits_ptr: " + << static_cast(decimal_digits_ptr) + << ", nullable_ptr: " << static_cast(nullable_ptr); + // GH-47724 TODO: Implement SQLDescribeCol return SQL_INVALID_HANDLE; } diff --git a/cpp/src/arrow/flight/sql/odbc/odbc_api_internal.h b/cpp/src/arrow/flight/sql/odbc/odbc_api_internal.h index 527d833840d..d377ee31206 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbc_api_internal.h +++ b/cpp/src/arrow/flight/sql/odbc/odbc_api_internal.h @@ -28,4 +28,78 @@ // Define internal ODBC API function headers. namespace arrow::flight::sql::odbc { SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result); +SQLRETURN SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle); +SQLRETURN SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option); +SQLRETURN SQLGetDiagField(SQLSMALLINT handle_type, SQLHANDLE handle, + SQLSMALLINT rec_number, SQLSMALLINT diag_identifier, + SQLPOINTER diag_info_ptr, SQLSMALLINT buffer_length, + SQLSMALLINT* string_length_ptr); +SQLRETURN SQLGetDiagRec(SQLSMALLINT handle_type, SQLHANDLE handle, SQLSMALLINT rec_number, + SQLWCHAR* sql_state, SQLINTEGER* native_error_ptr, + SQLWCHAR* message_text, SQLSMALLINT buffer_length, + SQLSMALLINT* text_length_ptr); +SQLRETURN SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr, + SQLINTEGER buffer_len, SQLINTEGER* str_len_ptr); +SQLRETURN SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr, + SQLINTEGER str_len); +SQLRETURN SQLGetConnectAttr(SQLHDBC conn, SQLINTEGER attribute, SQLPOINTER value_ptr, + SQLINTEGER buffer_length, SQLINTEGER* string_length_ptr); +SQLRETURN SQLSetConnectAttr(SQLHDBC conn, SQLINTEGER attr, SQLPOINTER value, + SQLINTEGER value_len); +SQLRETURN SQLDriverConnect(SQLHDBC conn, SQLHWND window_handle, + SQLWCHAR* in_connection_string, + SQLSMALLINT in_connection_string_len, + SQLWCHAR* out_connection_string, + SQLSMALLINT out_connection_string_buffer_len, + SQLSMALLINT* out_connection_string_len, + SQLUSMALLINT driver_completion); +SQLRETURN SQLConnect(SQLHDBC conn, SQLWCHAR* dsn_name, SQLSMALLINT dsn_name_len, + SQLWCHAR* user_name, SQLSMALLINT user_name_len, SQLWCHAR* password, + SQLSMALLINT password_len); +SQLRETURN SQLDisconnect(SQLHDBC conn); +SQLRETURN SQLGetInfo(SQLHDBC conn, SQLUSMALLINT info_type, SQLPOINTER info_value_ptr, + SQLSMALLINT buf_len, SQLSMALLINT* length); +SQLRETURN SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER value_ptr, + SQLINTEGER buffer_length, SQLINTEGER* string_length_ptr); +SQLRETURN SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, SQLPOINTER value_ptr, + SQLINTEGER stringLength); +SQLRETURN SQLExecDirect(SQLHSTMT stmt, SQLWCHAR* queryText, SQLINTEGER text_length); +SQLRETURN SQLPrepare(SQLHSTMT stmt, SQLWCHAR* queryText, SQLINTEGER text_length); +SQLRETURN SQLExecute(SQLHSTMT stmt); +SQLRETURN SQLFetch(SQLHSTMT stmt); +SQLRETURN SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT fetch_orientation, + SQLLEN fetch_offset, SQLULEN* row_count_ptr, + SQLUSMALLINT* row_status_array); +SQLRETURN SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT fetch_orientation, + SQLLEN fetch_offset); +SQLRETURN SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT record_number, SQLSMALLINT c_type, + SQLPOINTER data_ptr, SQLLEN buffer_length, SQLLEN* indicator_ptr); +SQLRETURN SQLCloseCursor(SQLHSTMT stmt); +SQLRETURN SQLGetData(SQLHSTMT stmt, SQLUSMALLINT record_number, SQLSMALLINT c_type, + SQLPOINTER data_ptr, SQLLEN buffer_length, SQLLEN* indicator_ptr); +SQLRETURN SQLMoreResults(SQLHSTMT stmt); +SQLRETURN SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT* column_count_ptr); +SQLRETURN SQLRowCount(SQLHSTMT stmt, SQLLEN* row_count_ptr); +SQLRETURN SQLTables(SQLHSTMT stmt, SQLWCHAR* catalog_name, + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, + SQLSMALLINT table_name_length, SQLWCHAR* table_type, + SQLSMALLINT table_type_length); +SQLRETURN SQLColumns(SQLHSTMT stmt, SQLWCHAR* catalog_name, + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, + SQLSMALLINT table_name_length, SQLWCHAR* column_name, + SQLSMALLINT column_name_length); +SQLRETURN SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT record_number, + SQLUSMALLINT field_identifier, + SQLPOINTER character_attribute_ptr, SQLSMALLINT buffer_length, + SQLSMALLINT* output_length, SQLLEN* numeric_attribute_ptr); +SQLRETURN SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT dataType); +SQLRETURN SQLNativeSql(SQLHDBC conn, SQLWCHAR* in_statement_text, + SQLINTEGER in_statement_text_length, SQLWCHAR* out_statement_text, + SQLINTEGER buffer_length, SQLINTEGER* out_statement_text_length); +SQLRETURN SQLDescribeCol(SQLHSTMT stmt, SQLUSMALLINT column_number, SQLWCHAR* column_name, + SQLSMALLINT buffer_length, SQLSMALLINT* name_length_ptr, + SQLSMALLINT* data_type_ptr, SQLULEN* column_size_ptr, + SQLSMALLINT* decimal_digits_ptr, SQLSMALLINT* nullable_ptr); } // namespace arrow::flight::sql::odbc diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h index 355d950502e..b029bac8cce 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h @@ -47,7 +47,7 @@ class ODBCHandle { rc = function(); } catch (const driver::odbcabstraction::DriverException& ex) { GetDiagnostics().AddError(ex); - } catch (const std::bad_alloc& ex) { + } catch (const std::bad_alloc&) { GetDiagnostics().AddError(driver::odbcabstraction::DriverException( "A memory allocation error occurred.", "HY001")); } catch (const std::exception& ex) {