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

Function SQLGetEnvAttr

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

Source from the content-addressed store, hash-verified

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

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