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

Function SQLGetEnvAttr

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

Source from the content-addressed store, hash-verified

677}
678
679SQLRETURN SQLGetEnvAttr(SQLHENV env, SQLINTEGER attr, SQLPOINTER value_ptr,
680 SQLINTEGER buffer_length, SQLINTEGER* str_len_ptr) {
681 ARROW_LOG(DEBUG) << "SQLGetEnvAttr called with env: " << env << ", attr: " << attr
682 << ", value_ptr: " << value_ptr << ", buffer_length: " << buffer_length
683 << ", str_len_ptr: " << static_cast<const void*>(str_len_ptr);
684
685 using ODBC::ODBCEnvironment;
686
687 ODBCEnvironment* environment = reinterpret_cast<ODBCEnvironment*>(env);
688
689 return ODBCEnvironment::ExecuteWithDiagnostics(environment, SQL_ERROR, [=]() {
690 switch (attr) {
691 case SQL_ATTR_ODBC_VERSION: {
692 if (!value_ptr && !str_len_ptr) {
693 throw DriverException("Invalid null pointer for attribute.", "HY000");
694 }
695
696 if (value_ptr) {
697 SQLINTEGER* value = reinterpret_cast<SQLINTEGER*>(value_ptr);
698 *value = static_cast<SQLSMALLINT>(environment->GetODBCVersion());
699 }
700
701 if (str_len_ptr) {
702 *str_len_ptr = sizeof(SQLINTEGER);
703 }
704
705 return SQL_SUCCESS;
706 }
707
708 case SQL_ATTR_OUTPUT_NTS: {
709 if (!value_ptr && !str_len_ptr) {
710 throw DriverException("Invalid null pointer for attribute.", "HY000");
711 }
712
713 if (value_ptr) {
714 // output nts always returns SQL_TRUE
715 SQLINTEGER* value = reinterpret_cast<SQLINTEGER*>(value_ptr);
716 *value = SQL_TRUE;
717 }
718
719 if (str_len_ptr) {
720 *str_len_ptr = sizeof(SQLINTEGER);
721 }
722
723 return SQL_SUCCESS;
724 }
725
726 case SQL_ATTR_CONNECTION_POOLING: {
727 throw DriverException("Optional feature not supported.", "HYC00");
728 }
729
730 default: {
731 throw DriverException("Invalid attribute", "HYC00");
732 }
733 }
734 });
735}
736

Callers 2

TESTFunction · 0.50
TYPED_TESTFunction · 0.50

Calls 2

DriverExceptionClass · 0.85
GetODBCVersionMethod · 0.80

Tested by 2

TESTFunction · 0.40
TYPED_TESTFunction · 0.40