3030// GH-48083 TODO: replace `namespace ODBC` with `namespace arrow::flight::sql::odbc`
3131namespace ODBC {
3232
33- using arrow::flight::sql::odbc::Diagnostics;
34- using arrow::flight::sql::odbc::DriverException;
35- using arrow::flight::sql::odbc::WcsToUtf8;
36-
3733template <typename T, typename O>
3834inline void GetAttribute (T attribute_value, SQLPOINTER output, O output_size,
3935 O* output_len_ptr) {
@@ -70,7 +66,7 @@ inline SQLRETURN GetAttributeUTF8(std::string_view attribute_value, SQLPOINTER o
7066template <typename O>
7167inline SQLRETURN GetAttributeUTF8 (std::string_view attribute_value, SQLPOINTER output,
7268 O output_size, O* output_len_ptr,
73- Diagnostics& diagnostics) {
69+ arrow::flight::sql::odbc:: Diagnostics& diagnostics) {
7470 SQLRETURN result =
7571 GetAttributeUTF8 (attribute_value, output, output_size, output_len_ptr);
7672 if (SQL_SUCCESS_WITH_INFO == result) {
@@ -85,10 +81,11 @@ inline SQLRETURN GetAttributeSQLWCHAR(std::string_view attribute_value,
8581 O output_size, O* output_len_ptr) {
8682 size_t length = ConvertToSqlWChar (
8783 attribute_value, reinterpret_cast <SQLWCHAR*>(output),
88- is_length_in_bytes ? output_size : output_size * GetSqlWCharSize ());
84+ is_length_in_bytes ? output_size
85+ : output_size * arrow::flight::sql::odbc::GetSqlWCharSize ());
8986
9087 if (!is_length_in_bytes) {
91- length = length / GetSqlWCharSize ();
88+ length = length / arrow::flight::sql::odbc:: GetSqlWCharSize ();
9289 }
9390
9491 if (output_len_ptr) {
@@ -97,17 +94,19 @@ inline SQLRETURN GetAttributeSQLWCHAR(std::string_view attribute_value,
9794
9895 if (output &&
9996 output_size <
100- static_cast <O>(length + (is_length_in_bytes ? GetSqlWCharSize () : 1 ))) {
97+ static_cast <O>(length + (is_length_in_bytes
98+ ? arrow::flight::sql::odbc::GetSqlWCharSize ()
99+ : 1 ))) {
101100 return SQL_SUCCESS_WITH_INFO;
102101 }
103102 return SQL_SUCCESS;
104103}
105104
106105template <typename O>
107- inline SQLRETURN GetAttributeSQLWCHAR (std::string_view attribute_value,
108- bool is_length_in_bytes, SQLPOINTER output,
109- O output_size, O* output_len_ptr,
110- Diagnostics& diagnostics) {
106+ inline SQLRETURN GetAttributeSQLWCHAR (
107+ const std::string& attribute_value, bool is_length_in_bytes, SQLPOINTER output,
108+ O output_size, O* output_len_ptr,
109+ arrow::flight::sql::odbc:: Diagnostics& diagnostics) {
111110 SQLRETURN result = GetAttributeSQLWCHAR (attribute_value, is_length_in_bytes, output,
112111 output_size, output_len_ptr);
113112 if (SQL_SUCCESS_WITH_INFO == result) {
@@ -120,7 +119,7 @@ template <typename O>
120119inline SQLRETURN GetStringAttribute (bool is_unicode, std::string_view attribute_value,
121120 bool is_length_in_bytes, SQLPOINTER output,
122121 O output_size, O* output_len_ptr,
123- Diagnostics& diagnostics) {
122+ arrow::flight::sql::odbc:: Diagnostics& diagnostics) {
124123 SQLRETURN result = SQL_SUCCESS;
125124 if (is_unicode) {
126125 result = GetAttributeSQLWCHAR (attribute_value, is_length_in_bytes, output,
@@ -158,17 +157,20 @@ inline void SetAttributeSQLWCHAR(SQLPOINTER new_value, SQLINTEGER input_length_i
158157 std::string& attribute_to_write) {
159158 thread_local std::vector<uint8_t > utf8_str;
160159 if (input_length_in_bytes == SQL_NTS) {
161- WcsToUtf8 (new_value, &utf8_str);
160+ arrow::flight::sql::odbc:: WcsToUtf8 (new_value, &utf8_str);
162161 } else {
163- WcsToUtf8 (new_value, input_length_in_bytes / GetSqlWCharSize (), &utf8_str);
162+ arrow::flight::sql::odbc::WcsToUtf8 (
163+ new_value, input_length_in_bytes / arrow::flight::sql::odbc::GetSqlWCharSize (),
164+ &utf8_str);
164165 }
165166 attribute_to_write.assign ((char *)utf8_str.data ());
166167}
167168
168169template <typename T>
169170void CheckIfAttributeIsSetToOnlyValidValue (SQLPOINTER value, T allowed_value) {
170171 if (static_cast <T>(reinterpret_cast <SQLULEN>(value)) != allowed_value) {
171- throw DriverException (" Optional feature not implemented" , " HYC00" );
172+ throw arrow::flight::sql::odbc::DriverException (" Optional feature not implemented" ,
173+ " HYC00" );
172174 }
173175}
174176} // namespace ODBC
0 commit comments