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

Method Execute

cpp/src/arrow/flight/sql/odbc/odbc_impl/odbc_handle.h:45–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43
44 template <typename Function>
45 inline SQLRETURN Execute(SQLRETURN rc, Function function) {
46 try {
47 GetDiagnostics().Clear();
48 rc = function();
49 } catch (const arrow::flight::sql::odbc::AuthenticationException& ex) {
50 GetDiagnostics().AddError(arrow::flight::sql::odbc::DriverException(
51 ex.GetMessageText(), ex.GetSqlState(), ex.GetNativeError()));
52 } catch (const arrow::flight::sql::odbc::NullWithoutIndicatorException& ex) {
53 GetDiagnostics().AddError(arrow::flight::sql::odbc::DriverException(
54 ex.GetMessageText(), ex.GetSqlState(), ex.GetNativeError()));
55 }
56 // on mac, DriverException doesn't catch the subclass exceptions hence we added
57 // the following above.
58 // GH-48278 TODO investigate if there is a way to catch all the subclass exceptions
59 // under DriverException
60 catch (const arrow::flight::sql::odbc::DriverException& ex) {
61 GetDiagnostics().AddError(ex);
62 } catch (const std::bad_alloc&) {
63 GetDiagnostics().AddError(arrow::flight::sql::odbc::DriverException(
64 "A memory allocation error occurred.", "HY001"));
65 } catch (const std::exception& ex) {
66 GetDiagnostics().AddError(arrow::flight::sql::odbc::DriverException(ex.what()));
67 } catch (...) {
68 GetDiagnostics().AddError(
69 arrow::flight::sql::odbc::DriverException("An unknown error occurred."));
70 }
71
72 if (GetDiagnostics().HasError()) {
73 return SQL_ERROR;
74 }
75 if (SQL_SUCCEEDED(rc) && GetDiagnostics().HasWarning()) {
76 return SQL_SUCCESS_WITH_INFO;
77 }
78 return rc;
79 }
80
81 template <typename Function>
82 inline SQLRETURN ExecuteWithLock(SQLRETURN rc, Function function) {

Callers 1

Calls 8

DriverExceptionClass · 0.85
AddErrorMethod · 0.80
GetMessageTextMethod · 0.80
HasWarningMethod · 0.80
ClearMethod · 0.45
GetNativeErrorMethod · 0.45
whatMethod · 0.45
HasErrorMethod · 0.45

Tested by

no test coverage detected