|
34 | 34 | #include "arrow/util/logging.h" |
35 | 35 |
|
36 | 36 | SQLRETURN SQL_API SQLAllocHandle(SQLSMALLINT type, SQLHANDLE parent, SQLHANDLE* result) { |
37 | | - return SQL_INVALID_HANDLE; |
| 37 | + return arrow::flight::sql::odbc::SQLAllocHandle(type, parent, result); |
| 38 | +} |
| 39 | + |
| 40 | +SQLRETURN SQL_API SQLAllocEnv(SQLHENV* env) { |
| 41 | + return arrow::flight::sql::odbc::SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, env); |
| 42 | +} |
| 43 | + |
| 44 | +SQLRETURN SQL_API SQLAllocConnect(SQLHENV env, SQLHDBC* conn) { |
| 45 | + return arrow::flight::sql::odbc::SQLAllocHandle(SQL_HANDLE_DBC, env, conn); |
| 46 | +} |
| 47 | + |
| 48 | +SQLRETURN SQL_API SQLAllocStmt(SQLHDBC conn, SQLHSTMT* stmt) { |
| 49 | + return arrow::flight::sql::odbc::SQLAllocHandle(SQL_HANDLE_STMT, conn, stmt); |
| 50 | +} |
| 51 | + |
| 52 | +SQLRETURN SQL_API SQLFreeHandle(SQLSMALLINT type, SQLHANDLE handle) { |
| 53 | + return arrow::flight::sql::odbc::SQLFreeHandle(type, handle); |
| 54 | +} |
| 55 | + |
| 56 | +SQLRETURN SQL_API SQLFreeEnv(SQLHENV env) { |
| 57 | + return arrow::flight::sql::odbc::SQLFreeHandle(SQL_HANDLE_ENV, env); |
| 58 | +} |
| 59 | + |
| 60 | +SQLRETURN SQL_API SQLFreeConnect(SQLHDBC conn) { |
| 61 | + return arrow::flight::sql::odbc::SQLFreeHandle(SQL_HANDLE_DBC, conn); |
| 62 | +} |
| 63 | + |
| 64 | +SQLRETURN SQL_API SQLFreeStmt(SQLHSTMT stmt, SQLUSMALLINT option) { |
| 65 | + return arrow::flight::sql::odbc::SQLFreeStmt(stmt, option); |
| 66 | +} |
| 67 | + |
| 68 | +SQLRETURN SQL_API SQLGetDiagField(SQLSMALLINT handle_type, SQLHANDLE handle, |
| 69 | + SQLSMALLINT rec_number, SQLSMALLINT diag_identifier, |
| 70 | + SQLPOINTER diag_info_ptr, SQLSMALLINT buffer_length, |
| 71 | + SQLSMALLINT* string_length_ptr) { |
| 72 | + return arrow::flight::sql::odbc::SQLGetDiagField(handle_type, handle, rec_number, |
| 73 | + diag_identifier, diag_info_ptr, |
| 74 | + buffer_length, string_length_ptr); |
| 75 | +} |
| 76 | + |
| 77 | +SQLRETURN SQL_API SQLGetDiagRec(SQLSMALLINT handle_type, SQLHANDLE handle, |
| 78 | + SQLSMALLINT rec_number, SQLWCHAR* sql_state, |
| 79 | + SQLINTEGER* native_error_ptr, SQLWCHAR* message_text, |
| 80 | + SQLSMALLINT buffer_length, SQLSMALLINT* text_length_ptr) { |
| 81 | + return arrow::flight::sql::odbc::SQLGetDiagRec( |
| 82 | + handle_type, handle, rec_number, sql_state, native_error_ptr, message_text, |
| 83 | + buffer_length, text_length_ptr); |
| 84 | +} |
| 85 | + |
| 86 | +SQLRETURN SQL_API SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr, |
| 87 | + SQLINTEGER buffer_len, SQLINTEGER* str_len_ptr) { |
| 88 | + return arrow::flight::sql::odbc::SQLGetEnvAttr(env, attr, value_ptr, buffer_len, |
| 89 | + str_len_ptr); |
| 90 | +} |
| 91 | + |
| 92 | +SQLRETURN SQL_API SQLSetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr, |
| 93 | + SQLINTEGER str_len) { |
| 94 | + return arrow::flight::sql::odbc::SQLSetEnvAttr(env, attr, value_ptr, str_len); |
| 95 | +} |
| 96 | + |
| 97 | +SQLRETURN SQL_API SQLGetConnectAttr(SQLHDBC conn, SQLINTEGER attribute, |
| 98 | + SQLPOINTER value_ptr, SQLINTEGER buffer_length, |
| 99 | + SQLINTEGER* string_length_ptr) { |
| 100 | + return arrow::flight::sql::odbc::SQLGetConnectAttr(conn, attribute, value_ptr, |
| 101 | + buffer_length, string_length_ptr); |
| 102 | +} |
| 103 | + |
| 104 | +SQLRETURN SQL_API SQLSetConnectAttr(SQLHDBC conn, SQLINTEGER attr, SQLPOINTER value, |
| 105 | + SQLINTEGER value_len) { |
| 106 | + return arrow::flight::sql::odbc::SQLSetConnectAttr(conn, attr, value, value_len); |
| 107 | +} |
| 108 | + |
| 109 | +SQLRETURN SQL_API SQLGetInfo(SQLHDBC conn, SQLUSMALLINT info_type, |
| 110 | + SQLPOINTER info_value_ptr, SQLSMALLINT buf_len, |
| 111 | + SQLSMALLINT* length) { |
| 112 | + return arrow::flight::sql::odbc::SQLGetInfo(conn, info_type, info_value_ptr, buf_len, |
| 113 | + length); |
| 114 | +} |
| 115 | + |
| 116 | +SQLRETURN SQL_API SQLDriverConnect(SQLHDBC conn, SQLHWND window_handle, |
| 117 | + SQLWCHAR* in_connection_string, |
| 118 | + SQLSMALLINT in_connection_stringLen, |
| 119 | + SQLWCHAR* out_connection_string, |
| 120 | + SQLSMALLINT out_connection_string_buffer_len, |
| 121 | + SQLSMALLINT* out_connection_string_len, |
| 122 | + SQLUSMALLINT driver_completion) { |
| 123 | + return arrow::flight::sql::odbc::SQLDriverConnect( |
| 124 | + conn, window_handle, in_connection_string, in_connection_stringLen, |
| 125 | + out_connection_string, out_connection_string_buffer_len, out_connection_string_len, |
| 126 | + driver_completion); |
| 127 | +} |
| 128 | + |
| 129 | +SQLRETURN SQL_API SQLConnect(SQLHDBC conn, SQLWCHAR* dsn_name, SQLSMALLINT dsn_name_len, |
| 130 | + SQLWCHAR* user_name, SQLSMALLINT user_name_len, |
| 131 | + SQLWCHAR* password, SQLSMALLINT password_len) { |
| 132 | + return arrow::flight::sql::odbc::SQLConnect(conn, dsn_name, dsn_name_len, user_name, |
| 133 | + user_name_len, password, password_len); |
| 134 | +} |
| 135 | + |
| 136 | +SQLRETURN SQL_API SQLDisconnect(SQLHDBC conn) { |
| 137 | + return arrow::flight::sql::odbc::SQLDisconnect(conn); |
| 138 | +} |
| 139 | + |
| 140 | +SQLRETURN SQL_API SQLGetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, |
| 141 | + SQLPOINTER value_ptr, SQLINTEGER buffer_length, |
| 142 | + SQLINTEGER* string_length_ptr) { |
| 143 | + return arrow::flight::sql::odbc::SQLGetStmtAttr(stmt, attribute, value_ptr, |
| 144 | + buffer_length, string_length_ptr); |
| 145 | +} |
| 146 | + |
| 147 | +SQLRETURN SQL_API SQLExecDirect(SQLHSTMT stmt, SQLWCHAR* query_text, |
| 148 | + SQLINTEGER text_length) { |
| 149 | + return arrow::flight::sql::odbc::SQLExecDirect(stmt, query_text, text_length); |
| 150 | +} |
| 151 | + |
| 152 | +SQLRETURN SQL_API SQLFetch(SQLHSTMT stmt) { |
| 153 | + return arrow::flight::sql::odbc::SQLFetch(stmt); |
| 154 | +} |
| 155 | + |
| 156 | +SQLRETURN SQL_API SQLExtendedFetch(SQLHSTMT stmt, SQLUSMALLINT fetch_orientation, |
| 157 | + SQLLEN fetch_offset, SQLULEN* row_count_ptr, |
| 158 | + SQLUSMALLINT* row_status_array) { |
| 159 | + return arrow::flight::sql::odbc::SQLExtendedFetch(stmt, fetch_orientation, fetch_offset, |
| 160 | + row_count_ptr, row_status_array); |
| 161 | +} |
| 162 | + |
| 163 | +SQLRETURN SQL_API SQLFetchScroll(SQLHSTMT stmt, SQLSMALLINT fetch_orientation, |
| 164 | + SQLLEN fetch_offset) { |
| 165 | + return arrow::flight::sql::odbc::SQLFetchScroll(stmt, fetch_orientation, fetch_offset); |
| 166 | +} |
| 167 | + |
| 168 | +SQLRETURN SQL_API SQLGetData(SQLHSTMT stmt, SQLUSMALLINT record_number, |
| 169 | + SQLSMALLINT c_type, SQLPOINTER data_ptr, |
| 170 | + SQLLEN buffer_length, SQLLEN* indicator_ptr) { |
| 171 | + return arrow::flight::sql::odbc::SQLGetData(stmt, record_number, c_type, data_ptr, |
| 172 | + buffer_length, indicator_ptr); |
| 173 | +} |
| 174 | + |
| 175 | +SQLRETURN SQL_API SQLPrepare(SQLHSTMT stmt, SQLWCHAR* query_text, |
| 176 | + SQLINTEGER text_length) { |
| 177 | + return arrow::flight::sql::odbc::SQLPrepare(stmt, query_text, text_length); |
| 178 | +} |
| 179 | + |
| 180 | +SQLRETURN SQL_API SQLExecute(SQLHSTMT stmt) { |
| 181 | + return arrow::flight::sql::odbc::SQLExecute(stmt); |
| 182 | +} |
| 183 | + |
| 184 | +SQLRETURN SQL_API SQLBindCol(SQLHSTMT stmt, SQLUSMALLINT record_number, |
| 185 | + SQLSMALLINT c_type, SQLPOINTER data_ptr, |
| 186 | + SQLLEN buffer_length, SQLLEN* indicator_ptr) { |
| 187 | + return arrow::flight::sql::odbc::SQLBindCol(stmt, record_number, c_type, data_ptr, |
| 188 | + buffer_length, indicator_ptr); |
| 189 | +} |
| 190 | + |
| 191 | +SQLRETURN SQL_API SQLCancel(SQLHSTMT stmt) { |
| 192 | + ARROW_LOG(DEBUG) << "SQLCancel called with stmt: " << stmt; |
| 193 | + return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { |
| 194 | + throw driver::odbcabstraction::DriverException("SQLCancel is not implemented", |
| 195 | + "IM001"); |
| 196 | + return SQL_ERROR; |
| 197 | + }); |
| 198 | +} |
| 199 | + |
| 200 | +SQLRETURN SQL_API SQLCloseCursor(SQLHSTMT stmt) { |
| 201 | + return arrow::flight::sql::odbc::SQLCloseCursor(stmt); |
| 202 | +} |
| 203 | + |
| 204 | +SQLRETURN SQL_API SQLColAttribute(SQLHSTMT stmt, SQLUSMALLINT record_number, |
| 205 | + SQLUSMALLINT field_identifier, |
| 206 | + SQLPOINTER character_attribute_ptr, |
| 207 | + SQLSMALLINT buffer_length, SQLSMALLINT* output_length, |
| 208 | + SQLLEN* numeric_attribute_ptr) { |
| 209 | + return arrow::flight::sql::odbc::SQLColAttribute(stmt, record_number, field_identifier, |
| 210 | + character_attribute_ptr, buffer_length, |
| 211 | + output_length, numeric_attribute_ptr); |
| 212 | +} |
| 213 | + |
| 214 | +SQLRETURN SQL_API SQLTables(SQLHSTMT stmt, SQLWCHAR* catalog_name, |
| 215 | + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, |
| 216 | + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, |
| 217 | + SQLSMALLINT table_name_length, SQLWCHAR* table_type, |
| 218 | + SQLSMALLINT table_type_length) { |
| 219 | + return arrow::flight::sql::odbc::SQLTables( |
| 220 | + stmt, catalog_name, catalog_name_length, schema_name, schema_name_length, |
| 221 | + table_name, table_name_length, table_type, table_type_length); |
| 222 | +} |
| 223 | + |
| 224 | +SQLRETURN SQL_API SQLColumns(SQLHSTMT stmt, SQLWCHAR* catalog_name, |
| 225 | + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, |
| 226 | + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, |
| 227 | + SQLSMALLINT table_name_length, SQLWCHAR* columnName, |
| 228 | + SQLSMALLINT column_name_length) { |
| 229 | + return arrow::flight::sql::odbc::SQLColumns( |
| 230 | + stmt, catalog_name, catalog_name_length, schema_name, schema_name_length, |
| 231 | + table_name, table_name_length, columnName, column_name_length); |
| 232 | +} |
| 233 | + |
| 234 | +SQLRETURN SQL_API SQLForeignKeys( |
| 235 | + SQLHSTMT stmt, SQLWCHAR* pk_catalog_name, SQLSMALLINT pk_catalog_name_length, |
| 236 | + SQLWCHAR* pk_schema_name, SQLSMALLINT pk_schema_name_length, SQLWCHAR* pk_table_name, |
| 237 | + SQLSMALLINT pk_table_name_length, SQLWCHAR* fk_catalog_name, |
| 238 | + SQLSMALLINT fk_catalog_name_length, SQLWCHAR* fk_schema_name, |
| 239 | + SQLSMALLINT fk_schema_name_length, SQLWCHAR* fk_table_name, |
| 240 | + SQLSMALLINT fk_table_name_length) { |
| 241 | + ARROW_LOG(DEBUG) << "SQLForeignKeysW called with stmt: " << stmt |
| 242 | + << ", pk_catalog_name: " << static_cast<const void*>(pk_catalog_name) |
| 243 | + << ", pk_catalog_name_length: " << pk_catalog_name_length |
| 244 | + << ", pk_schema_name: " << static_cast<const void*>(pk_schema_name) |
| 245 | + << ", pk_schema_name_length: " << pk_schema_name_length |
| 246 | + << ", pk_table_name: " << static_cast<const void*>(pk_table_name) |
| 247 | + << ", pk_table_name_length: " << pk_table_name_length |
| 248 | + << ", fk_catalog_name: " << static_cast<const void*>(fk_catalog_name) |
| 249 | + << ", fk_catalog_name_length: " << fk_catalog_name_length |
| 250 | + << ", fk_schema_name: " << static_cast<const void*>(fk_schema_name) |
| 251 | + << ", fk_schema_name_length: " << fk_schema_name_length |
| 252 | + << ", fk_table_name: " << static_cast<const void*>(fk_table_name) |
| 253 | + << ", fk_table_name_length: " << fk_table_name_length; |
| 254 | + return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { |
| 255 | + throw driver::odbcabstraction::DriverException("SQLForeignKeysW is not implemented", |
| 256 | + "IM001"); |
| 257 | + return SQL_ERROR; |
| 258 | + }); |
| 259 | +} |
| 260 | + |
| 261 | +SQLRETURN SQL_API SQLGetTypeInfo(SQLHSTMT stmt, SQLSMALLINT data_type) { |
| 262 | + return arrow::flight::sql::odbc::SQLGetTypeInfo(stmt, data_type); |
| 263 | +} |
| 264 | + |
| 265 | +SQLRETURN SQL_API SQLMoreResults(SQLHSTMT stmt) { |
| 266 | + return arrow::flight::sql::odbc::SQLMoreResults(stmt); |
| 267 | +} |
| 268 | + |
| 269 | +SQLRETURN SQL_API SQLNativeSql(SQLHDBC conn, SQLWCHAR* in_statement_text, |
| 270 | + SQLINTEGER in_statement_text_length, |
| 271 | + SQLWCHAR* out_statement_text, SQLINTEGER buffer_length, |
| 272 | + SQLINTEGER* out_statement_text_length) { |
| 273 | + return arrow::flight::sql::odbc::SQLNativeSql( |
| 274 | + conn, in_statement_text, in_statement_text_length, out_statement_text, |
| 275 | + buffer_length, out_statement_text_length); |
| 276 | +} |
| 277 | + |
| 278 | +SQLRETURN SQL_API SQLNumResultCols(SQLHSTMT stmt, SQLSMALLINT* column_count_ptr) { |
| 279 | + return arrow::flight::sql::odbc::SQLNumResultCols(stmt, column_count_ptr); |
| 280 | +} |
| 281 | + |
| 282 | +SQLRETURN SQL_API SQLRowCount(SQLHSTMT stmt, SQLLEN* row_count_ptr) { |
| 283 | + return arrow::flight::sql::odbc::SQLRowCount(stmt, row_count_ptr); |
| 284 | +} |
| 285 | + |
| 286 | +SQLRETURN SQL_API SQLPrimaryKeys(SQLHSTMT stmt, SQLWCHAR* catalog_name, |
| 287 | + SQLSMALLINT catalog_name_length, SQLWCHAR* schema_name, |
| 288 | + SQLSMALLINT schema_name_length, SQLWCHAR* table_name, |
| 289 | + SQLSMALLINT table_name_length) { |
| 290 | + ARROW_LOG(DEBUG) << "SQLPrimaryKeysW called with stmt: " << stmt |
| 291 | + << ", catalog_name: " << static_cast<const void*>(catalog_name) |
| 292 | + << ", catalog_name_length: " << catalog_name_length |
| 293 | + << ", schema_name: " << static_cast<const void*>(schema_name) |
| 294 | + << ", schema_name_length: " << schema_name_length |
| 295 | + << ", table_name: " << static_cast<const void*>(table_name) |
| 296 | + << ", table_name_length: " << table_name_length; |
| 297 | + return ODBC::ODBCStatement::ExecuteWithDiagnostics(stmt, SQL_ERROR, [=]() { |
| 298 | + throw driver::odbcabstraction::DriverException("SQLPrimaryKeysW is not implemented", |
| 299 | + "IM001"); |
| 300 | + return SQL_ERROR; |
| 301 | + }); |
| 302 | +} |
| 303 | + |
| 304 | +SQLRETURN SQL_API SQLSetStmtAttr(SQLHSTMT stmt, SQLINTEGER attribute, |
| 305 | + SQLPOINTER value_ptr, SQLINTEGER stringLength) { |
| 306 | + return arrow::flight::sql::odbc::SQLSetStmtAttr(stmt, attribute, value_ptr, |
| 307 | + stringLength); |
| 308 | +} |
| 309 | + |
| 310 | +SQLRETURN SQL_API SQLDescribeCol(SQLHSTMT stmt, SQLUSMALLINT column_number, |
| 311 | + SQLWCHAR* column_name, SQLSMALLINT buffer_length, |
| 312 | + SQLSMALLINT* name_length_ptr, SQLSMALLINT* data_type_ptr, |
| 313 | + SQLULEN* column_size_ptr, |
| 314 | + SQLSMALLINT* decimal_digits_ptr, |
| 315 | + SQLSMALLINT* nullable_ptr) { |
| 316 | + return arrow::flight::sql::odbc::SQLDescribeCol( |
| 317 | + stmt, column_number, column_name, buffer_length, name_length_ptr, data_type_ptr, |
| 318 | + column_size_ptr, decimal_digits_ptr, nullable_ptr); |
38 | 319 | } |
0 commit comments