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

Function SQLGetDiagField

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

Source from the content-addressed store, hash-verified

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