alinaliBQ commented on code in PR #47725:
URL: https://github.com/apache/arrow/pull/47725#discussion_r2411556937
##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -36,7 +36,370 @@ SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE
parent, SQLHANDLE* result)
ARROW_LOG(DEBUG) << "SQLAllocHandle called with type: " << type
<< ", parent: " << parent
<< ", result: " << static_cast<const void*>(result);
+ // GH-46096 TODO: Implement SQLAllocEnv
+ // GH-46097 TODO: Implement SQLAllocConnect, pre-requisite requires
SQLAllocEnv
+ // implementation GH-47706 TODO: Implement SQLAllocStmt, pre-requisite
requires
Review Comment:
Good catch, fixed
##########
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
Review Comment:
Unicode support will be added in upcoming PRs. Some ODBC unicode APIs will
have a `W` at the end after compilation, because some of the function names are
macros that expand to names with `W`. Please see:
https://github.com/microsoft/ODBC-Specification/blob/4dda95986bda5d3b55d7749315d3e5a0951c1e50/Windows/inc/sqlucode.h#L952-L996
##########
cpp/src/arrow/flight/sql/odbc/odbc_api.cc:
##########
@@ -36,7 +36,370 @@ SQLRETURN SQLAllocHandle(SQLSMALLINT type, SQLHANDLE
parent, SQLHANDLE* result)
ARROW_LOG(DEBUG) << "SQLAllocHandle called with type: " << type
<< ", parent: " << parent
<< ", result: " << static_cast<const void*>(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
Review Comment:
Good catch, fixed
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]