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

Function SQLError

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

Source from the content-addressed store, hash-verified

251
252#if defined(__APPLE__)
253SQLRETURN SQLError(SQLHENV env, SQLHDBC conn, SQLHSTMT stmt, SQLWCHAR* sql_state,
254 SQLINTEGER* native_error_ptr, SQLWCHAR* message_text,
255 SQLSMALLINT buffer_length, SQLSMALLINT* text_length_ptr) {
256 ARROW_LOG(DEBUG) << "SQLError called with env: " << env << ", conn: " << conn
257 << ", stmt: " << stmt
258 << ", sql_state: " << static_cast<const void*>(sql_state)
259 << ", native_error_ptr: " << static_cast<const void*>(native_error_ptr)
260 << ", message_text: " << static_cast<const void*>(message_text)
261 << ", buffer_length: " << buffer_length
262 << ", text_length_ptr: " << static_cast<const void*>(text_length_ptr);
263
264 SQLSMALLINT handle_type;
265 SQLHANDLE handle;
266
267 if (env) {
268 handle_type = SQL_HANDLE_ENV;
269 handle = static_cast<SQLHANDLE>(env);
270 } else if (conn) {
271 handle_type = SQL_HANDLE_DBC;
272 handle = static_cast<SQLHANDLE>(conn);
273 } else if (stmt) {
274 handle_type = SQL_HANDLE_STMT;
275 handle = static_cast<SQLHANDLE>(stmt);
276 } else {
277 return static_cast<SQLRETURN>(SQL_INVALID_HANDLE);
278 }
279
280 // Use the last record
281 SQLINTEGER diag_number;
282 SQLSMALLINT diag_number_length;
283
284 SQLRETURN ret = arrow::flight::sql::odbc::SQLGetDiagField(
285 handle_type, handle, 0, SQL_DIAG_NUMBER, &diag_number, sizeof(SQLINTEGER), 0);
286 if (ret != SQL_SUCCESS) {
287 return ret;
288 }
289
290 if (diag_number == 0) {
291 return SQL_NO_DATA;
292 }
293
294 SQLSMALLINT rec_number = static_cast<SQLSMALLINT>(diag_number);
295
296 return arrow::flight::sql::odbc::SQLGetDiagRec(
297 handle_type, handle, rec_number, sql_state, native_error_ptr, message_text,
298 buffer_length, text_length_ptr);
299}
300#endif // __APPLE__
301
302inline bool IsValidStringFieldArgs(SQLPOINTER diag_info_ptr, SQLSMALLINT buffer_length,

Callers 1

TYPED_TESTFunction · 0.50

Calls 2

SQLGetDiagFieldFunction · 0.70
SQLGetDiagRecFunction · 0.70

Tested by 1

TYPED_TESTFunction · 0.40