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

Function SQLGetDiagField

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

Source from the content-addressed store, hash-verified

313}
314
315SQLRETURN SQLGetDiagField(SQLSMALLINT handle_type, SQLHANDLE handle,
316 SQLSMALLINT rec_number, SQLSMALLINT diag_identifier,
317 SQLPOINTER diag_info_ptr, SQLSMALLINT buffer_length,
318 SQLSMALLINT* string_length_ptr) {
319 // GH-46573 TODO: Implement additional fields types
320 ARROW_LOG(DEBUG) << "SQLGetDiagFieldW called with handle_type: " << handle_type
321 << ", handle: " << handle << ", rec_number: " << rec_number
322 << ", diag_identifier: " << diag_identifier
323 << ", diag_info_ptr: " << diag_info_ptr
324 << ", buffer_length: " << buffer_length << ", string_length_ptr: "
325 << static_cast<const void*>(string_length_ptr);
326 using ODBC::GetStringAttribute;
327 using ODBC::ODBCConnection;
328 using ODBC::ODBCDescriptor;
329 using ODBC::ODBCEnvironment;
330 using ODBC::ODBCStatement;
331
332 if (!handle) {
333 return SQL_INVALID_HANDLE;
334 }
335
336 if (!diag_info_ptr && !string_length_ptr) {
337 return SQL_ERROR;
338 }
339
340 // If buffer length derived from null terminated string
341 if (diag_info_ptr && buffer_length == SQL_NTS) {
342 const wchar_t* str = reinterpret_cast<wchar_t*>(diag_info_ptr);
343 buffer_length = wcslen(str) * GetSqlWCharSize();
344 }
345
346 // Set character type to be Unicode by default
347 const bool is_unicode = true;
348 Diagnostics* diagnostics = nullptr;
349
350 switch (handle_type) {
351 case SQL_HANDLE_ENV: {
352 ODBCEnvironment* environment = reinterpret_cast<ODBCEnvironment*>(handle);
353 diagnostics = &environment->GetDiagnostics();
354 break;
355 }
356
357 case SQL_HANDLE_DBC: {
358 ODBCConnection* connection = reinterpret_cast<ODBCConnection*>(handle);
359 diagnostics = &connection->GetDiagnostics();
360 break;
361 }
362
363 case SQL_HANDLE_DESC: {
364 ODBCDescriptor* descriptor = reinterpret_cast<ODBCDescriptor*>(handle);
365 diagnostics = &descriptor->GetDiagnostics();
366 break;
367 }
368
369 case SQL_HANDLE_STMT: {
370 ODBCStatement* statement = reinterpret_cast<ODBCStatement*>(handle);
371 diagnostics = &statement->GetDiagnostics();
372 break;

Callers 2

SQLErrorFunction · 0.70
TYPED_TESTFunction · 0.50

Calls 9

GetSqlWCharSizeFunction · 0.85
IsValidStringFieldArgsFunction · 0.85
GetStringAttributeFunction · 0.85
GetRecordCountMethod · 0.80
HasRecordMethod · 0.80
GetMessageTextMethod · 0.80
GetConnectionMethod · 0.80
GetSQLStateMethod · 0.80
GetNativeErrorMethod · 0.45

Tested by 1

TYPED_TESTFunction · 0.40