diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.cc index 0ea4fcc5cef6f..659b7638cd335 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.cc @@ -56,8 +56,8 @@ inline RowStatus MoveSingleCellToBinaryBuffer(ColumnBinding* binding, BinaryArra value_offset = -1; } - if (binding->strlen_buffer) { - binding->strlen_buffer[i] = static_cast(remaining_length); + if (binding->str_len_buffer) { + binding->str_len_buffer[i] = static_cast(remaining_length); } return result; @@ -72,7 +72,7 @@ BinaryArrayFlightSqlAccessor::BinaryArrayFlightSqlAccessor(Array* a template <> RowStatus -BinaryArrayFlightSqlAccessor::MoveSingleCell_impl( +BinaryArrayFlightSqlAccessor::MoveSingleCellImpl( ColumnBinding* binding, int64_t arrow_row, int64_t i, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) { return MoveSingleCellToBinaryBuffer(binding, this->GetArray(), arrow_row, i, @@ -80,7 +80,7 @@ BinaryArrayFlightSqlAccessor::MoveSingleCell_ } template -size_t BinaryArrayFlightSqlAccessor::GetCellLength_impl( +size_t BinaryArrayFlightSqlAccessor::GetCellLengthImpl( ColumnBinding* binding) const { return binding->buffer_length; } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.h index 9c8cb1fa23f47..7b74288118989 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor.h @@ -34,11 +34,11 @@ class BinaryArrayFlightSqlAccessor public: explicit BinaryArrayFlightSqlAccessor(Array* array); - RowStatus MoveSingleCell_impl(ColumnBinding* binding, int64_t arrow_row, int64_t i, - int64_t& value_offset, bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics); + RowStatus MoveSingleCellImpl(ColumnBinding* binding, int64_t arrow_row, int64_t i, + int64_t& value_offset, bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics); - size_t GetCellLength_impl(ColumnBinding* binding) const; + size_t GetCellLengthImpl(ColumnBinding* binding) const; }; } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor_test.cc index 647b9b9fe5238..51d8b9bbb6b11 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/binary_array_accessor_test.cc @@ -35,12 +35,12 @@ TEST(BinaryArrayAccessor, Test_CDataType_BINARY_Basic) { BinaryArrayFlightSqlAccessor accessor(array.get()); - size_t max_strlen = 64; - std::vector buffer(values.size() * max_strlen); - std::vector strlen_buffer(values.size()); + size_t max_str_len = 64; + std::vector buffer(values.size() * max_str_len); + std::vector str_len_buffer(values.size()); ColumnBinding binding(odbcabstraction::CDataType_BINARY, 0, 0, buffer.data(), - max_strlen, strlen_buffer.data()); + max_str_len, str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -49,12 +49,13 @@ TEST(BinaryArrayAccessor, Test_CDataType_BINARY_Basic) { diagnostics, nullptr)); for (int i = 0; i < values.size(); ++i) { - ASSERT_EQ(values[i].length(), strlen_buffer[i]); + ASSERT_EQ(values[i].length(), str_len_buffer[i]); // Beware that CDataType_BINARY values are not null terminated. // It's safe to create a std::string from this data because we know it's // ASCII, this doesn't work with arbitrary binary data. - ASSERT_EQ(values[i], std::string(buffer.data() + i * max_strlen, - buffer.data() + i * max_strlen + strlen_buffer[i])); + ASSERT_EQ(values[i], + std::string(buffer.data() + i * max_str_len, + buffer.data() + i * max_str_len + str_len_buffer[i])); } } @@ -65,12 +66,12 @@ TEST(BinaryArrayAccessor, Test_CDataType_BINARY_Truncation) { BinaryArrayFlightSqlAccessor accessor(array.get()); - size_t max_strlen = 8; - std::vector buffer(values.size() * max_strlen); - std::vector strlen_buffer(values.size()); + size_t max_str_len = 8; + std::vector buffer(values.size() * max_str_len); + std::vector str_len_buffer(values.size()); ColumnBinding binding(odbcabstraction::CDataType_BINARY, 0, 0, buffer.data(), - max_strlen, strlen_buffer.data()); + max_str_len, str_len_buffer.data()); std::stringstream ss; int64_t value_offset = 0; @@ -83,13 +84,13 @@ TEST(BinaryArrayAccessor, Test_CDataType_BINARY_Truncation) { int64_t original_value_offset = value_offset; ASSERT_EQ(1, accessor.GetColumnarData(&binding, 0, 1, value_offset, true, diagnostics, nullptr)); - ASSERT_EQ(values[0].length() - original_value_offset, strlen_buffer[0]); + ASSERT_EQ(values[0].length() - original_value_offset, str_len_buffer[0]); int64_t chunk_length = 0; if (value_offset == -1) { - chunk_length = strlen_buffer[0]; + chunk_length = str_len_buffer[0]; } else { - chunk_length = max_strlen; + chunk_length = max_str_len; } // Beware that CDataType_BINARY values are not null terminated. diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor.cc index 6026a833cbb34..ea4d1ba72c2f5 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor.cc @@ -29,7 +29,7 @@ BooleanArrayFlightSqlAccessor::BooleanArrayFlightSqlAccessor(Array* BooleanArrayFlightSqlAccessor>(array) {} template -RowStatus BooleanArrayFlightSqlAccessor::MoveSingleCell_impl( +RowStatus BooleanArrayFlightSqlAccessor::MoveSingleCellImpl( ColumnBinding* binding, int64_t arrow_row, int64_t i, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) { typedef unsigned char c_type; @@ -38,15 +38,15 @@ RowStatus BooleanArrayFlightSqlAccessor::MoveSingleCell_impl( auto* buffer = static_cast(binding->buffer); buffer[i] = value ? 1 : 0; - if (binding->strlen_buffer) { - binding->strlen_buffer[i] = static_cast(GetCellLength_impl(binding)); + if (binding->str_len_buffer) { + binding->str_len_buffer[i] = static_cast(GetCellLengthImpl(binding)); } return odbcabstraction::RowStatus_SUCCESS; } template -size_t BooleanArrayFlightSqlAccessor::GetCellLength_impl( +size_t BooleanArrayFlightSqlAccessor::GetCellLengthImpl( ColumnBinding* binding) const { return sizeof(unsigned char); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor.h index 682bb3a7564a8..217cc0845c62a 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor.h @@ -35,11 +35,11 @@ class BooleanArrayFlightSqlAccessor public: explicit BooleanArrayFlightSqlAccessor(Array* array); - RowStatus MoveSingleCell_impl(ColumnBinding* binding, int64_t arrow_row, int64_t i, - int64_t& value_offset, bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics); + RowStatus MoveSingleCellImpl(ColumnBinding* binding, int64_t arrow_row, int64_t i, + int64_t& value_offset, bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics); - size_t GetCellLength_impl(ColumnBinding* binding) const; + size_t GetCellLengthImpl(ColumnBinding* binding) const; }; } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor_test.cc index bf77dbc89fc5b..31688200a564e 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/boolean_array_accessor_test.cc @@ -35,10 +35,10 @@ TEST(BooleanArrayFlightSqlAccessor, Test_BooleanArray_CDataType_BIT) { BooleanArrayFlightSqlAccessor accessor(array.get()); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); ColumnBinding binding(odbcabstraction::CDataType_BIT, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -47,7 +47,7 @@ TEST(BooleanArrayFlightSqlAccessor, Test_BooleanArray_CDataType_BIT) { diagnostics, nullptr)); for (int i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(unsigned char), strlen_buffer[i]); + ASSERT_EQ(sizeof(unsigned char), str_len_buffer[i]); ASSERT_EQ(values[i] ? 1 : 0, buffer[i]); } } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/common.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/common.h index 5888d8d0ccd04..8b74028a9c86e 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/common.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/common.h @@ -33,13 +33,13 @@ inline size_t CopyFromArrayValuesToBinding(ARRAY_TYPE* array, ColumnBinding* bin int64_t starting_row, int64_t cells) { constexpr ssize_t element_size = sizeof(typename ARRAY_TYPE::value_type); - if (binding->strlen_buffer) { + if (binding->str_len_buffer) { for (int64_t i = 0; i < cells; ++i) { int64_t current_row = starting_row + i; if (array->IsNull(current_row)) { - binding->strlen_buffer[i] = odbcabstraction::NULL_DATA; + binding->str_len_buffer[i] = odbcabstraction::NULL_DATA; } else { - binding->strlen_buffer[i] = element_size; + binding->str_len_buffer[i] = element_size; } } } else { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.cc index ab139efc923c0..b4f39b69de412 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.cc @@ -60,7 +60,7 @@ DateArrayFlightSqlAccessor::DateArrayFlightSqlAccessor DateArrayFlightSqlAccessor>(array) {} template -RowStatus DateArrayFlightSqlAccessor::MoveSingleCell_impl( +RowStatus DateArrayFlightSqlAccessor::MoveSingleCellImpl( ColumnBinding* binding, int64_t arrow_row, int64_t cell_counter, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) { @@ -74,16 +74,16 @@ RowStatus DateArrayFlightSqlAccessor::MoveSingleCell_i buffer[cell_counter].month = date.tm_mon + 1; buffer[cell_counter].day = date.tm_mday; - if (binding->strlen_buffer) { - binding->strlen_buffer[cell_counter] = - static_cast(GetCellLength_impl(binding)); + if (binding->str_len_buffer) { + binding->str_len_buffer[cell_counter] = + static_cast(GetCellLengthImpl(binding)); } return odbcabstraction::RowStatus_SUCCESS; } template -size_t DateArrayFlightSqlAccessor::GetCellLength_impl( +size_t DateArrayFlightSqlAccessor::GetCellLengthImpl( ColumnBinding* binding) const { return sizeof(DATE_STRUCT); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.h index 5e2a3dc37234b..42f3d4ba22087 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor.h @@ -34,12 +34,12 @@ class DateArrayFlightSqlAccessor public: explicit DateArrayFlightSqlAccessor(Array* array); - RowStatus MoveSingleCell_impl(ColumnBinding* binding, int64_t arrow_row, - int64_t cell_counter, int64_t& value_offset, - bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics); + RowStatus MoveSingleCellImpl(ColumnBinding* binding, int64_t arrow_row, + int64_t cell_counter, int64_t& value_offset, + bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics); - size_t GetCellLength_impl(ColumnBinding* binding) const; + size_t GetCellLengthImpl(ColumnBinding* binding) const; }; } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor_test.cc index fdd48d2706aa8..b4a0a5d11288f 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/date_array_accessor_test.cc @@ -51,10 +51,10 @@ TEST(DateArrayAccessor, Test_Date32Array_CDataType_DATE) { dynamic_cast*>(array.get())); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); ColumnBinding binding(odbcabstraction::CDataType_DATE, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -63,7 +63,7 @@ TEST(DateArrayAccessor, Test_Date32Array_CDataType_DATE) { diagnostics, nullptr)); for (size_t i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(DATE_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(DATE_STRUCT), str_len_buffer[i]); ASSERT_EQ(expected[i].year, buffer[i].year); ASSERT_EQ(expected[i].month, buffer[i].month); @@ -89,10 +89,10 @@ TEST(DateArrayAccessor, Test_Date64Array_CDataType_DATE) { dynamic_cast*>(array.get())); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); ColumnBinding binding(odbcabstraction::CDataType_DATE, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -101,7 +101,7 @@ TEST(DateArrayAccessor, Test_Date64Array_CDataType_DATE) { diagnostics, nullptr)); for (size_t i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(DATE_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(DATE_STRUCT), str_len_buffer[i]); ASSERT_EQ(expected[i].year, buffer[i].year); ASSERT_EQ(expected[i].month, buffer[i].month); ASSERT_EQ(expected[i].day, buffer[i].day); diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor.cc index f6ac1023243e9..f093e152fdbbc 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor.cc @@ -42,9 +42,9 @@ DecimalArrayFlightSqlAccessor::DecimalArrayFlightSqlAc template <> RowStatus DecimalArrayFlightSqlAccessor:: - MoveSingleCell_impl(ColumnBinding* binding, int64_t arrow_row, int64_t i, - int64_t& value_offset, bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics) { + MoveSingleCellImpl(ColumnBinding* binding, int64_t arrow_row, int64_t i, + int64_t& value_offset, bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics) { auto result = &(static_cast(binding->buffer)[i]); int32_t original_scale = data_type_->scale(); @@ -74,15 +74,15 @@ DecimalArrayFlightSqlAccessorprecision = data_type_->precision(); - if (binding->strlen_buffer) { - binding->strlen_buffer[i] = static_cast(GetCellLength_impl(binding)); + if (binding->str_len_buffer) { + binding->str_len_buffer[i] = static_cast(GetCellLengthImpl(binding)); } return odbcabstraction::RowStatus_SUCCESS; } template -size_t DecimalArrayFlightSqlAccessor::GetCellLength_impl( +size_t DecimalArrayFlightSqlAccessor::GetCellLengthImpl( ColumnBinding* binding) const { return sizeof(NUMERIC_STRUCT); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor.h index c7a0c7fed1599..235e48446e266 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor.h @@ -37,11 +37,11 @@ class DecimalArrayFlightSqlAccessor public: explicit DecimalArrayFlightSqlAccessor(Array* array); - RowStatus MoveSingleCell_impl(ColumnBinding* binding, int64_t arrow_row, int64_t i, - int64_t& value_offset, bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics); + RowStatus MoveSingleCellImpl(ColumnBinding* binding, int64_t arrow_row, int64_t i, + int64_t& value_offset, bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics); - size_t GetCellLength_impl(ColumnBinding* binding) const; + size_t GetCellLengthImpl(ColumnBinding* binding) const; private: Decimal128Type* data_type_; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor_test.cc index ad79f75523497..7abdc160efdbf 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/decimal_array_accessor_test.cc @@ -84,10 +84,10 @@ void AssertNumericOutput(int input_precision, int input_scale, accessor(array.get()); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); ColumnBinding binding(odbcabstraction::CDataType_NUMERIC, output_precision, - output_scale, buffer.data(), 0, strlen_buffer.data()); + output_scale, buffer.data(), 0, str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -96,7 +96,7 @@ void AssertNumericOutput(int input_precision, int input_scale, diagnostics, nullptr)); for (int i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(NUMERIC_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(NUMERIC_STRUCT), str_len_buffer[i]); ASSERT_EQ(output_precision, buffer[i].precision); ASSERT_EQ(output_scale, buffer[i].scale); diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.cc index c59f52eba3bcd..9bc135e9de2e3 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.cc @@ -39,7 +39,7 @@ PrimitiveArrayFlightSqlAccessor< array) {} template -size_t PrimitiveArrayFlightSqlAccessor::GetColumnarData_impl( +size_t PrimitiveArrayFlightSqlAccessor::GetColumnarDataImpl( ColumnBinding* binding, int64_t starting_row, int64_t cells, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics, uint16_t* row_status_array) { @@ -48,7 +48,7 @@ size_t PrimitiveArrayFlightSqlAccessor::GetColumnarDat } template -size_t PrimitiveArrayFlightSqlAccessor::GetCellLength_impl( +size_t PrimitiveArrayFlightSqlAccessor::GetCellLengthImpl( ColumnBinding* binding) const { return sizeof(typename ARROW_ARRAY::TypeClass::c_type); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.h index a8d828d485bd7..30fc0465bb8f7 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor.h @@ -35,12 +35,12 @@ class PrimitiveArrayFlightSqlAccessor public: explicit PrimitiveArrayFlightSqlAccessor(Array* array); - size_t GetColumnarData_impl(ColumnBinding* binding, int64_t starting_row, int64_t cells, - int64_t& value_offset, bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics, - uint16_t* row_status_array); + size_t GetColumnarDataImpl(ColumnBinding* binding, int64_t starting_row, int64_t cells, + int64_t& value_offset, bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics, + uint16_t* row_status_array); - size_t GetCellLength_impl(ColumnBinding* binding) const; + size_t GetCellLengthImpl(ColumnBinding* binding) const; }; } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor_test.cc index 820c0a7bd8402..d291b9e08f9e4 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/primitive_array_accessor_test.cc @@ -48,10 +48,10 @@ void TestPrimitiveArraySqlAccessor() { PrimitiveArrayFlightSqlAccessor accessor(array.get()); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); ColumnBinding binding(TARGET_TYPE, 0, 0, buffer.data(), values.size(), - strlen_buffer.data()); + str_len_buffer.data()); int64_t value_offset = 0; driver::odbcabstraction::Diagnostics diagnostics("Dummy", "Dummy", @@ -61,7 +61,7 @@ void TestPrimitiveArraySqlAccessor() { diagnostics, nullptr)); for (int i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(c_type), strlen_buffer[i]); + ASSERT_EQ(sizeof(c_type), str_len_buffer[i]); ASSERT_EQ(values[i], buffer[i]); } } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor.cc index 92f535b13ff79..fc1e97a4765b7 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor.cc @@ -31,11 +31,11 @@ using odbcabstraction::RowStatus; namespace { #if defined _WIN32 || defined _WIN64 -std::string utf8_to_clocale(const char* utf8str, int len) { +std::string Utf8ToCLocale(const char* utf8_str, int len) { thread_local boost::locale::generator g; g.locale_cache_enabled(true); std::locale loc = g(boost::locale::util::get_system_locale()); - return boost::locale::conv::from_utf(utf8str, utf8str + len, loc); + return boost::locale::conv::from_utf(utf8_str, utf8_str + len, loc); } #endif @@ -69,7 +69,7 @@ inline RowStatus MoveSingleCellToCharBuffer(std::vector& buffer, #if defined _WIN32 || defined _WIN64 // Convert to C locale string if (last_retrieved_arrow_row != arrow_row) { - clocale_str = utf8_to_clocale(raw_value, raw_value_length); + clocale_str = Utf8ToCLocale(raw_value, raw_value_length); last_retrieved_arrow_row = arrow_row; } const char* clocale_data = clocale_str.data(); @@ -112,8 +112,8 @@ inline RowStatus MoveSingleCellToCharBuffer(std::vector& buffer, } } - if (binding->strlen_buffer) { - binding->strlen_buffer[i] = static_cast(remaining_length); + if (binding->str_len_buffer) { + binding->str_len_buffer[i] = static_cast(remaining_length); } return result; @@ -129,7 +129,7 @@ StringArrayFlightSqlAccessor::StringArrayFlightSqlAccess last_arrow_row_(-1) {} template -RowStatus StringArrayFlightSqlAccessor::MoveSingleCell_impl( +RowStatus StringArrayFlightSqlAccessor::MoveSingleCellImpl( ColumnBinding* binding, int64_t arrow_row, int64_t i, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) { return MoveSingleCellToCharBuffer(buffer_, last_arrow_row_, @@ -142,7 +142,7 @@ RowStatus StringArrayFlightSqlAccessor::MoveSingleCell_i } template -size_t StringArrayFlightSqlAccessor::GetCellLength_impl( +size_t StringArrayFlightSqlAccessor::GetCellLengthImpl( ColumnBinding* binding) const { return binding->buffer_length; } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor.h index f297fba329c36..ed1a9e83ab43a 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor.h @@ -41,11 +41,11 @@ class StringArrayFlightSqlAccessor public: explicit StringArrayFlightSqlAccessor(Array* array); - RowStatus MoveSingleCell_impl(ColumnBinding* binding, int64_t arrow_row, int64_t i, - int64_t& value_offset, bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics); + RowStatus MoveSingleCellImpl(ColumnBinding* binding, int64_t arrow_row, int64_t i, + int64_t& value_offset, bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics); - size_t GetCellLength_impl(ColumnBinding* binding) const; + size_t GetCellLengthImpl(ColumnBinding* binding) const; private: std::vector buffer_; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor_test.cc index 8b568bbffcf58..3289914ffb5d0 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/string_array_accessor_test.cc @@ -37,12 +37,12 @@ TEST(StringArrayAccessor, Test_CDataType_CHAR_Basic) { StringArrayFlightSqlAccessor accessor( array.get()); - size_t max_strlen = 64; - std::vector buffer(values.size() * max_strlen); - std::vector strlen_buffer(values.size()); + size_t max_str_len = 64; + std::vector buffer(values.size() * max_str_len); + std::vector str_len_buffer(values.size()); - ColumnBinding binding(odbcabstraction::CDataType_CHAR, 0, 0, buffer.data(), max_strlen, - strlen_buffer.data()); + ColumnBinding binding(odbcabstraction::CDataType_CHAR, 0, 0, buffer.data(), max_str_len, + str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -51,8 +51,8 @@ TEST(StringArrayAccessor, Test_CDataType_CHAR_Basic) { diagnostics, nullptr)); for (int i = 0; i < values.size(); ++i) { - ASSERT_EQ(values[i].length(), strlen_buffer[i]); - ASSERT_EQ(values[i], std::string(buffer.data() + i * max_strlen)); + ASSERT_EQ(values[i].length(), str_len_buffer[i]); + ASSERT_EQ(values[i], std::string(buffer.data() + i * max_str_len)); } } @@ -64,12 +64,12 @@ TEST(StringArrayAccessor, Test_CDataType_CHAR_Truncation) { StringArrayFlightSqlAccessor accessor( array.get()); - size_t max_strlen = 8; - std::vector buffer(values.size() * max_strlen); - std::vector strlen_buffer(values.size()); + size_t max_str_len = 8; + std::vector buffer(values.size() * max_str_len); + std::vector str_len_buffer(values.size()); - ColumnBinding binding(odbcabstraction::CDataType_CHAR, 0, 0, buffer.data(), max_strlen, - strlen_buffer.data()); + ColumnBinding binding(odbcabstraction::CDataType_CHAR, 0, 0, buffer.data(), max_str_len, + str_len_buffer.data()); std::stringstream ss; int64_t value_offset = 0; @@ -82,7 +82,7 @@ TEST(StringArrayAccessor, Test_CDataType_CHAR_Truncation) { int64_t original_value_offset = value_offset; ASSERT_EQ(1, accessor.GetColumnarData(&binding, 0, 1, value_offset, true, diagnostics, nullptr)); - ASSERT_EQ(values[0].length() - original_value_offset, strlen_buffer[0]); + ASSERT_EQ(values[0].length() - original_value_offset, str_len_buffer[0]); ss << buffer.data(); } while (value_offset < static_cast(values[0].length()) && value_offset != -1); @@ -97,12 +97,12 @@ TEST(StringArrayAccessor, Test_CDataType_WCHAR_Basic) { auto accessor = CreateWCharStringArrayAccessor(array.get()); - size_t max_strlen = 64; - std::vector buffer(values.size() * max_strlen); - std::vector strlen_buffer(values.size()); + size_t max_str_len = 64; + std::vector buffer(values.size() * max_str_len); + std::vector str_len_buffer(values.size()); - ColumnBinding binding(odbcabstraction::CDataType_WCHAR, 0, 0, buffer.data(), max_strlen, - strlen_buffer.data()); + ColumnBinding binding(odbcabstraction::CDataType_WCHAR, 0, 0, buffer.data(), + max_str_len, str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -111,11 +111,11 @@ TEST(StringArrayAccessor, Test_CDataType_WCHAR_Basic) { diagnostics, nullptr)); for (int i = 0; i < values.size(); ++i) { - ASSERT_EQ(values[i].length() * GetSqlWCharSize(), strlen_buffer[i]); + ASSERT_EQ(values[i].length() * GetSqlWCharSize(), str_len_buffer[i]); std::vector expected; Utf8ToWcs(values[i].c_str(), &expected); - uint8_t* start = buffer.data() + i * max_strlen; - auto actual = std::vector(start, start + strlen_buffer[i]); + uint8_t* start = buffer.data() + i * max_str_len; + auto actual = std::vector(start, start + str_len_buffer[i]); ASSERT_EQ(expected, actual); } } @@ -127,12 +127,12 @@ TEST(StringArrayAccessor, Test_CDataType_WCHAR_Truncation) { auto accessor = CreateWCharStringArrayAccessor(array.get()); - size_t max_strlen = 8; - std::vector buffer(values.size() * max_strlen); - std::vector strlen_buffer(values.size()); + size_t max_str_len = 8; + std::vector buffer(values.size() * max_str_len); + std::vector str_len_buffer(values.size()); - ColumnBinding binding(odbcabstraction::CDataType_WCHAR, 0, 0, buffer.data(), max_strlen, - strlen_buffer.data()); + ColumnBinding binding(odbcabstraction::CDataType_WCHAR, 0, 0, buffer.data(), + max_str_len, str_len_buffer.data()); std::basic_stringstream ss; int64_t value_offset = 0; @@ -147,7 +147,7 @@ TEST(StringArrayAccessor, Test_CDataType_WCHAR_Truncation) { ASSERT_EQ(1, accessor->GetColumnarData(&binding, 0, 1, value_offset, true, diagnostics, nullptr)); ASSERT_EQ(values[0].length() * GetSqlWCharSize() - original_value_offset, - strlen_buffer[0]); + str_len_buffer[0]); size_t length = value_offset - original_value_offset; if (value_offset == -1) { diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor.cc index 93bf11778bfea..0ffa9fc84a7f6 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor.cc @@ -97,7 +97,7 @@ TimeArrayFlightSqlAccessor::TimeArrayFlightSqlAc array) {} template -RowStatus TimeArrayFlightSqlAccessor::MoveSingleCell_impl( +RowStatus TimeArrayFlightSqlAccessor::MoveSingleCellImpl( ColumnBinding* binding, int64_t arrow_row, int64_t cell_counter, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostic) { @@ -114,15 +114,15 @@ RowStatus TimeArrayFlightSqlAccessor::MoveSingle buffer[cell_counter].minute = time.tm_min; buffer[cell_counter].second = time.tm_sec; - if (binding->strlen_buffer) { - binding->strlen_buffer[cell_counter] = - static_cast(GetCellLength_impl(binding)); + if (binding->str_len_buffer) { + binding->str_len_buffer[cell_counter] = + static_cast(GetCellLengthImpl(binding)); } return odbcabstraction::RowStatus_SUCCESS; } template -size_t TimeArrayFlightSqlAccessor::GetCellLength_impl( +size_t TimeArrayFlightSqlAccessor::GetCellLengthImpl( ColumnBinding* binding) const { return sizeof(TIME_STRUCT); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor.h index 76d62c3320f2b..0d1997d7281a7 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor.h @@ -37,12 +37,12 @@ class TimeArrayFlightSqlAccessor public: explicit TimeArrayFlightSqlAccessor(Array* array); - RowStatus MoveSingleCell_impl(ColumnBinding* binding, int64_t arrow_row, - int64_t cell_counter, int64_t& value_offset, - bool update_value_offset, - odbcabstraction::Diagnostics& diagnostic); + RowStatus MoveSingleCellImpl(ColumnBinding* binding, int64_t arrow_row, + int64_t cell_counter, int64_t& value_offset, + bool update_value_offset, + odbcabstraction::Diagnostics& diagnostic); - size_t GetCellLength_impl(ColumnBinding* binding) const; + size_t GetCellLengthImpl(ColumnBinding* binding) const; }; } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor_test.cc index d04a098e23d4f..e9b5b95b2caa5 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/time_array_accessor_test.cc @@ -50,10 +50,10 @@ TEST(TEST_TIME32, TIME_WITH_SECONDS) { accessor(time32_array.get()); std::vector buffer(t32_values.size()); - std::vector strlen_buffer(t32_values.size()); + std::vector str_len_buffer(t32_values.size()); ColumnBinding binding(odbcabstraction::CDataType_TIME, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -62,7 +62,7 @@ TEST(TEST_TIME32, TIME_WITH_SECONDS) { diagnostics, nullptr)); for (size_t i = 0; i < t32_values.size(); ++i) { - ASSERT_EQ(sizeof(TIME_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(TIME_STRUCT), str_len_buffer[i]); tm time{}; @@ -86,10 +86,10 @@ TEST(TEST_TIME32, TIME_WITH_MILLI) { accessor(time32_array.get()); std::vector buffer(t32_values.size()); - std::vector strlen_buffer(t32_values.size()); + std::vector str_len_buffer(t32_values.size()); ColumnBinding binding(odbcabstraction::CDataType_TIME, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -98,12 +98,12 @@ TEST(TEST_TIME32, TIME_WITH_MILLI) { diagnostics, nullptr)); for (size_t i = 0; i < t32_values.size(); ++i) { - ASSERT_EQ(sizeof(TIME_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(TIME_STRUCT), str_len_buffer[i]); tm time{}; - auto convertedValue = t32_values[i] / odbcabstraction::MILLI_TO_SECONDS_DIVISOR; - GetTimeForSecondsSinceEpoch(convertedValue, time); + auto converted_value = t32_values[i] / odbcabstraction::MILLI_TO_SECONDS_DIVISOR; + GetTimeForSecondsSinceEpoch(converted_value, time); ASSERT_EQ(buffer[i].hour, time.tm_hour); ASSERT_EQ(buffer[i].minute, time.tm_min); @@ -125,10 +125,10 @@ TEST(TEST_TIME64, TIME_WITH_MICRO) { accessor(time64_array.get()); std::vector buffer(t64_values.size()); - std::vector strlen_buffer(t64_values.size()); + std::vector str_len_buffer(t64_values.size()); ColumnBinding binding(odbcabstraction::CDataType_TIME, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -137,7 +137,7 @@ TEST(TEST_TIME64, TIME_WITH_MICRO) { diagnostics, nullptr)); for (size_t i = 0; i < t64_values.size(); ++i) { - ASSERT_EQ(sizeof(TIME_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(TIME_STRUCT), str_len_buffer[i]); tm time{}; @@ -162,10 +162,10 @@ TEST(TEST_TIME64, TIME_WITH_NANO) { accessor(time64_array.get()); std::vector buffer(t64_values.size()); - std::vector strlen_buffer(t64_values.size()); + std::vector str_len_buffer(t64_values.size()); ColumnBinding binding(odbcabstraction::CDataType_TIME, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); int64_t value_offset = 0; odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); @@ -174,12 +174,12 @@ TEST(TEST_TIME64, TIME_WITH_NANO) { diagnostics, nullptr)); for (size_t i = 0; i < t64_values.size(); ++i) { - ASSERT_EQ(sizeof(TIME_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(TIME_STRUCT), str_len_buffer[i]); tm time{}; - const auto convertedValue = t64_values[i] / odbcabstraction::NANO_TO_SECONDS_DIVISOR; - GetTimeForSecondsSinceEpoch(convertedValue, time); + const auto converted_value = t64_values[i] / odbcabstraction::NANO_TO_SECONDS_DIVISOR; + GetTimeForSecondsSinceEpoch(converted_value, time); ASSERT_EQ(buffer[i].hour, time.tm_hour); ASSERT_EQ(buffer[i].minute, time.tm_min); diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor.cc index 68e9f64fffbae..3eb05f96a6e04 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor.cc @@ -81,7 +81,7 @@ TimestampArrayFlightSqlAccessor::TimestampArrayFlightSqlAcces TimestampArrayFlightSqlAccessor>(array) {} template -RowStatus TimestampArrayFlightSqlAccessor::MoveSingleCell_impl( +RowStatus TimestampArrayFlightSqlAccessor::MoveSingleCellImpl( ColumnBinding* binding, int64_t arrow_row, int64_t cell_counter, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) { @@ -113,16 +113,16 @@ RowStatus TimestampArrayFlightSqlAccessor::MoveSingleCell_imp buffer[cell_counter].second = timestamp.tm_sec; buffer[cell_counter].fraction = CalculateFraction(UNIT, value); - if (binding->strlen_buffer) { - binding->strlen_buffer[cell_counter] = - static_cast(GetCellLength_impl(binding)); + if (binding->str_len_buffer) { + binding->str_len_buffer[cell_counter] = + static_cast(GetCellLengthImpl(binding)); } return odbcabstraction::RowStatus_SUCCESS; } template -size_t TimestampArrayFlightSqlAccessor::GetCellLength_impl( +size_t TimestampArrayFlightSqlAccessor::GetCellLengthImpl( ColumnBinding* binding) const { return sizeof(TIMESTAMP_STRUCT); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor.h index f8e373805a8b3..ad449a6f82895 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor.h @@ -36,12 +36,12 @@ class TimestampArrayFlightSqlAccessor public: explicit TimestampArrayFlightSqlAccessor(Array* array); - RowStatus MoveSingleCell_impl(ColumnBinding* binding, int64_t arrow_row, - int64_t cell_counter, int64_t& value_offset, - bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics); + RowStatus MoveSingleCellImpl(ColumnBinding* binding, int64_t arrow_row, + int64_t cell_counter, int64_t& value_offset, + bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics); - size_t GetCellLength_impl(ColumnBinding* binding) const; + size_t GetCellLengthImpl(ColumnBinding* binding) const; }; } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor_test.cc index 930cc6a5654c2..b99d954c87019 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/timestamp_array_accessor_test.cc @@ -74,18 +74,18 @@ TEST(TEST_TIMESTAMP, TIMESTAMP_WITH_MILLI) { accessor(timestamp_array.get()); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); int64_t value_offset = 0; ColumnBinding binding(odbcabstraction::CDataType_TIMESTAMP, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); ASSERT_EQ(values.size(), accessor.GetColumnarData(&binding, 0, values.size(), value_offset, false, diagnostics, nullptr)); for (size_t i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(TIMESTAMP_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(TIMESTAMP_STRUCT), str_len_buffer[i]); ASSERT_EQ(buffer[i].year, expected[i].year); ASSERT_EQ(buffer[i].month, expected[i].month); @@ -111,11 +111,11 @@ TEST(TEST_TIMESTAMP, TIMESTAMP_WITH_SECONDS) { accessor(timestamp_array.get()); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); int64_t value_offset = 0; ColumnBinding binding(odbcabstraction::CDataType_TIMESTAMP, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); ASSERT_EQ(values.size(), @@ -123,7 +123,7 @@ TEST(TEST_TIMESTAMP, TIMESTAMP_WITH_SECONDS) { diagnostics, nullptr)); for (size_t i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(TIMESTAMP_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(TIMESTAMP_STRUCT), str_len_buffer[i]); tm date{}; auto converted_time = values[i]; @@ -152,11 +152,11 @@ TEST(TEST_TIMESTAMP, TIMESTAMP_WITH_MICRO) { accessor(timestamp_array.get()); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); int64_t value_offset = 0; ColumnBinding binding(odbcabstraction::CDataType_TIMESTAMP, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); ASSERT_EQ(values.size(), @@ -164,7 +164,7 @@ TEST(TEST_TIMESTAMP, TIMESTAMP_WITH_MICRO) { diagnostics, nullptr)); for (size_t i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(TIMESTAMP_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(TIMESTAMP_STRUCT), str_len_buffer[i]); tm date{}; @@ -196,11 +196,11 @@ TEST(TEST_TIMESTAMP, TIMESTAMP_WITH_NANO) { accessor(timestamp_array.get()); std::vector buffer(values.size()); - std::vector strlen_buffer(values.size()); + std::vector str_len_buffer(values.size()); int64_t value_offset = 0; ColumnBinding binding(odbcabstraction::CDataType_TIMESTAMP, 0, 0, buffer.data(), 0, - strlen_buffer.data()); + str_len_buffer.data()); odbcabstraction::Diagnostics diagnostics("Foo", "Foo", OdbcVersion::V_3); ASSERT_EQ(values.size(), @@ -208,7 +208,7 @@ TEST(TEST_TIMESTAMP, TIMESTAMP_WITH_NANO) { diagnostics, nullptr)); for (size_t i = 0; i < values.size(); ++i) { - ASSERT_EQ(sizeof(TIMESTAMP_STRUCT), strlen_buffer[i]); + ASSERT_EQ(sizeof(TIMESTAMP_STRUCT), str_len_buffer[i]); tm date{}; auto converted_time = values[i] / odbcabstraction::NANO_TO_SECONDS_DIVISOR; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/types.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/types.h index 2a8a1cf11e006..4e96b53aff9d1 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/types.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/accessors/types.h @@ -37,7 +37,7 @@ class FlightSqlResultSet; struct ColumnBinding { void* buffer; - ssize_t* strlen_buffer; + ssize_t* str_len_buffer; size_t buffer_length; CDataType target_type; int precision; @@ -46,13 +46,13 @@ struct ColumnBinding { ColumnBinding() = default; ColumnBinding(CDataType target_type, int precision, int scale, void* buffer, - size_t buffer_length, ssize_t* strlen_buffer) + size_t buffer_length, ssize_t* str_len_buffer) : target_type(target_type), precision(precision), scale(scale), buffer(buffer), buffer_length(buffer_length), - strlen_buffer(strlen_buffer) {} + str_len_buffer(str_len_buffer) {} }; /// \brief Accessor interface meant to provide a way of populating data of a @@ -86,31 +86,31 @@ class FlightSqlAccessor : public Accessor { int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics, uint16_t* row_status_array) override { - return static_cast(this)->GetColumnarData_impl( + return static_cast(this)->GetColumnarDataImpl( binding, starting_row, cells, value_offset, update_value_offset, diagnostics, row_status_array); } size_t GetCellLength(ColumnBinding* binding) const override { - return static_cast(this)->GetCellLength_impl(binding); + return static_cast(this)->GetCellLengthImpl(binding); } protected: - size_t GetColumnarData_impl(ColumnBinding* binding, int64_t starting_row, int64_t cells, - int64_t& value_offset, bool update_value_offset, - odbcabstraction::Diagnostics& diagnostics, - uint16_t* row_status_array) { + size_t GetColumnarDataImpl(ColumnBinding* binding, int64_t starting_row, int64_t cells, + int64_t& value_offset, bool update_value_offset, + odbcabstraction::Diagnostics& diagnostics, + uint16_t* row_status_array) { for (int64_t i = 0; i < cells; ++i) { int64_t current_arrow_row = starting_row + i; if (array_->IsNull(current_arrow_row)) { - if (binding->strlen_buffer) { - binding->strlen_buffer[i] = odbcabstraction::NULL_DATA; + if (binding->str_len_buffer) { + binding->str_len_buffer[i] = odbcabstraction::NULL_DATA; } else { throw odbcabstraction::NullWithoutIndicatorException(); } } else { // TODO: Optimize this by creating different versions of MoveSingleCell - // depending on if strlen_buffer is null. + // depending on if str_len_buffer is null. auto row_status = MoveSingleCell(binding, current_arrow_row, i, value_offset, update_value_offset, diagnostics); if (row_status_array) { @@ -131,11 +131,11 @@ class FlightSqlAccessor : public Accessor { int64_t i, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) { - return static_cast(this)->MoveSingleCell_impl( + return static_cast(this)->MoveSingleCellImpl( binding, arrow_row, i, value_offset, update_value_offset, diagnostics); } - odbcabstraction::RowStatus MoveSingleCell_impl( + odbcabstraction::RowStatus MoveSingleCellImpl( ColumnBinding* binding, int64_t arrow_row, int64_t i, int64_t& value_offset, bool update_value_offset, odbcabstraction::Diagnostics& diagnostics) { std::stringstream ss; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc index be92be057da01..2dee551915e19 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/config/configuration.cc @@ -139,15 +139,15 @@ void Configuration::LoadDsn(const std::string& dsn) { } } -void Configuration::Clear() { this->properties.clear(); } +void Configuration::Clear() { this->properties_.clear(); } bool Configuration::IsSet(const std::string_view& key) const { - return 0 != this->properties.count(key); + return 0 != this->properties_.count(key); } const std::string& Configuration::Get(const std::string_view& key) const { - const auto itr = this->properties.find(key); - if (itr == this->properties.cend()) { + const auto itr = this->properties_.find(key); + if (itr == this->properties_.cend()) { static const std::string empty(""); return empty; } @@ -157,22 +157,22 @@ const std::string& Configuration::Get(const std::string_view& key) const { void Configuration::Set(const std::string_view& key, const std::string& value) { const std::string copy = boost::trim_copy(value); if (!copy.empty()) { - this->properties[key] = value; + this->properties_[key] = value; } } const driver::odbcabstraction::Connection::ConnPropertyMap& Configuration::GetProperties() const { - return this->properties; + return this->properties_; } std::vector Configuration::GetCustomKeys() const { - driver::odbcabstraction::Connection::ConnPropertyMap copyProps(properties); + driver::odbcabstraction::Connection::ConnPropertyMap copy_props(properties_); for (auto& key : FlightSqlConnection::ALL_KEYS) { - copyProps.erase(key); + copy_props.erase(key); } std::vector keys; - boost::copy(copyProps | boost::adaptors::map_keys, std::back_inserter(keys)); + boost::copy(copy_props | boost::adaptors::map_keys, std::back_inserter(keys)); return keys; } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/config/connection_string_parser.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/config/connection_string_parser.cc index 1963ab602e98f..df218bd021b70 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/config/connection_string_parser.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/config/connection_string_parser.cc @@ -31,7 +31,7 @@ namespace driver { namespace flight_sql { namespace config { -ConnectionStringParser::ConnectionStringParser(Configuration& cfg) : cfg(cfg) { +ConnectionStringParser::ConnectionStringParser(Configuration& cfg) : cfg_(cfg) { // No-op. } @@ -73,7 +73,7 @@ void ConnectionStringParser::ParseConnectionString(const char* str, size_t len, value = value.substr(1, value.size() - 2); } - cfg.Set(key, value); + cfg_.Set(key, value); } if (!attr_begin) break; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_auth_method.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_auth_method.cc index fcf951270e622..4c9e69d07df4e 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_auth_method.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_auth_method.cc @@ -88,14 +88,15 @@ class UserPasswordAuthMethod : public FlightSqlAuthMethod { client_.AuthenticateBasicToken(auth_call_options, user_, password_); if (!bearer_result.ok()) { - const auto& flightStatus = + const auto& flight_status = arrow::flight::FlightStatusDetail::UnwrapStatus(bearer_result.status()); - if (flightStatus != nullptr) { - if (flightStatus->code() == arrow::flight::FlightStatusCode::Unauthenticated) { + if (flight_status != nullptr) { + if (flight_status->code() == arrow::flight::FlightStatusCode::Unauthenticated) { throw AuthenticationException( "Failed to authenticate with user and password: " + bearer_result.status().ToString()); - } else if (flightStatus->code() == arrow::flight::FlightStatusCode::Unavailable) { + } else if (flight_status->code() == + arrow::flight::FlightStatusCode::Unavailable) { throw CommunicationException(bearer_result.status().message()); } } @@ -134,12 +135,13 @@ class TokenAuthMethod : public FlightSqlAuthMethod { call_options, std::unique_ptr(new NoOpClientAuthHandler())); if (!status.ok()) { - const auto& flightStatus = arrow::flight::FlightStatusDetail::UnwrapStatus(status); - if (flightStatus != nullptr) { - if (flightStatus->code() == arrow::flight::FlightStatusCode::Unauthenticated) { + const auto& flight_status = arrow::flight::FlightStatusDetail::UnwrapStatus(status); + if (flight_status != nullptr) { + if (flight_status->code() == arrow::flight::FlightStatusCode::Unauthenticated) { throw AuthenticationException("Failed to authenticate with token: " + token_ + " Message: " + status.message()); - } else if (flightStatus->code() == arrow::flight::FlightStatusCode::Unavailable) { + } else if (flight_status->code() == + arrow::flight::FlightStatusCode::Unavailable) { throw CommunicationException(status.message()); } } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc index 09764e5c18ba8..4faa20e3d5c58 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.cc @@ -139,18 +139,19 @@ Connection::ConnPropertyMap::const_iterator TrackMissingRequiredProperty( } // namespace std::shared_ptr LoadFlightSslConfigs( - const Connection::ConnPropertyMap& connPropertyMap) { + const Connection::ConnPropertyMap& conn_property_map) { bool use_encryption = - AsBool(connPropertyMap, FlightSqlConnection::USE_ENCRYPTION).value_or(true); + AsBool(conn_property_map, FlightSqlConnection::USE_ENCRYPTION).value_or(true); bool disable_cert = - AsBool(connPropertyMap, FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION) + AsBool(conn_property_map, FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION) .value_or(false); bool use_system_trusted = - AsBool(connPropertyMap, FlightSqlConnection::USE_SYSTEM_TRUST_STORE) + AsBool(conn_property_map, FlightSqlConnection::USE_SYSTEM_TRUST_STORE) .value_or(SYSTEM_TRUST_STORE_DEFAULT); - auto trusted_certs_iterator = connPropertyMap.find(FlightSqlConnection::TRUSTED_CERTS); - auto trusted_certs = trusted_certs_iterator != connPropertyMap.end() + auto trusted_certs_iterator = + conn_property_map.find(FlightSqlConnection::TRUSTED_CERTS); + auto trusted_certs = trusted_certs_iterator != conn_property_map.end() ? trusted_certs_iterator->second : ""; @@ -200,9 +201,9 @@ void FlightSqlConnection::Connect(const ConnPropertyMap& properties, void FlightSqlConnection::PopulateMetadataSettings( const Connection::ConnPropertyMap& conn_property_map) { - metadata_settings_.string_column_length_ = GetStringColumnLength(conn_property_map); - metadata_settings_.use_wide_char_ = GetUseWideChar(conn_property_map); - metadata_settings_.chunk_buffer_capacity_ = GetChunkBufferCapacity(conn_property_map); + metadata_settings_.string_column_length = GetStringColumnLength(conn_property_map); + metadata_settings_.use_wide_char = GetUseWideChar(conn_property_map); + metadata_settings_.chunk_buffer_capacity = GetChunkBufferCapacity(conn_property_map); } boost::optional FlightSqlConnection::GetStringColumnLength( @@ -223,7 +224,7 @@ boost::optional FlightSqlConnection::GetStringColumnLength( return boost::none; } -bool FlightSqlConnection::GetUseWideChar(const ConnPropertyMap& connPropertyMap) { +bool FlightSqlConnection::GetUseWideChar(const ConnPropertyMap& conn_property_map) { #if defined _WIN32 || defined _WIN64 // Windows should use wide chars by default bool default_value = true; @@ -231,15 +232,15 @@ bool FlightSqlConnection::GetUseWideChar(const ConnPropertyMap& connPropertyMap) // Mac and Linux should not use wide chars by default bool default_value = false; #endif - return AsBool(connPropertyMap, FlightSqlConnection::USE_WIDE_CHAR) + return AsBool(conn_property_map, FlightSqlConnection::USE_WIDE_CHAR) .value_or(default_value); } size_t FlightSqlConnection::GetChunkBufferCapacity( - const ConnPropertyMap& connPropertyMap) { + const ConnPropertyMap& conn_property_map) { size_t default_value = 5; try { - return AsInt32(1, connPropertyMap, FlightSqlConnection::CHUNK_BUFFER_CAPACITY) + return AsInt32(1, conn_property_map, FlightSqlConnection::CHUNK_BUFFER_CAPACITY) .value_or(default_value); } catch (const std::exception& e) { diagnostics_.AddWarning( @@ -295,18 +296,18 @@ FlightClientOptions FlightSqlConnection::BuildFlightClientOptions( // Persist state information using cookies if the FlightProducer supports it. options.middleware.push_back(arrow::flight::GetCookieFactory()); - if (ssl_config->useEncryption()) { - if (ssl_config->shouldDisableCertificateVerification()) { + if (ssl_config->UseEncryption()) { + if (ssl_config->ShouldDisableCertificateVerification()) { options.disable_server_verification = - ssl_config->shouldDisableCertificateVerification(); + ssl_config->ShouldDisableCertificateVerification(); } else { - if (ssl_config->useSystemTrustStore()) { + if (ssl_config->UseSystemTrustStore()) { const std::string certs = GetCerts(); options.tls_root_certs = certs; - } else if (!ssl_config->getTrustedCerts().empty()) { + } else if (!ssl_config->GetTrustedCerts().empty()) { arrow::flight::CertKeyPair cert_key_pair; - ssl_config->populateOptionsWithCerts(&cert_key_pair); + ssl_config->PopulateOptionsWithCerts(&cert_key_pair); options.tls_root_certs = cert_key_pair.pem_cert; } } @@ -334,7 +335,7 @@ Location FlightSqlConnection::BuildLocation( const int& port = boost::lexical_cast(port_iter->second); Location location; - if (ssl_config->useEncryption()) { + if (ssl_config->UseEncryption()) { AddressInfo address_info; char host_name_info[NI_MAXHOST] = ""; bool operation_result = false; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h index 0ee6d5d539136..ad812ece569c2 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection.h @@ -33,10 +33,10 @@ class FlightSqlSslConfig; /// \brief Create an instance of the FlightSqlSslConfig class, from the properties passed /// into the map. -/// \param connPropertyMap the map with the Connection properties. -/// \return An instance of the FlightSqlSslConfig. +/// \param conn_property_map the map with the Connection properties. +/// \return An instance of the FlightSqlSslConfig. std::shared_ptr LoadFlightSslConfigs( - const odbcabstraction::Connection::ConnPropertyMap& connPropertyMap); + const odbcabstraction::Connection::ConnPropertyMap& conn_property_map); class FlightSqlConnection : public odbcabstraction::Connection { private: @@ -50,7 +50,7 @@ class FlightSqlConnection : public odbcabstraction::Connection { odbcabstraction::OdbcVersion odbc_version_; bool closed_; - void PopulateMetadataSettings(const Connection::ConnPropertyMap& connPropertyMap); + void PopulateMetadataSettings(const Connection::ConnPropertyMap& conn_property_map); public: static const std::vector ALL_KEYS; @@ -113,11 +113,12 @@ class FlightSqlConnection : public odbcabstraction::Connection { /// \note Visible for testing void SetClosed(bool is_closed); - boost::optional GetStringColumnLength(const ConnPropertyMap& connPropertyMap); + boost::optional GetStringColumnLength( + const ConnPropertyMap& conn_property_map); - bool GetUseWideChar(const ConnPropertyMap& connPropertyMap); + bool GetUseWideChar(const ConnPropertyMap& conn_property_map); - size_t GetChunkBufferCapacity(const ConnPropertyMap& connPropertyMap); + size_t GetChunkBufferCapacity(const ConnPropertyMap& conn_property_map); }; } // namespace flight_sql } // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection_test.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection_test.cc index 6a519138b637e..46d878e6925c3 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection_test.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_connection_test.cc @@ -32,20 +32,20 @@ TEST(AttributeTests, SetAndGetAttribute) { connection.SetClosed(false); connection.SetAttribute(Connection::CONNECTION_TIMEOUT, static_cast(200)); - const boost::optional firstValue = + const boost::optional first_value = connection.GetAttribute(Connection::CONNECTION_TIMEOUT); - EXPECT_TRUE(firstValue); + EXPECT_TRUE(first_value); - EXPECT_EQ(boost::get(*firstValue), static_cast(200)); + EXPECT_EQ(boost::get(*first_value), static_cast(200)); connection.SetAttribute(Connection::CONNECTION_TIMEOUT, static_cast(300)); - const boost::optional changeValue = + const boost::optional change_value = connection.GetAttribute(Connection::CONNECTION_TIMEOUT); - EXPECT_TRUE(changeValue); - EXPECT_EQ(boost::get(*changeValue), static_cast(300)); + EXPECT_TRUE(change_value); + EXPECT_EQ(boost::get(*change_value), static_cast(300)); connection.Close(); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set.cc index 824260a686875..971d73b3a9073 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set.cc @@ -49,7 +49,7 @@ FlightSqlResultSet::FlightSqlResultSet( const odbcabstraction::MetadataSettings& metadata_settings) : metadata_settings_(metadata_settings), chunk_buffer_(flight_sql_client, call_options, flight_info, - metadata_settings_.chunk_buffer_capacity_), + metadata_settings_.chunk_buffer_capacity), transformer_(transformer), metadata_(transformer ? new FlightSqlResultSetMetadata(transformer->GetTransformedSchema(), @@ -69,7 +69,7 @@ FlightSqlResultSet::FlightSqlResultSet( } for (size_t i = 0; i < columns_.size(); ++i) { - columns_[i] = FlightSqlResultSetColumn(metadata_settings.use_wide_char_); + columns_[i] = FlightSqlResultSetColumn(metadata_settings.use_wide_char); } } @@ -121,10 +121,10 @@ size_t FlightSqlResultSet::Move(size_t rows, size_t bind_offset, size_t bind_typ for (auto& column : columns_) { // There can be unbound columns. - if (!column.is_bound_) continue; + if (!column.is_bound) continue; auto* accessor = column.GetAccessorForBinding(); - ColumnBinding shifted_binding = column.binding_; + ColumnBinding shifted_binding = column.binding; uint16_t* shifted_row_status_array = row_status_array ? &row_status_array[fetched_rows] : nullptr; @@ -143,9 +143,10 @@ size_t FlightSqlResultSet::Move(size_t rows, size_t bind_offset, size_t bind_typ accessor->GetCellLength(&shifted_binding) * fetched_rows + bind_offset; } - if (shifted_binding.strlen_buffer) { - shifted_binding.strlen_buffer = reinterpret_cast( - reinterpret_cast(&shifted_binding.strlen_buffer[fetched_rows]) + + if (shifted_binding.str_len_buffer) { + shifted_binding.str_len_buffer = reinterpret_cast( + reinterpret_cast( + &shifted_binding.str_len_buffer[fetched_rows]) + bind_offset); } @@ -162,9 +163,9 @@ size_t FlightSqlResultSet::Move(size_t rows, size_t bind_offset, size_t bind_typ bind_offset + bind_type * fetched_rows; } - if (shifted_binding.strlen_buffer) { - shifted_binding.strlen_buffer = reinterpret_cast( - reinterpret_cast(shifted_binding.strlen_buffer) + bind_offset + + if (shifted_binding.str_len_buffer) { + shifted_binding.str_len_buffer = reinterpret_cast( + reinterpret_cast(shifted_binding.str_len_buffer) + bind_offset + bind_type * fetched_rows); } @@ -182,9 +183,9 @@ size_t FlightSqlResultSet::Move(size_t rows, size_t bind_offset, size_t bind_typ static_cast(shifted_binding.buffer) + bind_type; } - if (shifted_binding.strlen_buffer) { - shifted_binding.strlen_buffer = reinterpret_cast( - reinterpret_cast(shifted_binding.strlen_buffer) + bind_type); + if (shifted_binding.str_len_buffer) { + shifted_binding.str_len_buffer = reinterpret_cast( + reinterpret_cast(shifted_binding.str_len_buffer) + bind_type); } if (shifted_row_status_array) { @@ -228,7 +229,7 @@ void FlightSqlResultSet::Cancel() { bool FlightSqlResultSet::GetData(int column_n, int16_t target_type, int precision, int scale, void* buffer, size_t buffer_length, - ssize_t* strlen_buffer) { + ssize_t* str_len_buffer) { reset_get_data_ = true; // Check if the offset is already at the end. int64_t& value_offset = get_data_offsets_[column_n - 1]; @@ -237,7 +238,7 @@ bool FlightSqlResultSet::GetData(int column_n, int16_t target_type, int precisio } ColumnBinding binding(ConvertCDataTypeFromV2ToV3(target_type), precision, scale, buffer, - buffer_length, strlen_buffer); + buffer_length, str_len_buffer); auto& column = columns_[column_n - 1]; Accessor* accessor = column.GetAccessorForGetData(binding.target_type); @@ -256,22 +257,22 @@ std::shared_ptr FlightSqlResultSet::GetMetadata() { return me void FlightSqlResultSet::BindColumn(int column_n, int16_t target_type, int precision, int scale, void* buffer, size_t buffer_length, - ssize_t* strlen_buffer) { + ssize_t* str_len_buffer) { auto& column = columns_[column_n - 1]; if (buffer == nullptr) { - if (column.is_bound_) { + if (column.is_bound) { num_binding_--; } column.ResetBinding(); return; } - if (!column.is_bound_) { + if (!column.is_bound) { num_binding_++; } ColumnBinding binding(ConvertCDataTypeFromV2ToV3(target_type), precision, scale, buffer, - buffer_length, strlen_buffer); + buffer_length, str_len_buffer); column.SetBinding(binding, schema_->field(column_n - 1)->type()->id()); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set.h index d1f20979a2404..db86bd4c4b6b4 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set.h @@ -74,7 +74,7 @@ class FlightSqlResultSet : public ResultSet { void Cancel() override; bool GetData(int column_n, int16_t target_type, int precision, int scale, void* buffer, - size_t buffer_length, ssize_t* strlen_buffer) override; + size_t buffer_length, ssize_t* str_len_buffer) override; size_t Move(size_t rows, size_t bind_offset, size_t bind_type, uint16_t* row_status_array) override; @@ -82,7 +82,7 @@ class FlightSqlResultSet : public ResultSet { std::shared_ptr GetMetadata() override; void BindColumn(int column_n, int16_t target_type, int precision, int scale, - void* buffer, size_t buffer_length, ssize_t* strlen_buffer) override; + void* buffer, size_t buffer_length, ssize_t* str_len_buffer) override; }; } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_column.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_column.cc index 3f3fa3ac5a4ca..2a5d116b1e497 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_column.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_column.cc @@ -50,7 +50,7 @@ std::unique_ptr FlightSqlResultSetColumn::CreateAccessor( Accessor* FlightSqlResultSetColumn::GetAccessorForTargetType(CDataType target_type) { // Cast the original array to a type matching the target_type. if (target_type == odbcabstraction::CDataType_DEFAULT) { - target_type = ConvertArrowTypeToC(original_array_->type_id(), use_wide_char_); + target_type = ConvertArrowTypeToC(original_array_->type_id(), use_wide_char); } cached_accessor_ = CreateAccessor(target_type); @@ -58,33 +58,33 @@ Accessor* FlightSqlResultSetColumn::GetAccessorForTargetType(CDataType target_ty } FlightSqlResultSetColumn::FlightSqlResultSetColumn(bool use_wide_char) - : use_wide_char_(use_wide_char), is_bound_(false) {} + : use_wide_char(use_wide_char), is_bound(false) {} void FlightSqlResultSetColumn::SetBinding(const ColumnBinding& new_binding, arrow::Type::type arrow_type) { - binding_ = new_binding; - is_bound_ = true; + binding = new_binding; + is_bound = true; - if (binding_.target_type == odbcabstraction::CDataType_DEFAULT) { - binding_.target_type = ConvertArrowTypeToC(arrow_type, use_wide_char_); + if (binding.target_type == odbcabstraction::CDataType_DEFAULT) { + binding.target_type = ConvertArrowTypeToC(arrow_type, use_wide_char); } // Overwrite the binding if the caller is using SQL_C_NUMERIC and has used zero // precision if it is zero (this is precision unset and will always fail). - if (binding_.precision == 0 && - binding_.target_type == odbcabstraction::CDataType_NUMERIC) { - binding_.precision = arrow::Decimal128Type::kMaxPrecision; + if (binding.precision == 0 && + binding.target_type == odbcabstraction::CDataType_NUMERIC) { + binding.precision = arrow::Decimal128Type::kMaxPrecision; } // Rebuild the accessor and casted array if the target type changed. if (original_array_ && - (!cached_casted_array_ || cached_accessor_->target_type_ != binding_.target_type)) { - cached_accessor_ = CreateAccessor(binding_.target_type); + (!cached_casted_array_ || cached_accessor_->target_type_ != binding.target_type)) { + cached_accessor_ = CreateAccessor(binding.target_type); } } void FlightSqlResultSetColumn::ResetBinding() { - is_bound_ = false; + is_bound = false; cached_casted_array_.reset(); cached_accessor_.reset(); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_column.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_column.h index 1b487044cf965..e530c17efbaed 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_column.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_column.h @@ -40,15 +40,15 @@ class FlightSqlResultSetColumn { FlightSqlResultSetColumn() = default; explicit FlightSqlResultSetColumn(bool use_wide_char); - ColumnBinding binding_; - bool use_wide_char_; - bool is_bound_; + ColumnBinding binding; + bool use_wide_char; + bool is_bound; inline Accessor* GetAccessorForBinding() { return cached_accessor_.get(); } inline Accessor* GetAccessorForGetData(CDataType target_type) { if (target_type == odbcabstraction::CDataType_DEFAULT) { - target_type = ConvertArrowTypeToC(original_array_->type_id(), use_wide_char_); + target_type = ConvertArrowTypeToC(original_array_->type_id(), use_wide_char); } if (cached_accessor_ && cached_accessor_->target_type_ == target_type) { @@ -65,8 +65,8 @@ class FlightSqlResultSetColumn { original_array_ = std::move(array); if (cached_accessor_) { cached_accessor_ = CreateAccessor(cached_accessor_->target_type_); - } else if (is_bound_) { - cached_accessor_ = CreateAccessor(binding_.target_type); + } else if (is_bound) { + cached_accessor_ = CreateAccessor(binding.target_type); } else { cached_casted_array_.reset(); cached_accessor_.reset(); diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.cc index f863d4bc4894e..38b1410b6ac19 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_result_set_metadata.cc @@ -74,7 +74,7 @@ size_t FlightSqlResultSetMetadata::GetPrecision(int column_position) { int32_t column_size = GetFieldPrecision(field).ValueOrElse([] { return 0; }); SqlDataType data_type_v3 = - GetDataTypeFromArrowField_V3(field, metadata_settings_.use_wide_char_); + GetDataTypeFromArrowFieldV3(field, metadata_settings_.use_wide_char); return GetColumnSize(data_type_v3, column_size).value_or(0); } @@ -85,16 +85,16 @@ size_t FlightSqlResultSetMetadata::GetScale(int column_position) { int32_t type_scale = metadata.GetScale().ValueOrElse([] { return 0; }); SqlDataType data_type_v3 = - GetDataTypeFromArrowField_V3(field, metadata_settings_.use_wide_char_); + GetDataTypeFromArrowFieldV3(field, metadata_settings_.use_wide_char); return GetTypeScale(data_type_v3, type_scale).value_or(0); } uint16_t FlightSqlResultSetMetadata::GetDataType(int column_position) { const std::shared_ptr& field = schema_->field(column_position - 1); - const SqlDataType conciseType = - GetDataTypeFromArrowField_V3(field, metadata_settings_.use_wide_char_); - return GetNonConciseDataType(conciseType); + const SqlDataType concise_type = + GetDataTypeFromArrowFieldV3(field, metadata_settings_.use_wide_char); + return GetNonConciseDataType(concise_type); } driver::odbcabstraction::Nullability FlightSqlResultSetMetadata::IsNullable( @@ -132,10 +132,10 @@ std::string FlightSqlResultSetMetadata::GetColumnLabel(int column_position) { size_t FlightSqlResultSetMetadata::GetColumnDisplaySize(int column_position) { const std::shared_ptr& field = schema_->field(column_position - 1); - int32_t column_size = metadata_settings_.string_column_length_.value_or( + int32_t column_size = metadata_settings_.string_column_length.value_or( GetFieldPrecision(field).ValueOr(DefaultLengthForVariableLengthColumns)); SqlDataType data_type_v3 = - GetDataTypeFromArrowField_V3(field, metadata_settings_.use_wide_char_); + GetDataTypeFromArrowFieldV3(field, metadata_settings_.use_wide_char); return GetDisplaySize(data_type_v3, column_size).value_or(odbcabstraction::NO_TOTAL); } @@ -154,17 +154,17 @@ uint16_t FlightSqlResultSetMetadata::GetConciseType(int column_position) { const std::shared_ptr& field = schema_->field(column_position - 1); const SqlDataType sqlColumnType = - GetDataTypeFromArrowField_V3(field, metadata_settings_.use_wide_char_); + GetDataTypeFromArrowFieldV3(field, metadata_settings_.use_wide_char); return sqlColumnType; } size_t FlightSqlResultSetMetadata::GetLength(int column_position) { const std::shared_ptr& field = schema_->field(column_position - 1); - int32_t column_size = metadata_settings_.string_column_length_.value_or( + int32_t column_size = metadata_settings_.string_column_length.value_or( GetFieldPrecision(field).ValueOr(DefaultLengthForVariableLengthColumns)); SqlDataType data_type_v3 = - GetDataTypeFromArrowField_V3(field, metadata_settings_.use_wide_char_); + GetDataTypeFromArrowFieldV3(field, metadata_settings_.use_wide_char); return flight_sql::GetLength(data_type_v3, column_size) .value_or(DefaultLengthForVariableLengthColumns); @@ -191,7 +191,7 @@ std::string FlightSqlResultSetMetadata::GetLocalTypeName(int column_position) { size_t FlightSqlResultSetMetadata::GetNumPrecRadix(int column_position) { const std::shared_ptr& field = schema_->field(column_position - 1); SqlDataType data_type_v3 = - GetDataTypeFromArrowField_V3(field, metadata_settings_.use_wide_char_); + GetDataTypeFromArrowFieldV3(field, metadata_settings_.use_wide_char); return GetRadixFromSqlDataType(data_type_v3).value_or(odbcabstraction::NO_TOTAL); } @@ -200,10 +200,10 @@ size_t FlightSqlResultSetMetadata::GetOctetLength(int column_position) { const std::shared_ptr& field = schema_->field(column_position - 1); arrow::flight::sql::ColumnMetadata metadata = GetMetadata(field); - int32_t column_size = metadata_settings_.string_column_length_.value_or( + int32_t column_size = metadata_settings_.string_column_length.value_or( GetFieldPrecision(field).ValueOr(DefaultLengthForVariableLengthColumns)); SqlDataType data_type_v3 = - GetDataTypeFromArrowField_V3(field, metadata_settings_.use_wide_char_); + GetDataTypeFromArrowFieldV3(field, metadata_settings_.use_wide_char); // Workaround to get the precision for Decimal and Numeric types, since server doesn't // return it currently. diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.cc index b0f23b31deae3..9becf0e6f1f56 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.cc @@ -24,30 +24,30 @@ namespace driver { namespace flight_sql { -FlightSqlSslConfig::FlightSqlSslConfig(bool disableCertificateVerification, - const std::string& trustedCerts, - bool systemTrustStore, bool useEncryption) - : trustedCerts_(trustedCerts), - useEncryption_(useEncryption), - disableCertificateVerification_(disableCertificateVerification), - systemTrustStore_(systemTrustStore) {} - -bool FlightSqlSslConfig::useEncryption() const { return useEncryption_; } - -bool FlightSqlSslConfig::shouldDisableCertificateVerification() const { - return disableCertificateVerification_; +FlightSqlSslConfig::FlightSqlSslConfig(bool disable_certificate_verification, + const std::string& trusted_certs, + bool system_trust_store, bool use_encryption) + : trusted_certs_(trusted_certs), + use_encryption_(use_encryption), + disable_certificate_verification_(disable_certificate_verification), + system_trust_store_(system_trust_store) {} + +bool FlightSqlSslConfig::UseEncryption() const { return use_encryption_; } + +bool FlightSqlSslConfig::ShouldDisableCertificateVerification() const { + return disable_certificate_verification_; } -const std::string& FlightSqlSslConfig::getTrustedCerts() const { return trustedCerts_; } +const std::string& FlightSqlSslConfig::GetTrustedCerts() const { return trusted_certs_; } -bool FlightSqlSslConfig::useSystemTrustStore() const { return systemTrustStore_; } +bool FlightSqlSslConfig::UseSystemTrustStore() const { return system_trust_store_; } -void FlightSqlSslConfig::populateOptionsWithCerts(arrow::flight::CertKeyPair* out) { +void FlightSqlSslConfig::PopulateOptionsWithCerts(arrow::flight::CertKeyPair* out) { try { - std::ifstream cert_file(trustedCerts_); + std::ifstream cert_file(trusted_certs_); if (!cert_file) { throw odbcabstraction::DriverException("Could not open certificate: " + - trustedCerts_); + trusted_certs_); } std::stringstream cert; cert << cert_file.rdbuf(); diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.h index 76a54f13ce124..bf1c3c9cbbacb 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_ssl_config.h @@ -28,35 +28,36 @@ namespace flight_sql { /// a SSL connection. class FlightSqlSslConfig { public: - FlightSqlSslConfig(bool disableCertificateVerification, const std::string& trustedCerts, - bool systemTrustStore, bool useEncryption); + FlightSqlSslConfig(bool disable_certificate_verification, + const std::string& trusted_certs, bool system_trust_store, + bool use_encryption); /// \brief Tells if ssl is enabled. By default it will be true. /// \return Whether ssl is enabled. - bool useEncryption() const; + bool UseEncryption() const; /// \brief Tells if disable certificate verification is enabled. /// \return Whether disable certificate verification is enabled. - bool shouldDisableCertificateVerification() const; + bool ShouldDisableCertificateVerification() const; /// \brief The path to the trusted certificate. /// \return Certificate path. - const std::string& getTrustedCerts() const; + const std::string& GetTrustedCerts() const; /// \brief Tells if we need to check if the certificate is in the system trust store. /// \return Whether to use the system trust store. - bool useSystemTrustStore() const; + bool UseSystemTrustStore() const; /// \brief Loads the certificate file and extract the certificate file from it /// and create the object CertKeyPair with it on. /// \param out A CertKeyPair with the cert on it. - void populateOptionsWithCerts(arrow::flight::CertKeyPair* out); + void PopulateOptionsWithCerts(arrow::flight::CertKeyPair* out); private: - const std::string trustedCerts_; - const bool useEncryption_; - const bool disableCertificateVerification_; - const bool systemTrustStore_; + const std::string trusted_certs_; + const bool use_encryption_; + const bool disable_certificate_verification_; + const bool system_trust_store_; }; } // namespace flight_sql } // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement.cc index 1e8498ad7e351..137594b68d683 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement.cc @@ -257,7 +257,7 @@ std::shared_ptr FlightSqlStatement::GetTypeInfo_V2(int16_t data_type) auto flight_info = result.ValueOrDie(); - auto transformer = std::make_shared( + auto transformer = std::make_shared( metadata_settings_, odbcabstraction::V_2, data_type); current_result_set_ = @@ -275,7 +275,7 @@ std::shared_ptr FlightSqlStatement::GetTypeInfo_V3(int16_t data_type) auto flight_info = result.ValueOrDie(); - auto transformer = std::make_shared( + auto transformer = std::make_shared( metadata_settings_, odbcabstraction::V_3, data_type); current_result_set_ = diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_columns.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_columns.cc index 0e250d1af9bef..56a21c04af3dd 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_columns.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_columns.cc @@ -78,7 +78,7 @@ std::shared_ptr GetColumns_V2_Schema() { }); } -Result> Transform_inner( +Result> TransformInner( const odbcabstraction::OdbcVersion odbc_version, const std::shared_ptr& original, const optional& column_name_pattern, @@ -113,7 +113,7 @@ Result> Transform_inner( } odbcabstraction::SqlDataType data_type_v3 = - GetDataTypeFromArrowField_V3(field, metadata_settings.use_wide_char_); + GetDataTypeFromArrowFieldV3(field, metadata_settings.use_wide_char); ColumnMetadata metadata(field->metadata()); @@ -233,7 +233,7 @@ GetColumns_Transformer::GetColumns_Transformer( std::shared_ptr GetColumns_Transformer::Transform( const std::shared_ptr& original) { const Result>& result = - Transform_inner(odbc_version_, original, column_name_pattern_, metadata_settings_); + TransformInner(odbc_version_, original, column_name_pattern_, metadata_settings_); ThrowIfNotOK(result.status()); return result.ValueOrDie(); diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_type_info.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_type_info.cc index 3faf607c5f2c2..eddba5a08c25c 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_type_info.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_type_info.cc @@ -78,19 +78,19 @@ std::shared_ptr GetTypeInfo_V2_Schema() { }); } -Result> Transform_inner( +Result> TransformInner( const odbcabstraction::OdbcVersion odbc_version, const std::shared_ptr& original, int data_type, const MetadataSettings& metadata_settings_) { - GetTypeInfo_RecordBatchBuilder builder(odbc_version); - GetTypeInfo_RecordBatchBuilder::Data data; + GetTypeInfoRecordBatchBuilder builder(odbc_version); + GetTypeInfoRecordBatchBuilder::Data data; GetTypeInfoReader reader(original); while (reader.Next()) { auto data_type_v3 = EnsureRightSqlCharType( static_cast(reader.GetDataType()), - metadata_settings_.use_wide_char_); + metadata_settings_.use_wide_char); int16_t data_type_v2 = ConvertSqlDataTypeFromV3ToV2(data_type_v3); if (data_type != odbcabstraction::ALL_TYPES && data_type_v3 != data_type && @@ -124,7 +124,7 @@ Result> Transform_inner( data.maximum_scale = reader.GetMaximumScale(); data.sql_data_type = EnsureRightSqlCharType( static_cast(reader.GetSqlDataType()), - metadata_settings_.use_wide_char_); + metadata_settings_.use_wide_char); data.sql_datetime_sub = GetSqlDateTimeSubCode(static_cast(data.data_type)); data.num_prec_radix = reader.GetNumPrecRadix(); @@ -137,11 +137,11 @@ Result> Transform_inner( } } // namespace -GetTypeInfo_RecordBatchBuilder::GetTypeInfo_RecordBatchBuilder( +GetTypeInfoRecordBatchBuilder::GetTypeInfoRecordBatchBuilder( odbcabstraction::OdbcVersion odbc_version) : odbc_version_(odbc_version) {} -Result> GetTypeInfo_RecordBatchBuilder::Build() { +Result> GetTypeInfoRecordBatchBuilder::Build() { ARROW_ASSIGN_OR_RAISE(auto TYPE_NAME_Array, TYPE_NAME_Builder_.Finish()) ARROW_ASSIGN_OR_RAISE(auto DATA_TYPE_Array, DATA_TYPE_Builder_.Finish()) ARROW_ASSIGN_OR_RAISE(auto COLUMN_SIZE_Array, COLUMN_SIZE_Builder_.Finish()) @@ -179,8 +179,8 @@ Result> GetTypeInfo_RecordBatchBuilder::Build() { return RecordBatch::Make(schema, num_rows_, arrays); } -Status GetTypeInfo_RecordBatchBuilder::Append( - const GetTypeInfo_RecordBatchBuilder::Data& data) { +Status GetTypeInfoRecordBatchBuilder::Append( + const GetTypeInfoRecordBatchBuilder::Data& data) { ARROW_RETURN_NOT_OK(AppendToBuilder(TYPE_NAME_Builder_, data.type_name)); ARROW_RETURN_NOT_OK(AppendToBuilder(DATA_TYPE_Builder_, data.data_type)); ARROW_RETURN_NOT_OK(AppendToBuilder(COLUMN_SIZE_Builder_, data.column_size)); @@ -208,23 +208,23 @@ Status GetTypeInfo_RecordBatchBuilder::Append( return Status::OK(); } -GetTypeInfo_Transformer::GetTypeInfo_Transformer( +GetTypeInfoTransformer::GetTypeInfoTransformer( const MetadataSettings& metadata_settings, const odbcabstraction::OdbcVersion odbc_version, int data_type) : metadata_settings_(metadata_settings), odbc_version_(odbc_version), data_type_(data_type) {} -std::shared_ptr GetTypeInfo_Transformer::Transform( +std::shared_ptr GetTypeInfoTransformer::Transform( const std::shared_ptr& original) { const Result>& result = - Transform_inner(odbc_version_, original, data_type_, metadata_settings_); + TransformInner(odbc_version_, original, data_type_, metadata_settings_); ThrowIfNotOK(result.status()); return result.ValueOrDie(); } -std::shared_ptr GetTypeInfo_Transformer::GetTransformedSchema() { +std::shared_ptr GetTypeInfoTransformer::GetTransformedSchema() { return odbc_version_ == odbcabstraction::V_3 ? GetTypeInfo_V3_Schema() : GetTypeInfo_V2_Schema(); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_type_info.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_type_info.h index 556341fc000c5..f212a6598871d 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_type_info.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_statement_get_type_info.h @@ -34,7 +34,7 @@ using arrow::StringBuilder; using odbcabstraction::MetadataSettings; using std::optional; -class GetTypeInfo_RecordBatchBuilder { +class GetTypeInfoRecordBatchBuilder { private: odbcabstraction::OdbcVersion odbc_version_; @@ -82,23 +82,23 @@ class GetTypeInfo_RecordBatchBuilder { optional interval_precision; }; - explicit GetTypeInfo_RecordBatchBuilder(odbcabstraction::OdbcVersion odbc_version); + explicit GetTypeInfoRecordBatchBuilder(odbcabstraction::OdbcVersion odbc_version); Result> Build(); Status Append(const Data& data); }; -class GetTypeInfo_Transformer : public RecordBatchTransformer { +class GetTypeInfoTransformer : public RecordBatchTransformer { private: const MetadataSettings& metadata_settings_; odbcabstraction::OdbcVersion odbc_version_; int data_type_; public: - explicit GetTypeInfo_Transformer(const MetadataSettings& metadata_settings, - odbcabstraction::OdbcVersion odbc_version, - int data_type); + explicit GetTypeInfoTransformer(const MetadataSettings& metadata_settings, + odbcabstraction::OdbcVersion odbc_version, + int data_type); std::shared_ptr Transform( const std::shared_ptr& original) override; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_stream_chunk_buffer.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_stream_chunk_buffer.cc index 093a46dfe8384..b0c93db2ddcc6 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_stream_chunk_buffer.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/flight_sql_stream_chunk_buffer.cc @@ -38,10 +38,10 @@ FlightStreamChunkBuffer::FlightStreamChunkBuffer( BlockingQueue>::Supplier supplier = [=] { auto result = stream_reader_ptr->Next(); - bool isNotOk = !result.ok(); - bool isNotEmpty = result.ok() && (result.ValueOrDie().data != nullptr); + bool is_not_ok = !result.ok(); + bool is_not_empty = result.ok() && (result.ValueOrDie().data != nullptr); - return boost::make_optional(isNotOk || isNotEmpty, std::move(result)); + return boost::make_optional(is_not_ok || is_not_empty, std::move(result)); }; queue_.AddProducer(std::move(supplier)); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h index 69fa8a8696c5e..ead39976d43fb 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/configuration.h @@ -69,7 +69,7 @@ class Configuration { std::vector GetCustomKeys() const; private: - driver::odbcabstraction::Connection::ConnPropertyMap properties; + driver::odbcabstraction::Connection::ConnPropertyMap properties_; }; } // namespace config diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/connection_string_parser.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/connection_string_parser.h index 7e805e9d2045e..45494c743906d 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/connection_string_parser.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/config/connection_string_parser.h @@ -70,7 +70,7 @@ class ConnectionStringParser { ConnectionStringParser& operator=(const ConnectionStringParser&) = delete; /** Configuration. */ - Configuration& cfg; + Configuration& cfg_; }; } // namespace config diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h index 01d93829a46b8..6f87f71621019 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/add_property_window.h @@ -63,7 +63,7 @@ class AddPropertyWindow : public CustomWindow { void OnCreate() override; - bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) override; + bool OnMessage(UINT msg, WPARAM wparam, LPARAM lparam) override; /** * Get the property from the dialog. @@ -76,41 +76,41 @@ class AddPropertyWindow : public CustomWindow { /** * Create property edit boxes. * - * @param posX X position. - * @param posY Y position. - * @param sizeX Width. + * @param pos_x X position. + * @param pos_y Y position. + * @param size_x Width. * @return Size by Y. */ - int CreateEdits(int posX, int posY, int sizeX); + int CreateEdits(int pos_x, int pos_y, int size_x); void CheckEnableOk(); - std::vector > labels; + std::vector > labels_; /** Ok button. */ - std::unique_ptr okButton; + std::unique_ptr ok_button_; /** Cancel button. */ - std::unique_ptr cancelButton; + std::unique_ptr cancel_button_; - std::unique_ptr keyEdit; + std::unique_ptr key_edit_; - std::unique_ptr valueEdit; + std::unique_ptr value_edit_; - std::string key; + std::string key_; - std::string value; + std::string value_; /** Window width. */ - int width; + int width_; /** Window height. */ - int height; + int height_; /** Flag indicating whether OK option was selected. */ - bool accepted; + bool accepted_; - bool isInitialized; + bool is_initialized_; }; } // namespace config diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/custom_window.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/custom_window.h index 0fc3737ed8bc0..f9651d5cca49c 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/custom_window.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/custom_window.h @@ -62,10 +62,10 @@ class CustomWindow : public Window { * Constructor. * * @param parent Parent window. - * @param className Window class name. + * @param class_name Window class name. * @param title Window title. */ - CustomWindow(Window* parent, const char* className, const char* title); + CustomWindow(Window* parent, const char* class_name, const char* title); /** * Destructor. @@ -77,12 +77,12 @@ class CustomWindow : public Window { * Pure virtual. Should be defined by user. * * @param msg Message. - * @param wParam Word-sized parameter. - * @param lParam Long parameter. + * @param wparam Word-sized parameter. + * @param lparam Long parameter. * @return Should return true if the message has been * processed by the handler and false otherwise. */ - virtual bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) = 0; + virtual bool OnMessage(UINT msg, WPARAM wparam, LPARAM lparam) = 0; /** * Callback that is called upon window creation. @@ -97,11 +97,11 @@ class CustomWindow : public Window { * * @param hwnd Window handle. * @param msg Message. - * @param wParam Word-sized parameter. - * @param lParam Long parameter. + * @param wparam Word-sized parameter. + * @param lparam Long parameter. * @return Operation result. */ - static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam); + static LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam); }; } // namespace config diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/dsn_configuration_window.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/dsn_configuration_window.h index d32e7a6932d7d..daa962ddb2a21 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/dsn_configuration_window.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/dsn_configuration_window.h @@ -90,131 +90,127 @@ class DsnConfigurationWindow : public CustomWindow { void OnCreate() override; - bool OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) override; + bool OnMessage(UINT msg, WPARAM wparam, LPARAM lparam) override; private: /** * Create connection settings group box. * - * @param posX X position. - * @param posY Y position. - * @param sizeX Width. + * @param pos_x X position. + * @param pos_y Y position. + * @param size_x Width. * @return Size by Y. */ - int CreateConnectionSettingsGroup(int posX, int posY, int sizeX); + int CreateConnectionSettingsGroup(int pos_x, int pos_y, int size_x); /** * Create aythentication settings group box. * - * @param posX X position. - * @param posY Y position. - * @param sizeX Width. + * @param pos_x X position. + * @param pos_y Y position. + * @param size_x Width. * @return Size by Y. */ - int CreateAuthSettingsGroup(int posX, int posY, int sizeX); + int CreateAuthSettingsGroup(int pos_x, int pos_y, int size_x); /** * Create Encryption settings group box. * - * @param posX X position. - * @param posY Y position. - * @param sizeX Width. + * @param pos_x X position. + * @param pos_y Y position. + * @param size_x Width. * @return Size by Y. */ - int CreateEncryptionSettingsGroup(int posX, int posY, int sizeX); + int CreateEncryptionSettingsGroup(int pos_x, int pos_y, int size_x); /** * Create advanced properties group box. * - * @param posX X position. - * @param posY Y position. - * @param sizeX Width. + * @param pos_x X position. + * @param pos_y Y position. + * @param size_x Width. * @return Size by Y. */ - int CreatePropertiesGroup(int posX, int posY, int sizeX); + int CreatePropertiesGroup(int pos_x, int pos_y, int size_x); - void SelectTab(int tabIndex); + void SelectTab(int tab_index); void CheckEnableOk(); void CheckAuthType(); - void SaveParameters(Configuration& targetConfig); + void SaveParameters(Configuration& target_config); /** Window width. */ - int width; + int width_; /** Window height. */ - int height; + int height_; - std::unique_ptr tabControl; - - std::unique_ptr commonContent; - - std::unique_ptr advancedContent; + std::unique_ptr tab_control_; /** Connection settings group box. */ - std::unique_ptr connectionSettingsGroupBox; + std::unique_ptr connection_settings_group_box_; /** Authentication settings group box. */ - std::unique_ptr authSettingsGroupBox; + std::unique_ptr auth_settings_group_box_; /** Encryption settings group box. */ - std::unique_ptr encryptionSettingsGroupBox; + std::unique_ptr encryption_settings_group_box_; - std::vector > labels; + std::vector > labels_; /** Test button. */ - std::unique_ptr testButton; + std::unique_ptr test_button_; /** Ok button. */ - std::unique_ptr okButton; + std::unique_ptr ok_button_; /** Cancel button. */ - std::unique_ptr cancelButton; + std::unique_ptr cancel_button_; /** DSN name edit field. */ - std::unique_ptr nameEdit; + std::unique_ptr name_edit_; - std::unique_ptr serverEdit; + std::unique_ptr server_edit_; - std::unique_ptr portEdit; + std::unique_ptr port_edit_; - std::unique_ptr authTypeComboBox; + std::unique_ptr auth_type_combo_box_; /** User edit. */ - std::unique_ptr userEdit; + std::unique_ptr user_edit_; /** Password edit. */ - std::unique_ptr passwordEdit; + std::unique_ptr password_edit_; - std::unique_ptr authTokenEdit; + std::unique_ptr auth_token_edit_; - std::unique_ptr enableEncryptionCheckBox; + std::unique_ptr enable_encryption_check_box_; - std::unique_ptr certificateEdit; + std::unique_ptr certificate_edit_; - std::unique_ptr certificateBrowseButton; + std::unique_ptr certificate_browse_button_; - std::unique_ptr useSystemCertStoreCheckBox; + std::unique_ptr use_system_cert_store_check_box_; - std::unique_ptr disableCertVerificationCheckBox; + std::unique_ptr disable_cert_verification_check_box_; - std::unique_ptr propertyGroupBox; + std::unique_ptr property_group_box_; - std::unique_ptr propertyList; + std::unique_ptr property_list_; - std::unique_ptr addButton; + std::unique_ptr add_button_; - std::unique_ptr deleteButton; + std::unique_ptr delete_button_; /** Configuration. */ - Configuration& config; + Configuration& config_; /** Flag indicating whether OK option was selected. */ - bool accepted; + bool accepted_; - bool isInitialized; + bool is_initialized_; }; } // namespace config diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h index e56ad88dec656..8ac8dd7934aa9 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/include/flight_sql/ui/window.h @@ -41,10 +41,10 @@ class Window { * Constructor for a new window that is going to be created. * * @param parent Parent window handle. - * @param className Window class name. + * @param class_name Window class name. * @param title Window title. */ - Window(Window* parent, const char* className, const char* title); + Window(Window* parent, const char* class_name, const char* title); /** * Constructor for the existing window. @@ -62,13 +62,13 @@ class Window { * Create window. * * @param style Window style. - * @param posX Window x position. - * @param posY Window y position. + * @param pos_x Window x position. + * @param pos_y Window y position. * @param width Window width. * @param height Window height. * @param id ID for child window. */ - void Create(DWORD style, int posX, int posY, int width, int height, int id); + void Create(DWORD style, int pos_x, int pos_y, int width, int height, int id); /** * Create child tab controlwindow. @@ -81,100 +81,101 @@ class Window { /** * Create child list view window. * - * @param posX Position by X coordinate. - * @param posY Position by Y coordinate. - * @param sizeX Size by X coordinate. - * @param sizeY Size by Y coordinate. + * @param pos_x Position by X coordinate. + * @param pos_y Position by Y coordinate. + * @param size_x Size by X coordinate. + * @param size_y Size by Y coordinate. * @param id ID to be assigned to the created window. * @return Auto pointer containing new window. */ - std::unique_ptr CreateList(int posX, int posY, int sizeX, int sizeY, int id); + std::unique_ptr CreateList(int pos_x, int pos_y, int size_x, int size_y, + int id); /** * Create child group box window. * - * @param posX Position by X coordinate. - * @param posY Position by Y coordinate. - * @param sizeX Size by X coordinate. - * @param sizeY Size by Y coordinate. + * @param pos_x Position by X coordinate. + * @param pos_y Position by Y coordinate. + * @param size_x Size by X coordinate. + * @param size_y Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. * @return Auto pointer containing new window. */ - std::unique_ptr CreateGroupBox(int posX, int posY, int sizeX, int sizeY, + std::unique_ptr CreateGroupBox(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id); /** * Create child label window. * - * @param posX Position by X coordinate. - * @param posY Position by Y coordinate. - * @param sizeX Size by X coordinate. - * @param sizeY Size by Y coordinate. + * @param pos_x Position by X coordinate. + * @param pos_y Position by Y coordinate. + * @param size_x Size by X coordinate. + * @param size_y Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. * @return Auto pointer containing new window. */ - std::unique_ptr CreateLabel(int posX, int posY, int sizeX, int sizeY, + std::unique_ptr CreateLabel(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id); /** * Create child Edit window. * - * @param posX Position by X coordinate. - * @param posY Position by Y coordinate. - * @param sizeX Size by X coordinate. - * @param sizeY Size by Y coordinate. + * @param pos_x Position by X coordinate. + * @param pos_y Position by Y coordinate. + * @param size_x Size by X coordinate. + * @param size_y Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. * @param style Window style. * @return Auto pointer containing new window. */ - std::unique_ptr CreateEdit(int posX, int posY, int sizeX, int sizeY, + std::unique_ptr CreateEdit(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id, int style = 0); /** * Create child button window. * - * @param posX Position by X coordinate. - * @param posY Position by Y coordinate. - * @param sizeX Size by X coordinate. - * @param sizeY Size by Y coordinate. + * @param pos_x Position by X coordinate. + * @param pos_y Position by Y coordinate. + * @param size_x Size by X coordinate. + * @param size_y Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. * @param style Window style. * @return Auto pointer containing new window. */ - std::unique_ptr CreateButton(int posX, int posY, int sizeX, int sizeY, + std::unique_ptr CreateButton(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id, int style = 0); /** * Create child CheckBox window. * - * @param posX Position by X coordinate. - * @param posY Position by Y coordinate. - * @param sizeX Size by X coordinate. - * @param sizeY Size by Y coordinate. + * @param pos_x Position by X coordinate. + * @param pos_y Position by Y coordinate. + * @param size_x Size by X coordinate. + * @param size_y Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. * @param state Checked state of checkbox * @return Auto pointer containing new window. */ - std::unique_ptr CreateCheckBox(int posX, int posY, int sizeX, int sizeY, + std::unique_ptr CreateCheckBox(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id, bool state); /** * Create child ComboBox window. * - * @param posX Position by X coordinate. - * @param posY Position by Y coordinate. - * @param sizeX Size by X coordinate. - * @param sizeY Size by Y coordinate. + * @param pos_x Position by X coordinate. + * @param pos_y Position by Y coordinate. + * @param size_x Size by X coordinate. + * @param size_y Size by Y coordinate. * @param title Title. * @param id ID to be assigned to the created window. * @return Auto pointer containing new window. */ - std::unique_ptr CreateComboBox(int posX, int posY, int sizeX, int sizeY, + std::unique_ptr CreateComboBox(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id); /** @@ -197,7 +198,7 @@ class Window { * * @return Window handle. */ - HWND GetHandle() const { return handle; } + HWND GetHandle() const { return handle_; } void SetVisible(bool isVisible); @@ -282,22 +283,22 @@ class Window { * * @param value Window handle. */ - void SetHandle(HWND value) { handle = value; } + void SetHandle(HWND value) { handle_ = value; } /** Window class name. */ - std::string className; + std::string class_name_; /** Window title. */ - std::string title; + std::string title_; /** Window handle. */ - HWND handle; + HWND handle_; /** Window parent. */ - Window* parent; + Window* parent_; /** Specifies whether window has been created by the thread and needs destruction. */ - bool created; + bool created_; private: Window(const Window& window) = delete; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/main.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/main.cc index e112fdf67c08d..b8b9f9e91f1e8 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/main.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/main.cc @@ -28,6 +28,7 @@ #include #include "arrow/flight/api.h" #include "arrow/flight/sql/api.h" +#include "arrow/util/logging.h" using arrow::Status; using arrow::flight::FlightClient; @@ -48,18 +49,18 @@ void TestBindColumn(const std::shared_ptr& connection) { const std::shared_ptr& result_set = statement->GetResultSet(); const int batch_size = 100; - const int max_strlen = 1000; + const int max_str_len = 1000; - char IncidntNum[batch_size][max_strlen]; - ssize_t IncidntNum_length[batch_size]; + char incidnt_num[batch_size][max_str_len]; + ssize_t incidnt_num_length[batch_size]; - char Category[batch_size][max_strlen]; - ssize_t Category_length[batch_size]; + char category[batch_size][max_str_len]; + ssize_t category_length[batch_size]; - result_set->BindColumn(1, driver::odbcabstraction::CDataType_CHAR, 0, 0, IncidntNum, - max_strlen, IncidntNum_length); - result_set->BindColumn(2, driver::odbcabstraction::CDataType_CHAR, 0, 0, Category, - max_strlen, Category_length); + result_set->BindColumn(1, driver::odbcabstraction::CDataType_CHAR, 0, 0, incidnt_num, + max_str_len, incidnt_num_length); + result_set->BindColumn(2, driver::odbcabstraction::CDataType_CHAR, 0, 0, category, + max_str_len, category_length); size_t total = 0; while (true) { @@ -70,8 +71,8 @@ void TestBindColumn(const std::shared_ptr& connection) { std::cout << "Total:" << total << std::endl; for (int i = 0; i < fetched_rows; ++i) { - std::cout << "Row[" << i << "] IncidntNum: '" << IncidntNum[i] << "', Category: '" - << Category[i] << "'" << std::endl; + ARROW_LOG(DEBUG) << "Row[" << i << "] incidnt_num: '" << incidnt_num[i] + << "', Category: '" << category[i] << "'"; } if (fetched_rows < batch_size) break; @@ -114,34 +115,34 @@ void TestBindColumnBigInt(const std::shared_ptr& connection) { const int batch_size = 100; const int max_strlen = 1000; - char IncidntNum[batch_size][max_strlen]; - ssize_t IncidntNum_length[batch_size]; + char incidnt_num[batch_size][max_strlen]; + ssize_t incidnt_num_length[batch_size]; double double_field[batch_size]; ssize_t double_field_length[batch_size]; - char Category[batch_size][max_strlen]; - ssize_t Category_length[batch_size]; + char category[batch_size][max_strlen]; + ssize_t category_length[batch_size]; - result_set->BindColumn(1, driver::odbcabstraction::CDataType_CHAR, 0, 0, IncidntNum, - max_strlen, IncidntNum_length); + result_set->BindColumn(1, driver::odbcabstraction::CDataType_CHAR, 0, 0, incidnt_num, + max_strlen, incidnt_num_length); result_set->BindColumn(2, driver::odbcabstraction::CDataType_DOUBLE, 0, 0, double_field, max_strlen, double_field_length); - result_set->BindColumn(3, driver::odbcabstraction::CDataType_CHAR, 0, 0, Category, - max_strlen, Category_length); + result_set->BindColumn(3, driver::odbcabstraction::CDataType_CHAR, 0, 0, category, + max_strlen, category_length); size_t total = 0; while (true) { size_t fetched_rows = result_set->Move(batch_size, 0, 0, nullptr); - std::cout << "Fetched " << fetched_rows << " rows." << std::endl; + ARROW_LOG(DEBUG) << "Fetched " << fetched_rows << " rows."; total += fetched_rows; - std::cout << "Total:" << total << std::endl; + ARROW_LOG(DEBUG) << "Total:" << total; for (int i = 0; i < fetched_rows; ++i) { - std::cout << "Row[" << i << "] IncidntNum: '" << IncidntNum[i] << "', " - << "double_field: '" << double_field[i] << "', " - << "Category: '" << Category[i] << "'" << std::endl; + ARROW_LOG(DEBUG) << "Row[" << i << "] incidnt_num: '" << incidnt_num[i] << "', " + << "double_field: '" << double_field[i] << "', " + << "category: '" << category[i] << "'"; } if (fetched_rows < batch_size) break; diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/system_dsn.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/system_dsn.cc index 504b62a81ebb2..6426c0c5b5075 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/system_dsn.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/system_dsn.cc @@ -81,10 +81,10 @@ void PostLastInstallerError() { std::stringstream buf; buf << "Message: \"" << msg << "\", Code: " << code; - std::string errorMsg = buf.str(); + std::string error_msg = buf.str(); - MessageBox(NULL, errorMsg.c_str(), "Error!", MB_ICONEXCLAMATION | MB_OK); - SQLPostInstallerError(code, errorMsg.c_str()); + MessageBox(NULL, error_msg.c_str(), "Error!", MB_ICONEXCLAMATION | MB_OK); + SQLPostInstallerError(code, error_msg.c_str()); } /** diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/add_property_window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/add_property_window.cc index 64cc1797f7ed2..60fcca64f1773 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/add_property_window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/add_property_window.cc @@ -34,10 +34,10 @@ namespace config { AddPropertyWindow::AddPropertyWindow(Window* parent) : CustomWindow(parent, "AddProperty", "Add Property"), - width(300), - height(120), - accepted(false), - isInitialized(false) { + width_(300), + height_(120), + accepted_(false), + is_initialized_(false) { // No-op. } @@ -47,22 +47,24 @@ AddPropertyWindow::~AddPropertyWindow() { void AddPropertyWindow::Create() { // Finding out parent position. - RECT parentRect; - GetWindowRect(parent->GetHandle(), &parentRect); + RECT parent_rect; + GetWindowRect(parent_->GetHandle(), &parent_rect); // Positioning window to the center of parent window. - const int posX = parentRect.left + (parentRect.right - parentRect.left - width) / 2; - const int posY = parentRect.top + (parentRect.bottom - parentRect.top - height) / 2; + const int pos_x = + parent_rect.left + (parent_rect.right - parent_rect.left - width_) / 2; + const int pos_y = + parent_rect.top + (parent_rect.bottom - parent_rect.top - height_) / 2; - RECT desiredRect = {posX, posY, posX + width, posY + height}; - AdjustWindowRect(&desiredRect, WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, + RECT desired_rect = {pos_x, pos_y, pos_x + width_, pos_y + height_}; + AdjustWindowRect(&desired_rect, WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, FALSE); - Window::Create(WS_OVERLAPPED | WS_SYSMENU, desiredRect.left, desiredRect.top, - desiredRect.right - desiredRect.left, - desiredRect.bottom - desiredRect.top, 0); + Window::Create(WS_OVERLAPPED | WS_SYSMENU, desired_rect.left, desired_rect.top, + desired_rect.right - desired_rect.left, + desired_rect.bottom - desired_rect.top, 0); - if (!handle) { + if (!handle_) { std::stringstream buf; buf << "Can not create window, error code: " << GetLastError(); throw odbcabstraction::DriverException(buf.str()); @@ -70,71 +72,72 @@ void AddPropertyWindow::Create() { } bool AddPropertyWindow::GetProperty(std::string& key, std::string& value) { - if (accepted) { - key = this->key; - value = this->value; + if (accepted_) { + key = this->key_; + value = this->value_; return true; } return false; } void AddPropertyWindow::OnCreate() { - int groupPosY = MARGIN; - int groupSizeY = width - 2 * MARGIN; + int group_pos_y = MARGIN; + int group_size_y = width_ - 2 * MARGIN; - groupPosY += INTERVAL + CreateEdits(MARGIN, groupPosY, groupSizeY); + group_pos_y += INTERVAL + CreateEdits(MARGIN, group_pos_y, group_size_y); - int cancelPosX = width - MARGIN - BUTTON_WIDTH; - int okPosX = cancelPosX - INTERVAL - BUTTON_WIDTH; + int cancel_pos_x = width_ - MARGIN - BUTTON_WIDTH; + int ok_pos_x = cancel_pos_x - INTERVAL - BUTTON_WIDTH; - okButton = CreateButton(okPosX, groupPosY, BUTTON_WIDTH, BUTTON_HEIGHT, "Ok", - ChildId::OK_BUTTON, BS_DEFPUSHBUTTON); - cancelButton = CreateButton(cancelPosX, groupPosY, BUTTON_WIDTH, BUTTON_HEIGHT, - "Cancel", ChildId::CANCEL_BUTTON); - isInitialized = true; + ok_button_ = CreateButton(ok_pos_x, group_pos_y, BUTTON_WIDTH, BUTTON_HEIGHT, "Ok", + ChildId::OK_BUTTON, BS_DEFPUSHBUTTON); + cancel_button_ = CreateButton(cancel_pos_x, group_pos_y, BUTTON_WIDTH, BUTTON_HEIGHT, + "Cancel", ChildId::CANCEL_BUTTON); + is_initialized_ = true; CheckEnableOk(); } -int AddPropertyWindow::CreateEdits(int posX, int posY, int sizeX) { +int AddPropertyWindow::CreateEdits(int pos_x, int pos_y, int size_x) { enum { LABEL_WIDTH = 30 }; - const int editSizeX = sizeX - LABEL_WIDTH - INTERVAL; - const int editPosX = posX + LABEL_WIDTH + INTERVAL; + const int edit_size_x = size_x - LABEL_WIDTH - INTERVAL; + const int edit_pos_x = pos_x + LABEL_WIDTH + INTERVAL; - int rowPos = posY; + int row_pos = pos_y; - labels.push_back( - CreateLabel(posX, rowPos, LABEL_WIDTH, ROW_HEIGHT, "Key:", ChildId::KEY_LABEL)); - keyEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, "", ChildId::KEY_EDIT); + labels_.push_back( + CreateLabel(pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, "Key:", ChildId::KEY_LABEL)); + key_edit_ = + CreateEdit(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, "", ChildId::KEY_EDIT); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - labels.push_back( - CreateLabel(posX, rowPos, LABEL_WIDTH, ROW_HEIGHT, "Value:", ChildId::VALUE_LABEL)); - valueEdit = - CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, "", ChildId::VALUE_EDIT); + labels_.push_back(CreateLabel(pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Value:", ChildId::VALUE_LABEL)); + value_edit_ = + CreateEdit(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, "", ChildId::VALUE_EDIT); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - return rowPos - posY; + return row_pos - pos_y; } void AddPropertyWindow::CheckEnableOk() { - if (!isInitialized) { + if (!is_initialized_) { return; } - okButton->SetEnabled(!keyEdit->IsTextEmpty() && !valueEdit->IsTextEmpty()); + ok_button_->SetEnabled(!key_edit_->IsTextEmpty() && !value_edit_->IsTextEmpty()); } -bool AddPropertyWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { +bool AddPropertyWindow::OnMessage(UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_COMMAND: { - switch (LOWORD(wParam)) { + switch (LOWORD(wparam)) { case ChildId::OK_BUTTON: { - keyEdit->GetText(key); - valueEdit->GetText(value); - accepted = true; + key_edit_->GetText(key_); + value_edit_->GetText(value_); + accepted_ = true; PostMessage(GetHandle(), WM_CLOSE, 0, 0); break; @@ -148,7 +151,7 @@ bool AddPropertyWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { case ChildId::KEY_EDIT: case ChildId::VALUE_EDIT: { - if (HIWORD(wParam) == EN_CHANGE) { + if (HIWORD(wparam) == EN_CHANGE) { CheckEnableOk(); } break; @@ -162,7 +165,7 @@ bool AddPropertyWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { } case WM_DESTROY: { - PostQuitMessage(accepted ? Result::OK : Result::CANCEL); + PostQuitMessage(accepted_ ? Result::OK : Result::CANCEL); break; } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc index 5443ea0ec8d29..438bc535dc4eb 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/custom_window.cc @@ -46,22 +46,22 @@ Result::Type ProcessMessages(Window& window) { return static_cast(msg.wParam); } -LRESULT CALLBACK CustomWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) { +LRESULT CALLBACK CustomWindow::WndProc(HWND hwnd, UINT msg, WPARAM wparam, + LPARAM lparam) { CustomWindow* window = reinterpret_cast(GetWindowLongPtr(hwnd, GWLP_USERDATA)); switch (msg) { case WM_NCCREATE: { - _ASSERT(lParam != NULL); + _ASSERT(lparam != NULL); - CREATESTRUCT* createStruct = reinterpret_cast(lParam); + CREATESTRUCT* create_struct = reinterpret_cast(lparam); - LONG_PTR longSelfPtr = reinterpret_cast(createStruct->lpCreateParams); + LONG_PTR long_self_ptr = reinterpret_cast(create_struct->lpCreateParams); - SetWindowLongPtr(hwnd, GWLP_USERDATA, longSelfPtr); + SetWindowLongPtr(hwnd, GWLP_USERDATA, long_self_ptr); - return DefWindowProc(hwnd, msg, wParam, lParam); + return DefWindowProc(hwnd, msg, wparam, lparam); } case WM_CREATE: { @@ -78,13 +78,13 @@ LRESULT CALLBACK CustomWindow::WndProc(HWND hwnd, UINT msg, WPARAM wParam, break; } - if (window && window->OnMessage(msg, wParam, lParam)) return 0; + if (window && window->OnMessage(msg, wparam, lparam)) return 0; - return DefWindowProc(hwnd, msg, wParam, lParam); + return DefWindowProc(hwnd, msg, wparam, lparam); } -CustomWindow::CustomWindow(Window* parent, const char* className, const char* title) - : Window(parent, className, title) { +CustomWindow::CustomWindow(Window* parent, const char* class_name, const char* title) + : Window(parent, class_name, title) { WNDCLASS wcx; wcx.style = CS_HREDRAW | CS_VREDRAW; @@ -96,7 +96,7 @@ CustomWindow::CustomWindow(Window* parent, const char* className, const char* ti wcx.hCursor = LoadCursor(NULL, IDC_ARROW); wcx.hbrBackground = (HBRUSH)COLOR_WINDOW; wcx.lpszMenuName = NULL; - wcx.lpszClassName = className; + wcx.lpszClassName = class_name; if (!RegisterClass(&wcx)) { std::stringstream buf; @@ -105,7 +105,7 @@ CustomWindow::CustomWindow(Window* parent, const char* className, const char* ti } } -CustomWindow::~CustomWindow() { UnregisterClass(className.c_str(), GetHInstance()); } +CustomWindow::~CustomWindow() { UnregisterClass(class_name_.c_str(), GetHInstance()); } } // namespace config } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc index 7792773447112..718b4a1d52b06 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/dsn_configuration_window.cc @@ -33,19 +33,19 @@ namespace { std::string TestConnection(const driver::flight_sql::config::Configuration& config) { - std::unique_ptr flightSqlConn( + std::unique_ptr flight_sql_conn( new driver::flight_sql::FlightSqlConnection(driver::odbcabstraction::V_3)); - std::vector missingProperties; - flightSqlConn->Connect(config.GetProperties(), missingProperties); + std::vector missing_properties; + flight_sql_conn->Connect(config.GetProperties(), missing_properties); // This should have been checked before enabling the Test button. - assert(missingProperties.empty()); - std::string serverName = - boost::get(flightSqlConn->GetInfo(SQL_SERVER_NAME)); - std::string serverVersion = - boost::get(flightSqlConn->GetInfo(SQL_DBMS_VER)); - return "Server Name: " + serverName + "\n" + "Server Version: " + serverVersion; + assert(missing_properties.empty()); + std::string server_name = + boost::get(flight_sql_conn->GetInfo(SQL_SERVER_NAME)); + std::string server_version = + boost::get(flight_sql_conn->GetInfo(SQL_DBMS_VER)); + return "Server Name: " + server_name + "\n" + "Server Version: " + server_version; } } // namespace @@ -56,11 +56,11 @@ namespace config { DsnConfigurationWindow::DsnConfigurationWindow(Window* parent, config::Configuration& config) : CustomWindow(parent, "FlightConfigureDSN", "Configure Apache Arrow Flight SQL"), - width(480), - height(375), - config(config), - accepted(false), - isInitialized(false) { + width_(480), + height_(375), + config_(config), + accepted_(false), + is_initialized_(false) { // No-op. } @@ -70,22 +70,24 @@ DsnConfigurationWindow::~DsnConfigurationWindow() { void DsnConfigurationWindow::Create() { // Finding out parent position. - RECT parentRect; - GetWindowRect(parent->GetHandle(), &parentRect); + RECT parent_rect; + GetWindowRect(parent_->GetHandle(), &parent_rect); // Positioning window to the center of parent window. - const int posX = parentRect.left + (parentRect.right - parentRect.left - width) / 2; - const int posY = parentRect.top + (parentRect.bottom - parentRect.top - height) / 2; + const int pos_x = + parent_rect.left + (parent_rect.right - parent_rect.left - width_) / 2; + const int pos_y = + parent_rect.top + (parent_rect.bottom - parent_rect.top - height_) / 2; - RECT desiredRect = {posX, posY, posX + width, posY + height}; - AdjustWindowRect(&desiredRect, WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, + RECT desired_rect = {pos_x, pos_y, pos_x + width_, pos_y + height_}; + AdjustWindowRect(&desired_rect, WS_BORDER | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME, FALSE); - Window::Create(WS_OVERLAPPED | WS_SYSMENU, desiredRect.left, desiredRect.top, - desiredRect.right - desiredRect.left, - desiredRect.bottom - desiredRect.top, 0); + Window::Create(WS_OVERLAPPED | WS_SYSMENU, desired_rect.left, desired_rect.top, + desired_rect.right - desired_rect.left, + desired_rect.bottom - desired_rect.top, 0); - if (!handle) { + if (!handle_) { std::stringstream buf; buf << "Can not create window, error code: " << GetLastError(); throw odbcabstraction::DriverException(buf.str()); @@ -93,362 +95,370 @@ void DsnConfigurationWindow::Create() { } void DsnConfigurationWindow::OnCreate() { - tabControl = CreateTabControl(ChildId::TAB_CONTROL); - tabControl->AddTab("Common", COMMON_TAB); - tabControl->AddTab("Advanced", ADVANCED_TAB); - - int groupPosY = 3 * MARGIN; - int groupSizeY = width - 2 * MARGIN; - - int commonGroupPosY = groupPosY; - commonGroupPosY += - INTERVAL + CreateConnectionSettingsGroup(MARGIN, commonGroupPosY, groupSizeY); - commonGroupPosY += - INTERVAL + CreateAuthSettingsGroup(MARGIN, commonGroupPosY, groupSizeY); - - int advancedGroupPosY = groupPosY; - advancedGroupPosY += - INTERVAL + CreateEncryptionSettingsGroup(MARGIN, advancedGroupPosY, groupSizeY); - advancedGroupPosY += - INTERVAL + CreatePropertiesGroup(MARGIN, advancedGroupPosY, groupSizeY); - - int testPosX = MARGIN; - int cancelPosX = width - MARGIN - BUTTON_WIDTH; - int okPosX = cancelPosX - INTERVAL - BUTTON_WIDTH; - - int buttonPosY = std::max(commonGroupPosY, advancedGroupPosY); - testButton = CreateButton(testPosX, buttonPosY, BUTTON_WIDTH + 20, BUTTON_HEIGHT, - "Test Connection", ChildId::TEST_CONNECTION_BUTTON); - okButton = CreateButton(okPosX, buttonPosY, BUTTON_WIDTH, BUTTON_HEIGHT, "Ok", - ChildId::OK_BUTTON); - cancelButton = CreateButton(cancelPosX, buttonPosY, BUTTON_WIDTH, BUTTON_HEIGHT, - "Cancel", ChildId::CANCEL_BUTTON); - isInitialized = true; + tab_control_ = CreateTabControl(ChildId::TAB_CONTROL); + tab_control_->AddTab("Common", COMMON_TAB); + tab_control_->AddTab("Advanced", ADVANCED_TAB); + + int group_pos_y = 3 * MARGIN; + int group_size_y = width_ - 2 * MARGIN; + + int common_group_pos_y = group_pos_y; + common_group_pos_y += + INTERVAL + CreateConnectionSettingsGroup(MARGIN, common_group_pos_y, group_size_y); + common_group_pos_y += + INTERVAL + CreateAuthSettingsGroup(MARGIN, common_group_pos_y, group_size_y); + + int advanced_group_pos_y = group_pos_y; + advanced_group_pos_y += INTERVAL + CreateEncryptionSettingsGroup( + MARGIN, advanced_group_pos_y, group_size_y); + advanced_group_pos_y += + INTERVAL + CreatePropertiesGroup(MARGIN, advanced_group_pos_y, group_size_y); + + int test_pos_x = MARGIN; + int cancel_pos_x = width_ - MARGIN - BUTTON_WIDTH; + int ok_pos_x = cancel_pos_x - INTERVAL - BUTTON_WIDTH; + + int button_pos_y = std::max(common_group_pos_y, advanced_group_pos_y); + test_button_ = CreateButton(test_pos_x, button_pos_y, BUTTON_WIDTH + 20, BUTTON_HEIGHT, + "Test Connection", ChildId::TEST_CONNECTION_BUTTON); + ok_button_ = CreateButton(ok_pos_x, button_pos_y, BUTTON_WIDTH, BUTTON_HEIGHT, "Ok", + ChildId::OK_BUTTON); + cancel_button_ = CreateButton(cancel_pos_x, button_pos_y, BUTTON_WIDTH, BUTTON_HEIGHT, + "Cancel", ChildId::CANCEL_BUTTON); + is_initialized_ = true; CheckEnableOk(); SelectTab(COMMON_TAB); } -int DsnConfigurationWindow::CreateConnectionSettingsGroup(int posX, int posY, int sizeX) { +int DsnConfigurationWindow::CreateConnectionSettingsGroup(int pos_x, int pos_y, + int size_x) { enum { LABEL_WIDTH = 100 }; - const int labelPosX = posX + INTERVAL; + const int label_pos_x = pos_x + INTERVAL; - const int editSizeX = sizeX - LABEL_WIDTH - 3 * INTERVAL; - const int editPosX = labelPosX + LABEL_WIDTH + INTERVAL; + const int edit_size_x = size_x - LABEL_WIDTH - 3 * INTERVAL; + const int edit_pos_x = label_pos_x + LABEL_WIDTH + INTERVAL; - int rowPos = posY + 2 * INTERVAL; + int row_pos = pos_y + 2 * INTERVAL; - const char* val = config.Get(FlightSqlConnection::DSN).c_str(); - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "Data Source Name:", ChildId::NAME_LABEL)); - nameEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::NAME_EDIT); + const char* val = config_.Get(FlightSqlConnection::DSN).c_str(); + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Data Source Name:", ChildId::NAME_LABEL)); + name_edit_ = + CreateEdit(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, val, ChildId::NAME_EDIT); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - val = config.Get(FlightSqlConnection::HOST).c_str(); - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "Host Name:", ChildId::SERVER_LABEL)); - serverEdit = - CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::SERVER_EDIT); + val = config_.Get(FlightSqlConnection::HOST).c_str(); + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Host Name:", ChildId::SERVER_LABEL)); + server_edit_ = + CreateEdit(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, val, ChildId::SERVER_EDIT); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - val = config.Get(FlightSqlConnection::PORT).c_str(); - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "Port:", ChildId::PORT_LABEL)); - portEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::PORT_EDIT, - ES_NUMBER); + val = config_.Get(FlightSqlConnection::PORT).c_str(); + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Port:", ChildId::PORT_LABEL)); + port_edit_ = CreateEdit(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, val, + ChildId::PORT_EDIT, ES_NUMBER); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - connectionSettingsGroupBox = - CreateGroupBox(posX, posY, sizeX, rowPos - posY, "Connection settings", + connection_settings_group_box_ = + CreateGroupBox(pos_x, pos_y, size_x, row_pos - pos_y, "Connection settings", ChildId::CONNECTION_SETTINGS_GROUP_BOX); - return rowPos - posY; + return row_pos - pos_y; } -int DsnConfigurationWindow::CreateAuthSettingsGroup(int posX, int posY, int sizeX) { +int DsnConfigurationWindow::CreateAuthSettingsGroup(int pos_x, int pos_y, int size_x) { enum { LABEL_WIDTH = 120 }; - const int labelPosX = posX + INTERVAL; + const int label_pos_x = pos_x + INTERVAL; - const int editSizeX = sizeX - LABEL_WIDTH - 3 * INTERVAL; - const int editPosX = labelPosX + LABEL_WIDTH + INTERVAL; + const int edit_size_x = size_x - LABEL_WIDTH - 3 * INTERVAL; + const int edit_pos_x = label_pos_x + LABEL_WIDTH + INTERVAL; - int rowPos = posY + 2 * INTERVAL; + int row_pos = pos_y + 2 * INTERVAL; - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "Authentication Type:", ChildId::AUTH_TYPE_LABEL)); - authTypeComboBox = CreateComboBox(editPosX, rowPos, editSizeX, ROW_HEIGHT, - "Authentication Type:", ChildId::AUTH_TYPE_COMBOBOX); - authTypeComboBox->AddString("Basic Authentication"); - authTypeComboBox->AddString("Token Authentication"); + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Authentication Type:", ChildId::AUTH_TYPE_LABEL)); + auth_type_combo_box_ = + CreateComboBox(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, + "Authentication Type:", ChildId::AUTH_TYPE_COMBOBOX); + auth_type_combo_box_->AddString("Basic Authentication"); + auth_type_combo_box_->AddString("Token Authentication"); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - const char* val = config.Get(FlightSqlConnection::UID).c_str(); + const char* val = config_.Get(FlightSqlConnection::UID).c_str(); - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "User:", ChildId::USER_LABEL)); - userEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::USER_EDIT); + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "User:", ChildId::USER_LABEL)); + user_edit_ = + CreateEdit(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, val, ChildId::USER_EDIT); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - val = config.Get(FlightSqlConnection::PWD).c_str(); - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "Password:", ChildId::PASSWORD_LABEL)); - passwordEdit = CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, - ChildId::USER_EDIT, ES_PASSWORD); + val = config_.Get(FlightSqlConnection::PWD).c_str(); + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Password:", ChildId::PASSWORD_LABEL)); + password_edit_ = CreateEdit(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, val, + ChildId::USER_EDIT, ES_PASSWORD); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - const auto& token = config.Get(FlightSqlConnection::TOKEN); + const auto& token = config_.Get(FlightSqlConnection::TOKEN); val = token.c_str(); - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "Authentication Token:", ChildId::AUTH_TOKEN_LABEL)); - authTokenEdit = - CreateEdit(editPosX, rowPos, editSizeX, ROW_HEIGHT, val, ChildId::AUTH_TOKEN_EDIT); - authTokenEdit->SetEnabled(false); + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Authentication Token:", ChildId::AUTH_TOKEN_LABEL)); + auth_token_edit_ = CreateEdit(edit_pos_x, row_pos, edit_size_x, ROW_HEIGHT, val, + ChildId::AUTH_TOKEN_EDIT); + auth_token_edit_->SetEnabled(false); // Ensure the right elements are selected. - authTypeComboBox->SetSelection(token.empty() ? 0 : 1); + auth_type_combo_box_->SetSelection(token.empty() ? 0 : 1); CheckAuthType(); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - authSettingsGroupBox = - CreateGroupBox(posX, posY, sizeX, rowPos - posY, "Authentication settings", + auth_settings_group_box_ = + CreateGroupBox(pos_x, pos_y, size_x, row_pos - pos_y, "Authentication settings", ChildId::AUTH_SETTINGS_GROUP_BOX); - return rowPos - posY; + return row_pos - pos_y; } -int DsnConfigurationWindow::CreateEncryptionSettingsGroup(int posX, int posY, int sizeX) { +int DsnConfigurationWindow::CreateEncryptionSettingsGroup(int pos_x, int pos_y, + int size_x) { enum { LABEL_WIDTH = 120 }; - const int labelPosX = posX + INTERVAL; + const int label_pos_x = pos_x + INTERVAL; - const int editSizeX = sizeX - LABEL_WIDTH - 3 * INTERVAL; - const int editPosX = labelPosX + LABEL_WIDTH + INTERVAL; + const int edit_size_x = size_x - LABEL_WIDTH - 3 * INTERVAL; + const int edit_pos_x = label_pos_x + LABEL_WIDTH + INTERVAL; - int rowPos = posY + 2 * INTERVAL; + int row_pos = pos_y + 2 * INTERVAL; - const char* val = config.Get(FlightSqlConnection::USE_ENCRYPTION).c_str(); + const char* val = config_.Get(FlightSqlConnection::USE_ENCRYPTION).c_str(); - const bool enableEncryption = driver::odbcabstraction::AsBool(val).value_or(true); - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "Use Encryption:", ChildId::ENABLE_ENCRYPTION_LABEL)); - enableEncryptionCheckBox = - CreateCheckBox(editPosX, rowPos - 2, editSizeX, ROW_HEIGHT, "", - ChildId::ENABLE_ENCRYPTION_CHECKBOX, enableEncryption); + const bool enable_encryption = driver::odbcabstraction::AsBool(val).value_or(true); + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Use Encryption:", ChildId::ENABLE_ENCRYPTION_LABEL)); + enable_encryption_check_box_ = + CreateCheckBox(edit_pos_x, row_pos - 2, edit_size_x, ROW_HEIGHT, "", + ChildId::ENABLE_ENCRYPTION_CHECKBOX, enable_encryption); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - val = config.Get(FlightSqlConnection::TRUSTED_CERTS).c_str(); + val = config_.Get(FlightSqlConnection::TRUSTED_CERTS).c_str(); - labels.push_back(CreateLabel(labelPosX, rowPos, LABEL_WIDTH, ROW_HEIGHT, - "Certificate:", ChildId::CERTIFICATE_LABEL)); - certificateEdit = CreateEdit(editPosX, rowPos, editSizeX - MARGIN - BUTTON_WIDTH, - ROW_HEIGHT, val, ChildId::CERTIFICATE_EDIT); - certificateBrowseButton = - CreateButton(editPosX + editSizeX - BUTTON_WIDTH, rowPos - 2, BUTTON_WIDTH, + labels_.push_back(CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, ROW_HEIGHT, + "Certificate:", ChildId::CERTIFICATE_LABEL)); + certificate_edit_ = CreateEdit(edit_pos_x, row_pos, edit_size_x - MARGIN - BUTTON_WIDTH, + ROW_HEIGHT, val, ChildId::CERTIFICATE_EDIT); + certificate_browse_button_ = + CreateButton(edit_pos_x + edit_size_x - BUTTON_WIDTH, row_pos - 2, BUTTON_WIDTH, BUTTON_HEIGHT, "Browse", ChildId::CERTIFICATE_BROWSE_BUTTON); - rowPos += INTERVAL + ROW_HEIGHT; + row_pos += INTERVAL + ROW_HEIGHT; - val = config.Get(FlightSqlConnection::USE_SYSTEM_TRUST_STORE).c_str(); + val = config_.Get(FlightSqlConnection::USE_SYSTEM_TRUST_STORE).c_str(); - const bool useSystemCertStore = driver::odbcabstraction::AsBool(val).value_or(true); - labels.push_back( - CreateLabel(labelPosX, rowPos, LABEL_WIDTH, 2 * ROW_HEIGHT, + const bool use_system_cert_store = driver::odbcabstraction::AsBool(val).value_or(true); + labels_.push_back( + CreateLabel(label_pos_x, row_pos, LABEL_WIDTH, 2 * ROW_HEIGHT, "Use System Certificate Store:", ChildId::USE_SYSTEM_CERT_STORE_LABEL)); - useSystemCertStoreCheckBox = - CreateCheckBox(editPosX, rowPos - 2, 20, 2 * ROW_HEIGHT, "", - ChildId::USE_SYSTEM_CERT_STORE_CHECKBOX, useSystemCertStore); + use_system_cert_store_check_box_ = + CreateCheckBox(edit_pos_x, row_pos - 2, 20, 2 * ROW_HEIGHT, "", + ChildId::USE_SYSTEM_CERT_STORE_CHECKBOX, use_system_cert_store); - val = config.Get(FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION).c_str(); + val = config_.Get(FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION).c_str(); - const int rightPosX = labelPosX + (sizeX - (2 * INTERVAL)) / 2; - const int rightCheckPosX = rightPosX + (editPosX - labelPosX); - const bool disableCertVerification = + const int right_pos_x = label_pos_x + (size_x - (2 * INTERVAL)) / 2; + const int right_check_pos_x = right_pos_x + (edit_pos_x - label_pos_x); + const bool disable_cert_verification = driver::odbcabstraction::AsBool(val).value_or(false); - labels.push_back(CreateLabel( - rightPosX, rowPos, LABEL_WIDTH, 2 * ROW_HEIGHT, + labels_.push_back(CreateLabel( + right_pos_x, row_pos, LABEL_WIDTH, 2 * ROW_HEIGHT, "Disable Certificate Verification:", ChildId::DISABLE_CERT_VERIFICATION_LABEL)); - disableCertVerificationCheckBox = CreateCheckBox( - rightCheckPosX, rowPos - 2, 20, 2 * ROW_HEIGHT, "", - ChildId::DISABLE_CERT_VERIFICATION_CHECKBOX, disableCertVerification); + disable_cert_verification_check_box_ = CreateCheckBox( + right_check_pos_x, row_pos - 2, 20, 2 * ROW_HEIGHT, "", + ChildId::DISABLE_CERT_VERIFICATION_CHECKBOX, disable_cert_verification); - rowPos += INTERVAL + static_cast(1.5 * static_cast(ROW_HEIGHT)); + row_pos += INTERVAL + static_cast(1.5 * static_cast(ROW_HEIGHT)); - encryptionSettingsGroupBox = - CreateGroupBox(posX, posY, sizeX, rowPos - posY, "Encryption settings", + encryption_settings_group_box_ = + CreateGroupBox(pos_x, pos_y, size_x, row_pos - pos_y, "Encryption settings", ChildId::AUTH_SETTINGS_GROUP_BOX); - return rowPos - posY; + return row_pos - pos_y; } -int DsnConfigurationWindow::CreatePropertiesGroup(int posX, int posY, int sizeX) { +int DsnConfigurationWindow::CreatePropertiesGroup(int pos_x, int pos_y, int size_x) { enum { LABEL_WIDTH = 120 }; - const int labelPosX = posX + INTERVAL; - const int listSize = sizeX - 2 * INTERVAL; - const int columnSize = listSize / 2; + const int label_pos_x = pos_x + INTERVAL; + const int list_size = size_x - 2 * INTERVAL; + const int column_size = list_size / 2; - int rowPos = posY + 2 * INTERVAL; - const int listHeight = 5 * ROW_HEIGHT; + int row_pos = pos_y + 2 * INTERVAL; + const int list_height = 5 * ROW_HEIGHT; - propertyList = - CreateList(labelPosX, rowPos, listSize, listHeight, ChildId::PROPERTY_LIST); - propertyList->ListAddColumn("Key", 0, columnSize); - propertyList->ListAddColumn("Value", 1, columnSize); + property_list_ = + CreateList(label_pos_x, row_pos, list_size, list_height, ChildId::PROPERTY_LIST); + property_list_->ListAddColumn("Key", 0, column_size); + property_list_->ListAddColumn("Value", 1, column_size); - const auto keys = config.GetCustomKeys(); + const auto keys = config_.GetCustomKeys(); for (const auto& key : keys) { - propertyList->ListAddItem({std::string(key), config.Get(key)}); + property_list_->ListAddItem({std::string(key), config.Get(key)}); } - SendMessage(propertyList->GetHandle(), LVM_SETEXTENDEDLISTVIEWSTYLE, + SendMessage(property_list_->GetHandle(), LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT); - rowPos += INTERVAL + listHeight; + row_pos += INTERVAL + list_height; - int deletePosX = width - INTERVAL - MARGIN - BUTTON_WIDTH; - int addPosX = deletePosX - INTERVAL - BUTTON_WIDTH; - addButton = CreateButton(addPosX, rowPos, BUTTON_WIDTH, BUTTON_HEIGHT, "Add", - ChildId::ADD_BUTTON); - deleteButton = CreateButton(deletePosX, rowPos, BUTTON_WIDTH, BUTTON_HEIGHT, "Delete", - ChildId::DELETE_BUTTON); + int delete_pos_x = width_ - INTERVAL - MARGIN - BUTTON_WIDTH; + int add_pos_x = delete_pos_x - INTERVAL - BUTTON_WIDTH; + add_button_ = CreateButton(add_pos_x, row_pos, BUTTON_WIDTH, BUTTON_HEIGHT, "Add", + ChildId::ADD_BUTTON); + delete_button_ = CreateButton(delete_pos_x, row_pos, BUTTON_WIDTH, BUTTON_HEIGHT, + "Delete", ChildId::DELETE_BUTTON); - rowPos += INTERVAL + BUTTON_HEIGHT; + row_pos += INTERVAL + BUTTON_HEIGHT; - propertyGroupBox = CreateGroupBox(posX, posY, sizeX, rowPos - posY, - "Advanced properties", ChildId::PROPERTY_GROUP_BOX); + property_group_box_ = + CreateGroupBox(pos_x, pos_y, size_x, row_pos - pos_y, "Advanced properties", + ChildId::PROPERTY_GROUP_BOX); - return rowPos - posY; + return row_pos - pos_y; } -void DsnConfigurationWindow::SelectTab(int tabIndex) { - if (!isInitialized) { +void DsnConfigurationWindow::SelectTab(int tab_index) { + if (!is_initialized_) { return; } - connectionSettingsGroupBox->SetVisible(COMMON_TAB == tabIndex); - authSettingsGroupBox->SetVisible(COMMON_TAB == tabIndex); - nameEdit->SetVisible(COMMON_TAB == tabIndex); - serverEdit->SetVisible(COMMON_TAB == tabIndex); - portEdit->SetVisible(COMMON_TAB == tabIndex); - authTypeComboBox->SetVisible(COMMON_TAB == tabIndex); - userEdit->SetVisible(COMMON_TAB == tabIndex); - passwordEdit->SetVisible(COMMON_TAB == tabIndex); - authTokenEdit->SetVisible(COMMON_TAB == tabIndex); + connection_settings_group_box_->SetVisible(COMMON_TAB == tab_index); + auth_settings_group_box_->SetVisible(COMMON_TAB == tab_index); + name_edit_->SetVisible(COMMON_TAB == tab_index); + server_edit_->SetVisible(COMMON_TAB == tab_index); + port_edit_->SetVisible(COMMON_TAB == tab_index); + auth_type_combo_box_->SetVisible(COMMON_TAB == tab_index); + user_edit_->SetVisible(COMMON_TAB == tab_index); + password_edit_->SetVisible(COMMON_TAB == tab_index); + auth_token_edit_->SetVisible(COMMON_TAB == tab_index); for (size_t i = 0; i < 7; ++i) { - labels[i]->SetVisible(COMMON_TAB == tabIndex); + labels_[i]->SetVisible(COMMON_TAB == tab_index); } - encryptionSettingsGroupBox->SetVisible(ADVANCED_TAB == tabIndex); - enableEncryptionCheckBox->SetVisible(ADVANCED_TAB == tabIndex); - certificateEdit->SetVisible(ADVANCED_TAB == tabIndex); - certificateBrowseButton->SetVisible(ADVANCED_TAB == tabIndex); - useSystemCertStoreCheckBox->SetVisible(ADVANCED_TAB == tabIndex); - disableCertVerificationCheckBox->SetVisible(ADVANCED_TAB == tabIndex); - propertyGroupBox->SetVisible(ADVANCED_TAB == tabIndex); - propertyList->SetVisible(ADVANCED_TAB == tabIndex); - addButton->SetVisible(ADVANCED_TAB == tabIndex); - deleteButton->SetVisible(ADVANCED_TAB == tabIndex); - for (size_t i = 7; i < labels.size(); ++i) { - labels[i]->SetVisible(ADVANCED_TAB == tabIndex); + encryption_settings_group_box_->SetVisible(ADVANCED_TAB == tab_index); + enable_encryption_check_box_->SetVisible(ADVANCED_TAB == tab_index); + certificate_edit_->SetVisible(ADVANCED_TAB == tab_index); + certificate_browse_button_->SetVisible(ADVANCED_TAB == tab_index); + use_system_cert_store_check_box_->SetVisible(ADVANCED_TAB == tab_index); + disable_cert_verification_check_box_->SetVisible(ADVANCED_TAB == tab_index); + property_group_box_->SetVisible(ADVANCED_TAB == tab_index); + property_list_->SetVisible(ADVANCED_TAB == tab_index); + add_button_->SetVisible(ADVANCED_TAB == tab_index); + delete_button_->SetVisible(ADVANCED_TAB == tab_index); + for (size_t i = 7; i < labels_.size(); ++i) { + labels_[i]->SetVisible(ADVANCED_TAB == tab_index); } } void DsnConfigurationWindow::CheckEnableOk() { - if (!isInitialized) { + if (!is_initialized_) { return; } - bool enableOk = !nameEdit->IsTextEmpty(); - enableOk = enableOk && !serverEdit->IsTextEmpty(); - enableOk = enableOk && !portEdit->IsTextEmpty(); - if (authTokenEdit->IsEnabled()) { - enableOk = enableOk && !authTokenEdit->IsTextEmpty(); + bool enable_ok = !name_edit_->IsTextEmpty(); + enable_ok = enable_ok && !server_edit_->IsTextEmpty(); + enable_ok = enable_ok && !port_edit_->IsTextEmpty(); + if (auth_token_edit_->IsEnabled()) { + enable_ok = enable_ok && !auth_token_edit_->IsTextEmpty(); } else { - enableOk = enableOk && !userEdit->IsTextEmpty(); - enableOk = enableOk && !passwordEdit->IsTextEmpty(); + enable_ok = enable_ok && !user_edit_->IsTextEmpty(); + enable_ok = enable_ok && !password_edit_->IsTextEmpty(); } - testButton->SetEnabled(enableOk); - okButton->SetEnabled(enableOk); + test_button_->SetEnabled(enable_ok); + ok_button_->SetEnabled(enable_ok); } -void DsnConfigurationWindow::SaveParameters(Configuration& targetConfig) { - targetConfig.Clear(); +void DsnConfigurationWindow::SaveParameters(Configuration& target_config) { + target_config.Clear(); std::string text; - nameEdit->GetText(text); - targetConfig.Set(FlightSqlConnection::DSN, text); - serverEdit->GetText(text); - targetConfig.Set(FlightSqlConnection::HOST, text); - portEdit->GetText(text); + name_edit_->GetText(text); + target_config.Set(FlightSqlConnection::DSN, text); + server_edit_->GetText(text); + target_config.Set(FlightSqlConnection::HOST, text); + port_edit_->GetText(text); try { - const int portInt = std::stoi(text); - if (0 > portInt || USHRT_MAX < portInt) { + const int port_int = std::stoi(text); + if (0 > port_int || USHRT_MAX < port_int) { throw odbcabstraction::DriverException("Invalid port value."); } - targetConfig.Set(FlightSqlConnection::PORT, text); + target_config.Set(FlightSqlConnection::PORT, text); } catch (odbcabstraction::DriverException&) { throw; } catch (std::exception&) { throw odbcabstraction::DriverException("Invalid port value."); } - if (0 == authTypeComboBox->GetSelection()) { - userEdit->GetText(text); - targetConfig.Set(FlightSqlConnection::UID, text); - passwordEdit->GetText(text); - targetConfig.Set(FlightSqlConnection::PWD, text); + if (0 == auth_type_combo_box_->GetSelection()) { + user_edit_->GetText(text); + target_config.Set(FlightSqlConnection::UID, text); + password_edit_->GetText(text); + target_config.Set(FlightSqlConnection::PWD, text); } else { - authTokenEdit->GetText(text); - targetConfig.Set(FlightSqlConnection::TOKEN, text); + auth_token_edit_->GetText(text); + target_config.Set(FlightSqlConnection::TOKEN, text); } - if (enableEncryptionCheckBox->IsChecked()) { - targetConfig.Set(FlightSqlConnection::USE_ENCRYPTION, TRUE_STR); - certificateEdit->GetText(text); - targetConfig.Set(FlightSqlConnection::TRUSTED_CERTS, text); - targetConfig.Set(FlightSqlConnection::USE_SYSTEM_TRUST_STORE, - useSystemCertStoreCheckBox->IsChecked() ? TRUE_STR : FALSE_STR); - targetConfig.Set(FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION, - disableCertVerificationCheckBox->IsChecked() ? TRUE_STR : FALSE_STR); + if (enable_encryption_check_box_->IsChecked()) { + target_config.Set(FlightSqlConnection::USE_ENCRYPTION, TRUE_STR); + certificate_edit_->GetText(text); + target_config.Set(FlightSqlConnection::TRUSTED_CERTS, text); + target_config.Set( + FlightSqlConnection::USE_SYSTEM_TRUST_STORE, + use_system_cert_store_check_box_->IsChecked() ? TRUE_STR : FALSE_STR); + target_config.Set( + FlightSqlConnection::DISABLE_CERTIFICATE_VERIFICATION, + disable_cert_verification_check_box_->IsChecked() ? TRUE_STR : FALSE_STR); } else { - targetConfig.Set(FlightSqlConnection::USE_ENCRYPTION, FALSE_STR); + target_config.Set(FlightSqlConnection::USE_ENCRYPTION, FALSE_STR); } // Get all the list properties. - const auto properties = propertyList->ListGetAll(); + const auto properties = property_list_->ListGetAll(); for (const auto& property : properties) { - targetConfig.Set(property[0], property[1]); + target_config.Set(property[0], property[1]); } } void DsnConfigurationWindow::CheckAuthType() { - const bool isBasic = COMMON_TAB == authTypeComboBox->GetSelection(); - userEdit->SetEnabled(isBasic); - passwordEdit->SetEnabled(isBasic); - authTokenEdit->SetEnabled(!isBasic); + const bool is_basic = COMMON_TAB == auth_type_combo_box_->GetSelection(); + user_edit_->SetEnabled(is_basic); + password_edit_->SetEnabled(is_basic); + auth_token_edit_->SetEnabled(!is_basic); } -bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { +bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wparam, LPARAM lparam) { switch (msg) { case WM_NOTIFY: { - switch (((LPNMHDR)lParam)->code) { + switch (((LPNMHDR)lparam)->code) { case TCN_SELCHANGING: { // Return FALSE to allow the selection to change. return FALSE; } case TCN_SELCHANGE: { - SelectTab(TabCtrl_GetCurSel(tabControl->GetHandle())); + SelectTab(TabCtrl_GetCurSel(tab_control_->GetHandle())); break; } } @@ -456,14 +466,14 @@ bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { } case WM_COMMAND: { - switch (LOWORD(wParam)) { + switch (LOWORD(wparam)) { case ChildId::TEST_CONNECTION_BUTTON: { try { - Configuration testConfig; - SaveParameters(testConfig); - std::string testMessage = TestConnection(testConfig); + Configuration test_config; + SaveParameters(test_config); + std::string test_message = TestConnection(test_config); - MessageBox(NULL, testMessage.c_str(), "Test Connection Success", MB_OK); + MessageBox(NULL, test_message.c_str(), "Test Connection Success", MB_OK); } catch (odbcabstraction::DriverException& err) { MessageBox(NULL, err.GetMessageText().c_str(), "Error!", MB_ICONEXCLAMATION | MB_OK); @@ -473,8 +483,8 @@ bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { } case ChildId::OK_BUTTON: { try { - SaveParameters(config); - accepted = true; + SaveParameters(config_); + accepted_ = true; PostMessage(GetHandle(), WM_CLOSE, 0, 0); } catch (odbcabstraction::DriverException& err) { MessageBox(NULL, err.GetMessageText().c_str(), "Error!", @@ -496,7 +506,7 @@ bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { case ChildId::PORT_EDIT: case ChildId::SERVER_EDIT: case ChildId::USER_EDIT: { - if (HIWORD(wParam) == EN_CHANGE) { + if (HIWORD(wparam) == EN_CHANGE) { CheckEnableOk(); } break; @@ -509,67 +519,67 @@ bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { } case ChildId::ENABLE_ENCRYPTION_CHECKBOX: { - const bool toggle = !enableEncryptionCheckBox->IsChecked(); - enableEncryptionCheckBox->SetChecked(toggle); - certificateEdit->SetEnabled(toggle); - certificateBrowseButton->SetEnabled(toggle); - useSystemCertStoreCheckBox->SetEnabled(toggle); - disableCertVerificationCheckBox->SetEnabled(toggle); + const bool toggle = !enable_encryption_check_box_->IsChecked(); + enable_encryption_check_box_->SetChecked(toggle); + certificate_edit_->SetEnabled(toggle); + certificate_browse_button_->SetEnabled(toggle); + use_system_cert_store_check_box_->SetEnabled(toggle); + disable_cert_verification_check_box_->SetEnabled(toggle); break; } case ChildId::CERTIFICATE_BROWSE_BUTTON: { - OPENFILENAME openFileName; - char fileName[FILENAME_MAX]; - - ZeroMemory(&openFileName, sizeof(openFileName)); - openFileName.lStructSize = sizeof(openFileName); - openFileName.hwndOwner = NULL; - openFileName.lpstrFile = fileName; - openFileName.lpstrFile[0] = '\0'; - openFileName.nMaxFile = FILENAME_MAX; + OPENFILENAME open_file_name; + char file_name[FILENAME_MAX]; + + ZeroMemory(&open_file_name, sizeof(open_file_name)); + open_file_name.lStructSize = sizeof(open_file_name); + open_file_name.hwndOwner = NULL; + open_file_name.lpstrFile = file_name; + open_file_name.lpstrFile[0] = '\0'; + open_file_name.nMaxFile = FILENAME_MAX; // TODO: What type should this be? - openFileName.lpstrFilter = "All\0*.*"; - openFileName.nFilterIndex = 1; - openFileName.lpstrFileTitle = NULL; - openFileName.nMaxFileTitle = 0; - openFileName.lpstrInitialDir = NULL; - openFileName.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; - - if (GetOpenFileName(&openFileName)) { - certificateEdit->SetText(fileName); + open_file_name.lpstrFilter = "All\0*.*"; + open_file_name.nFilterIndex = 1; + open_file_name.lpstrFileTitle = NULL; + open_file_name.nMaxFileTitle = 0; + open_file_name.lpstrInitialDir = NULL; + open_file_name.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; + + if (GetOpenFileName(&open_file_name)) { + certificate_edit_->SetText(file_name); } break; } case ChildId::USE_SYSTEM_CERT_STORE_CHECKBOX: { - useSystemCertStoreCheckBox->SetChecked( - !useSystemCertStoreCheckBox->IsChecked()); + use_system_cert_store_check_box_->SetChecked( + !use_system_cert_store_check_box_->IsChecked()); break; } case ChildId::DISABLE_CERT_VERIFICATION_CHECKBOX: { - disableCertVerificationCheckBox->SetChecked( - !disableCertVerificationCheckBox->IsChecked()); + disable_cert_verification_check_box_->SetChecked( + !disable_cert_verification_check_box_->IsChecked()); break; } case ChildId::DELETE_BUTTON: { - propertyList->ListDeleteSelectedItem(); + property_list_->ListDeleteSelectedItem(); break; } case ChildId::ADD_BUTTON: { - AddPropertyWindow addWindow(this); - addWindow.Create(); - addWindow.Show(); - addWindow.Update(); + AddPropertyWindow add_window(this); + add_window.Create(); + add_window.Show(); + add_window.Update(); - if (ProcessMessages(addWindow) == Result::OK) { + if (ProcessMessages(add_window) == Result::OK) { std::string key; std::string value; - addWindow.GetProperty(key, value); - propertyList->ListAddItem({key, value}); + add_window.GetProperty(key, value); + property_list_->ListAddItem({key, value}); } break; } @@ -582,7 +592,7 @@ bool DsnConfigurationWindow::OnMessage(UINT msg, WPARAM wParam, LPARAM lParam) { } case WM_DESTROY: { - PostQuitMessage(accepted ? Result::OK : Result::CANCEL); + PostQuitMessage(accepted_ ? Result::OK : Result::CANCEL); break; } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/window.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/window.cc index f88cd8a3f8808..534575680ac2f 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/window.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/ui/window.cc @@ -34,57 +34,61 @@ namespace flight_sql { namespace config { HINSTANCE GetHInstance() { - TCHAR szFileName[MAX_PATH]; - GetModuleFileName(NULL, szFileName, MAX_PATH); + TCHAR sz_file_name[MAX_PATH]; + GetModuleFileName(NULL, sz_file_name, MAX_PATH); // TODO: This needs to be the module name. - HINSTANCE hInstance = GetModuleHandle(szFileName); + HINSTANCE h_instance = GetModuleHandle(sz_file_name); - if (hInstance == NULL) { + if (h_instance == NULL) { std::stringstream buf; buf << "Can not get hInstance for the module, error code: " << GetLastError(); throw odbcabstraction::DriverException(buf.str()); } - return hInstance; + return h_instance; } -Window::Window(Window* parent, const char* className, const char* title) - : className(className), title(title), handle(NULL), parent(parent), created(false) { +Window::Window(Window* parent, const char* class_name, const char* title) + : class_name_(class_name), + title_(title), + handle_(NULL), + parent_(parent), + created_(false) { // No-op. } Window::Window(HWND handle) - : className(), title(), handle(handle), parent(0), created(false) { + : class_name_(), title_(), handle_(handle), parent_(0), created_(false) { // No-op. } Window::~Window() { - if (created) Destroy(); + if (created_) Destroy(); } -void Window::Create(DWORD style, int posX, int posY, int width, int height, int id) { - if (handle) { +void Window::Create(DWORD style, int pos_x, int pos_y, int width, int height, int id) { + if (handle_) { std::stringstream buf; buf << "Window already created, error code: " << GetLastError(); throw odbcabstraction::DriverException(buf.str()); } - handle = CreateWindow(className.c_str(), title.c_str(), style, posX, posY, width, - height, parent ? parent->GetHandle() : NULL, - reinterpret_cast(static_cast(id)), - GetHInstance(), this); + handle_ = CreateWindow(class_name_.c_str(), title_.c_str(), style, pos_x, pos_y, width, + height, parent_ ? parent_->GetHandle() : NULL, + reinterpret_cast(static_cast(id)), + GetHInstance(), this); - if (!handle) { + if (!handle_) { std::stringstream buf; buf << "Can not create window, error code: " << GetLastError(); throw odbcabstraction::DriverException(buf.str()); } - created = true; + created_ = true; - const HGDIOBJ hfDefault = GetStockObject(DEFAULT_GUI_FONT); - SendMessage(GetHandle(), WM_SETFONT, (WPARAM)hfDefault, MAKELPARAM(FALSE, 0)); + const HGDIOBJ hf_default = GetStockObject(DEFAULT_GUI_FONT); + SendMessage(GetHandle(), WM_SETFONT, (WPARAM)hf_default, MAKELPARAM(FALSE, 0)); } std::unique_ptr Window::CreateTabControl(int id) { @@ -92,104 +96,106 @@ std::unique_ptr Window::CreateTabControl(int id) { // Get the dimensions of the parent window's client area, and // create a tab control child window of that size. - RECT rcClient; - GetClientRect(handle, &rcClient); + RECT rc_client; + GetClientRect(handle_, &rc_client); child->Create(WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | WS_TABSTOP, 0, 0, - rcClient.right, 20, id); + rc_client.right, 20, id); return child; } -std::unique_ptr Window::CreateList(int posX, int posY, int sizeX, int sizeY, +std::unique_ptr Window::CreateList(int pos_x, int pos_y, int size_x, int size_y, int id) { std::unique_ptr child(new Window(this, WC_LISTVIEW, "")); child->Create( - WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_EDITLABELS | WS_TABSTOP, posX, - posY, sizeX, sizeY, id); + WS_CHILD | WS_VISIBLE | WS_BORDER | LVS_REPORT | LVS_EDITLABELS | WS_TABSTOP, pos_x, + pos_y, size_x, size_y, id); return child; } -std::unique_ptr Window::CreateGroupBox(int posX, int posY, int sizeX, int sizeY, - const char* title, int id) { +std::unique_ptr Window::CreateGroupBox(int pos_x, int pos_y, int size_x, + int size_y, const char* title, int id) { std::unique_ptr child(new Window(this, "Button", title)); - child->Create(WS_CHILD | WS_VISIBLE | BS_GROUPBOX, posX, posY, sizeX, sizeY, id); + child->Create(WS_CHILD | WS_VISIBLE | BS_GROUPBOX, pos_x, pos_y, size_x, size_y, id); return child; } -std::unique_ptr Window::CreateLabel(int posX, int posY, int sizeX, int sizeY, +std::unique_ptr Window::CreateLabel(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id) { std::unique_ptr child(new Window(this, "Static", title)); - child->Create(WS_CHILD | WS_VISIBLE, posX, posY, sizeX, sizeY, id); + child->Create(WS_CHILD | WS_VISIBLE, pos_x, pos_y, size_x, size_y, id); return child; } -std::unique_ptr Window::CreateEdit(int posX, int posY, int sizeX, int sizeY, +std::unique_ptr Window::CreateEdit(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id, int style) { std::unique_ptr child(new Window(this, "Edit", title)); child->Create(WS_CHILD | WS_VISIBLE | WS_BORDER | ES_AUTOHSCROLL | WS_TABSTOP | style, - posX, posY, sizeX, sizeY, id); + pos_x, pos_y, size_x, size_y, id); return child; } -std::unique_ptr Window::CreateButton(int posX, int posY, int sizeX, int sizeY, +std::unique_ptr Window::CreateButton(int pos_x, int pos_y, int size_x, int size_y, const char* title, int id, int style) { std::unique_ptr child(new Window(this, "Button", title)); - child->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | style, posX, posY, sizeX, sizeY, id); + child->Create(WS_CHILD | WS_VISIBLE | WS_TABSTOP | style, pos_x, pos_y, size_x, size_y, + id); return child; } -std::unique_ptr Window::CreateCheckBox(int posX, int posY, int sizeX, int sizeY, - const char* title, int id, bool state) { +std::unique_ptr Window::CreateCheckBox(int pos_x, int pos_y, int size_x, + int size_y, const char* title, int id, + bool state) { std::unique_ptr child(new Window(this, "Button", title)); - child->Create(WS_CHILD | WS_VISIBLE | BS_CHECKBOX | WS_TABSTOP, posX, posY, sizeX, - sizeY, id); + child->Create(WS_CHILD | WS_VISIBLE | BS_CHECKBOX | WS_TABSTOP, pos_x, pos_y, size_x, + size_y, id); child->SetChecked(state); return child; } -std::unique_ptr Window::CreateComboBox(int posX, int posY, int sizeX, int sizeY, - const char* title, int id) { +std::unique_ptr Window::CreateComboBox(int pos_x, int pos_y, int size_x, + int size_y, const char* title, int id) { std::unique_ptr child(new Window(this, "Combobox", title)); - child->Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_TABSTOP, posX, posY, sizeX, - sizeY, id); + child->Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST | WS_TABSTOP, pos_x, pos_y, + size_x, size_y, id); return child; } -void Window::Show() { ShowWindow(handle, SW_SHOW); } +void Window::Show() { ShowWindow(handle_, SW_SHOW); } -void Window::Update() { UpdateWindow(handle); } +void Window::Update() { UpdateWindow(handle_); } void Window::Destroy() { - if (handle) DestroyWindow(handle); + if (handle_) DestroyWindow(handle_); - handle = NULL; + handle_ = NULL; } -void Window::SetVisible(bool isVisible) { - ShowWindow(handle, isVisible ? SW_SHOW : SW_HIDE); +void Window::SetVisible(bool is_visible) { + ShowWindow(handle_, is_visible ? SW_SHOW : SW_HIDE); } bool Window::IsTextEmpty() const { if (!IsEnabled()) { return true; } - int len = GetWindowTextLength(handle); + int len = GetWindowTextLength(handle_); return (len <= 0); } @@ -202,7 +208,7 @@ void Window::ListAddColumn(const std::string& name, int index, int width) { lvc.pszText = const_cast(name.c_str()); lvc.iSubItem = index; - if (ListView_InsertColumn(handle, index, &lvc) == -1) { + if (ListView_InsertColumn(handle_, index, &lvc) == -1) { std::stringstream buf; buf << "Can not add list column, error code: " << GetLastError(); throw odbcabstraction::DriverException(buf.str()); @@ -214,7 +220,7 @@ void Window::ListAddItem(const std::vector& items) { lvi.mask = LVIF_TEXT; lvi.pszText = const_cast(items[0].c_str()); - int ret = ListView_InsertItem(handle, &lvi); + int ret = ListView_InsertItem(handle_, &lvi); if (ret < 0) { std::stringstream buf; buf << "Can not add list item, error code: " << GetLastError(); @@ -222,15 +228,15 @@ void Window::ListAddItem(const std::vector& items) { } for (size_t i = 1; i < items.size(); ++i) { - ListView_SetItemText(handle, ret, static_cast(i), + ListView_SetItemText(handle_, ret, static_cast(i), const_cast(items[i].c_str())); } } void Window::ListDeleteSelectedItem() { - const int rowIndex = ListView_GetSelectionMark(handle); - if (rowIndex >= 0) { - if (ListView_DeleteItem(handle, rowIndex) == -1) { + const int row_index = ListView_GetSelectionMark(handle_); + if (row_index >= 0) { + if (ListView_DeleteItem(handle_, row_index) == -1) { std::stringstream buf; buf << "Can not delete list item, error code: " << GetLastError(); throw odbcabstraction::DriverException(buf.str()); @@ -243,12 +249,12 @@ std::vector > Window::ListGetAll() { char buf[BUF_LEN]; std::vector > values; - const int numColumns = Header_GetItemCount(ListView_GetHeader(handle)); - const int numItems = ListView_GetItemCount(handle); - for (int i = 0; i < numItems; ++i) { + const int num_columns = Header_GetItemCount(ListView_GetHeader(handle_)); + const int num_items = ListView_GetItemCount(handle_); + for (int i = 0; i < num_items; ++i) { std::vector row; - for (int j = 0; j < numColumns; ++j) { - ListView_GetItemText(handle, i, j, buf, BUF_LEN); + for (int j = 0; j < num_columns; ++j) { + ListView_GetItemText(handle_, i, j, buf, BUF_LEN); row.emplace_back(buf); } values.push_back(row); @@ -258,11 +264,11 @@ std::vector > Window::ListGetAll() { } void Window::AddTab(const std::string& name, int index) { - TCITEM tabControlItem; - tabControlItem.mask = TCIF_TEXT | TCIF_IMAGE; - tabControlItem.iImage = -1; - tabControlItem.pszText = const_cast(name.c_str()); - if (TabCtrl_InsertItem(handle, index, &tabControlItem) == -1) { + TCITEM tab_control_item; + tab_control_item.mask = TCIF_TEXT | TCIF_IMAGE; + tab_control_item.iImage = -1; + tab_control_item.pszText = const_cast(name.c_str()); + if (TabCtrl_InsertItem(handle_, index, &tab_control_item) == -1) { std::stringstream buf; buf << "Can not add tab, error code: " << GetLastError(); throw odbcabstraction::DriverException(buf.str()); @@ -276,7 +282,7 @@ void Window::GetText(std::string& text) const { return; } - int len = GetWindowTextLength(handle); + int len = GetWindowTextLength(handle_); if (len <= 0) { text.clear(); @@ -286,34 +292,34 @@ void Window::GetText(std::string& text) const { text.resize(len + 1); - if (!GetWindowText(handle, &text[0], len + 1)) text.clear(); + if (!GetWindowText(handle_, &text[0], len + 1)) text.clear(); text.resize(len); boost::algorithm::trim(text); } void Window::SetText(const std::string& text) const { - SNDMSG(handle, WM_SETTEXT, 0, reinterpret_cast(text.c_str())); + SNDMSG(handle_, WM_SETTEXT, 0, reinterpret_cast(text.c_str())); } bool Window::IsChecked() const { - return IsEnabled() && Button_GetCheck(handle) == BST_CHECKED; + return IsEnabled() && Button_GetCheck(handle_) == BST_CHECKED; } void Window::SetChecked(bool state) { - Button_SetCheck(handle, state ? BST_CHECKED : BST_UNCHECKED); + Button_SetCheck(handle_, state ? BST_CHECKED : BST_UNCHECKED); } void Window::AddString(const std::string& str) { - SNDMSG(handle, CB_ADDSTRING, 0, reinterpret_cast(str.c_str())); + SNDMSG(handle_, CB_ADDSTRING, 0, reinterpret_cast(str.c_str())); } void Window::SetSelection(int idx) { - SNDMSG(handle, CB_SETCURSEL, static_cast(idx), 0); + SNDMSG(handle_, CB_SETCURSEL, static_cast(idx), 0); } int Window::GetSelection() const { - return static_cast(SNDMSG(handle, CB_GETCURSEL, 0, 0)); + return static_cast(SNDMSG(handle_, CB_GETCURSEL, 0, 0)); } void Window::SetEnabled(bool enabled) { EnableWindow(GetHandle(), enabled); } diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.cc b/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.cc index 33a11aaabed56..49ee103fbdc12 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.cc +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.cc @@ -51,16 +51,17 @@ bool IsComplexType(arrow::Type::type type_id) { } } -odbcabstraction::SqlDataType GetDefaultSqlCharType(bool useWideChar) { - return useWideChar ? odbcabstraction::SqlDataType_WCHAR - : odbcabstraction::SqlDataType_CHAR; +odbcabstraction::SqlDataType GetDefaultSqlCharType(bool use_wide_char) { + return use_wide_char ? odbcabstraction::SqlDataType_WCHAR + : odbcabstraction::SqlDataType_CHAR; } -odbcabstraction::SqlDataType GetDefaultSqlVarcharType(bool useWideChar) { - return useWideChar ? odbcabstraction::SqlDataType_WVARCHAR - : odbcabstraction::SqlDataType_VARCHAR; +odbcabstraction::SqlDataType GetDefaultSqlVarcharType(bool use_wide_char) { + return use_wide_char ? odbcabstraction::SqlDataType_WVARCHAR + : odbcabstraction::SqlDataType_VARCHAR; } -odbcabstraction::CDataType GetDefaultCCharType(bool useWideChar) { - return useWideChar ? odbcabstraction::CDataType_WCHAR : odbcabstraction::CDataType_CHAR; +odbcabstraction::CDataType GetDefaultCCharType(bool use_wide_char) { + return use_wide_char ? odbcabstraction::CDataType_WCHAR + : odbcabstraction::CDataType_CHAR; } } // namespace @@ -79,8 +80,8 @@ using std::nullopt; /// \note use GetNonConciseDataType on the output to get the verbose type /// \note the concise and verbose types are the same for all but types relating to times /// and intervals -SqlDataType GetDataTypeFromArrowField_V3(const std::shared_ptr& field, - bool useWideChar) { +SqlDataType GetDataTypeFromArrowFieldV3(const std::shared_ptr& field, + bool use_wide_char) { const std::shared_ptr& type = field->type(); switch (type->id()) { @@ -109,7 +110,7 @@ SqlDataType GetDataTypeFromArrowField_V3(const std::shared_ptr& fi return odbcabstraction::SqlDataType_BINARY; case arrow::Type::STRING: case arrow::Type::LARGE_STRING: - return GetDefaultSqlVarcharType(useWideChar); + return GetDefaultSqlVarcharType(use_wide_char); case arrow::Type::DATE32: case arrow::Type::DATE64: return odbcabstraction::SqlDataType_TYPE_DATE; @@ -144,17 +145,17 @@ SqlDataType GetDataTypeFromArrowField_V3(const std::shared_ptr& fi break; } - return GetDefaultSqlVarcharType(useWideChar); + return GetDefaultSqlVarcharType(use_wide_char); } -SqlDataType EnsureRightSqlCharType(SqlDataType data_type, bool useWideChar) { +SqlDataType EnsureRightSqlCharType(SqlDataType data_type, bool use_wide_char) { switch (data_type) { case odbcabstraction::SqlDataType_CHAR: case odbcabstraction::SqlDataType_WCHAR: - return GetDefaultSqlCharType(useWideChar); + return GetDefaultSqlCharType(use_wide_char); case odbcabstraction::SqlDataType_VARCHAR: case odbcabstraction::SqlDataType_WVARCHAR: - return GetDefaultSqlVarcharType(useWideChar); + return GetDefaultSqlVarcharType(use_wide_char); default: return data_type; } @@ -857,10 +858,10 @@ arrow::Type::type ConvertCToArrowType(odbcabstraction::CDataType data_type) { } odbcabstraction::CDataType ConvertArrowTypeToC(arrow::Type::type type_id, - bool useWideChar) { + bool use_wide_char) { switch (type_id) { case arrow::Type::STRING: - return GetDefaultCCharType(useWideChar); + return GetDefaultCCharType(use_wide_char); case arrow::Type::INT16: return odbcabstraction::CDataType_SSHORT; case arrow::Type::UINT16: @@ -1110,14 +1111,14 @@ std::string ConvertToDBMSVer(const std::string& str) { return result; } -int32_t GetDecimalTypeScale(const std::shared_ptr& decimalType) { - auto decimal128Type = std::dynamic_pointer_cast(decimalType); - return decimal128Type->scale(); +int32_t GetDecimalTypeScale(const std::shared_ptr& decimal_type) { + auto decimal128_type = std::dynamic_pointer_cast(decimal_type); + return decimal128_type->scale(); } -int32_t GetDecimalTypePrecision(const std::shared_ptr& decimalType) { - auto decimal128Type = std::dynamic_pointer_cast(decimalType); - return decimal128Type->precision(); +int32_t GetDecimalTypePrecision(const std::shared_ptr& decimal_type) { + auto decimal128_type = std::dynamic_pointer_cast(decimal_type); + return decimal128_type->precision(); } } // namespace flight_sql diff --git a/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.h b/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.h index 586cfb22a3052..69e43727ce1b6 100644 --- a/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.h +++ b/cpp/src/arrow/flight/sql/odbc/flight_sql/utils.h @@ -58,11 +58,11 @@ arrow::Status AppendToBuilder(BUILDER& builder, T value) { return builder.Append(value); } -odbcabstraction::SqlDataType GetDataTypeFromArrowField_V3( - const std::shared_ptr& field, bool useWideChar); +odbcabstraction::SqlDataType GetDataTypeFromArrowFieldV3( + const std::shared_ptr& field, bool use_wide_char); odbcabstraction::SqlDataType EnsureRightSqlCharType( - odbcabstraction::SqlDataType data_type, bool useWideChar); + odbcabstraction::SqlDataType data_type, bool use_wide_char); int16_t ConvertSqlDataTypeFromV3ToV2(int16_t data_type_v3); @@ -107,7 +107,7 @@ std::shared_ptr GetDefaultDataTypeForTypeId(arrow::Type::type t arrow::Type::type ConvertCToArrowType(odbcabstraction::CDataType data_type); odbcabstraction::CDataType ConvertArrowTypeToC(arrow::Type::type type_id, - bool useWideChar); + bool use_wide_char); std::shared_ptr CheckConversion(const arrow::Result& result); @@ -116,9 +116,9 @@ ArrayConvertTask GetConverter(arrow::Type::type original_type_id, std::string ConvertToDBMSVer(const std::string& str); -int32_t GetDecimalTypeScale(const std::shared_ptr& decimalType); +int32_t GetDecimalTypeScale(const std::shared_ptr& decimal_type); -int32_t GetDecimalTypePrecision(const std::shared_ptr& decimalType); +int32_t GetDecimalTypePrecision(const std::shared_ptr& decimal_type); } // namespace flight_sql } // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/diagnostics.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/diagnostics.cc index 8c94978ef9977..37c95194fa014 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/diagnostics.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/diagnostics.cc @@ -52,7 +52,7 @@ void driver::odbcabstraction::Diagnostics::AddError( auto record = std::unique_ptr(new DiagnosticsRecord{ exception.GetMessageText(), exception.GetSqlState(), exception.GetNativeError()}); if (version_ == OdbcVersion::V_2) { - RewriteSQLStateForODBC2(record->sql_state_); + RewriteSQLStateForODBC2(record->sql_state); } TrackRecord(*record); owned_records_.push_back(std::move(record)); @@ -64,7 +64,7 @@ void driver::odbcabstraction::Diagnostics::AddWarning(std::string message, auto record = std::unique_ptr( new DiagnosticsRecord{std::move(message), std::move(sql_state), native_error}); if (version_ == OdbcVersion::V_2) { - RewriteSQLStateForODBC2(record->sql_state_); + RewriteSQLStateForODBC2(record->sql_state); } TrackRecord(*record); owned_records_.push_back(std::move(record)); @@ -78,7 +78,7 @@ std::string driver::odbcabstraction::Diagnostics::GetMessageText( } const DiagnosticsRecord* rec = GetRecordAtIndex(record_index); return message + "[" + data_source_component_ + "] (" + - std::to_string(rec->native_error_) + ") " + rec->msg_text_; + std::to_string(rec->native_error) + ") " + rec->msg_text; } OdbcVersion Diagnostics::GetOdbcVersion() const { return version_; } diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h index f1c6efe498294..131de3c1b087d 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/diagnostics.h @@ -29,9 +29,9 @@ namespace odbcabstraction { class Diagnostics { public: struct DiagnosticsRecord { - std::string msg_text_; - std::string sql_state_; - int32_t native_error_; + std::string msg_text; + std::string sql_state; + int32_t native_error; }; private: @@ -56,7 +56,7 @@ class Diagnostics { } inline void TrackRecord(const DiagnosticsRecord& record) { - if (record.sql_state_[0] == '0' && record.sql_state_[1] == '1') { + if (record.sql_state[0] == '0' && record.sql_state[1] == '1') { warning_records_.push_back(&record); } else { error_records_.push_back(&record); @@ -76,11 +76,11 @@ class Diagnostics { std::string GetMessageText(uint32_t record_index) const; std::string GetSQLState(uint32_t record_index) const { - return GetRecordAtIndex(record_index)->sql_state_; + return GetRecordAtIndex(record_index)->sql_state; } int32_t GetNativeError(uint32_t record_index) const { - return GetRecordAtIndex(record_index)->native_error_; + return GetRecordAtIndex(record_index)->native_error; } inline size_t GetRecordCount() const { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h index 9163e942cebdf..13d4492717a94 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/attribute_utils.h @@ -32,43 +32,44 @@ namespace ODBC { using driver::odbcabstraction::WcsToUtf8; template -inline void GetAttribute(T attributeValue, SQLPOINTER output, O outputSize, - O* outputLenPtr) { +inline void GetAttribute(T attribute_value, SQLPOINTER output, O output_size, + O* output_len_ptr) { if (output) { - T* typedOutput = reinterpret_cast(output); - *typedOutput = attributeValue; + T* typed_output = reinterpret_cast(output); + *typed_output = attribute_value; } - if (outputLenPtr) { - *outputLenPtr = sizeof(T); + if (output_len_ptr) { + *output_len_ptr = sizeof(T); } } template -inline SQLRETURN GetAttributeUTF8(const std::string& attributeValue, SQLPOINTER output, - O outputSize, O* outputLenPtr) { +inline SQLRETURN GetAttributeUTF8(const std::string& attribute_value, SQLPOINTER output, + O output_size, O* output_len_ptr) { if (output) { - size_t outputLenBeforeNul = - std::min(static_cast(attributeValue.size()), static_cast(outputSize - 1)); - memcpy(output, attributeValue.c_str(), outputLenBeforeNul); - reinterpret_cast(output)[outputLenBeforeNul] = '\0'; + size_t output_len_before_null = + std::min(static_cast(attribute_value.size()), static_cast(output_size - 1)); + memcpy(output, attribute_value.c_str(), output_len_before_null); + reinterpret_cast(output)[output_len_before_null] = '\0'; } - if (outputLenPtr) { - *outputLenPtr = static_cast(attributeValue.size()); + if (output_len_ptr) { + *output_len_ptr = static_cast(attribute_value.size()); } - if (output && outputSize < static_cast(attributeValue.size() + 1)) { + if (output && output_size < static_cast(attribute_value.size() + 1)) { return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; } template -inline SQLRETURN GetAttributeUTF8(const std::string& attributeValue, SQLPOINTER output, - O outputSize, O* outputLenPtr, +inline SQLRETURN GetAttributeUTF8(const std::string& attribute_value, SQLPOINTER output, + O output_size, O* output_len_ptr, driver::odbcabstraction::Diagnostics& diagnostics) { - SQLRETURN result = GetAttributeUTF8(attributeValue, output, outputSize, outputLenPtr); + SQLRETURN result = + GetAttributeUTF8(attribute_value, output, output_size, output_len_ptr); if (SQL_SUCCESS_WITH_INFO == result) { diagnostics.AddTruncationWarning(); } @@ -76,31 +77,33 @@ inline SQLRETURN GetAttributeUTF8(const std::string& attributeValue, SQLPOINTER } template -inline SQLRETURN GetAttributeSQLWCHAR(const std::string& attributeValue, - bool isLengthInBytes, SQLPOINTER output, - O outputSize, O* outputLenPtr) { - size_t result = - ConvertToSqlWChar(attributeValue, reinterpret_cast(output), - isLengthInBytes ? outputSize : outputSize * GetSqlWCharSize()); - - if (outputLenPtr) { - *outputLenPtr = static_cast(isLengthInBytes ? result : result / GetSqlWCharSize()); +inline SQLRETURN GetAttributeSQLWCHAR(const std::string& attribute_value, + bool is_length_in_bytes, SQLPOINTER output, + O output_size, O* output_len_ptr) { + size_t result = ConvertToSqlWChar( + attribute_value, reinterpret_cast(output), + is_length_in_bytes ? output_size : output_size * GetSqlWCharSize()); + + if (output_len_ptr) { + *output_len_ptr = + static_cast(is_length_in_bytes ? result : result / GetSqlWCharSize()); } if (output && - outputSize < static_cast(result + (isLengthInBytes ? GetSqlWCharSize() : 1))) { + output_size < + static_cast(result + (is_length_in_bytes ? GetSqlWCharSize() : 1))) { return SQL_SUCCESS_WITH_INFO; } return SQL_SUCCESS; } template -inline SQLRETURN GetAttributeSQLWCHAR(const std::string& attributeValue, - bool isLengthInBytes, SQLPOINTER output, - O outputSize, O* outputLenPtr, +inline SQLRETURN GetAttributeSQLWCHAR(const std::string& attribute_value, + bool is_length_in_bytes, SQLPOINTER output, + O output_size, O* output_len_ptr, driver::odbcabstraction::Diagnostics& diagnostics) { - SQLRETURN result = GetAttributeSQLWCHAR(attributeValue, isLengthInBytes, output, - outputSize, outputLenPtr); + SQLRETURN result = GetAttributeSQLWCHAR(attribute_value, is_length_in_bytes, output, + output_size, output_len_ptr); if (SQL_SUCCESS_WITH_INFO == result) { diagnostics.AddTruncationWarning(); } @@ -108,16 +111,16 @@ inline SQLRETURN GetAttributeSQLWCHAR(const std::string& attributeValue, } template -inline SQLRETURN GetStringAttribute(bool isUnicode, const std::string& attributeValue, - bool isLengthInBytes, SQLPOINTER output, O outputSize, - O* outputLenPtr, +inline SQLRETURN GetStringAttribute(bool is_unicode, const std::string& attribute_value, + bool is_length_in_bytes, SQLPOINTER output, + O output_size, O* output_len_ptr, driver::odbcabstraction::Diagnostics& diagnostics) { SQLRETURN result = SQL_SUCCESS; - if (isUnicode) { - result = GetAttributeSQLWCHAR(attributeValue, isLengthInBytes, output, outputSize, - outputLenPtr); + if (is_unicode) { + result = GetAttributeSQLWCHAR(attribute_value, is_length_in_bytes, output, + output_size, output_len_ptr); } else { - result = GetAttributeUTF8(attributeValue, output, outputSize, outputLenPtr); + result = GetAttributeUTF8(attribute_value, output, output_size, output_len_ptr); } if (SQL_SUCCESS_WITH_INFO == result) { @@ -127,32 +130,33 @@ inline SQLRETURN GetStringAttribute(bool isUnicode, const std::string& attribute } template -inline void SetAttribute(SQLPOINTER newValue, T& attributeToWrite) { - SQLLEN valueAsLen = reinterpret_cast(newValue); - attributeToWrite = static_cast(valueAsLen); +inline void SetAttribute(SQLPOINTER new_value, T& attribute_to_write) { + SQLLEN valueAsLen = reinterpret_cast(new_value); + attribute_to_write = static_cast(valueAsLen); } template -inline void SetPointerAttribute(SQLPOINTER newValue, T& attributeToWrite) { - attributeToWrite = static_cast(newValue); +inline void SetPointerAttribute(SQLPOINTER new_value, T& attribute_to_write) { + attribute_to_write = static_cast(new_value); } -inline void SetAttributeUTF8(SQLPOINTER newValue, SQLINTEGER inputLength, - std::string& attributeToWrite) { - const char* newValueAsChar = static_cast(newValue); - attributeToWrite.assign(newValueAsChar, - inputLength == SQL_NTS ? strlen(newValueAsChar) : inputLength); +inline void SetAttributeUTF8(SQLPOINTER new_value, SQLINTEGER input_length, + std::string& attribute_to_write) { + const char* new_value_as_char = static_cast(new_value); + attribute_to_write.assign(new_value_as_char, input_length == SQL_NTS + ? strlen(new_value_as_char) + : input_length); } -inline void SetAttributeSQLWCHAR(SQLPOINTER newValue, SQLINTEGER inputLengthInBytes, - std::string& attributeToWrite) { +inline void SetAttributeSQLWCHAR(SQLPOINTER new_value, SQLINTEGER input_length_in_bytes, + std::string& attribute_to_write) { thread_local std::vector utf8_str; - if (inputLengthInBytes == SQL_NTS) { - WcsToUtf8(newValue, &utf8_str); + if (input_length_in_bytes == SQL_NTS) { + WcsToUtf8(new_value, &utf8_str); } else { - WcsToUtf8(newValue, inputLengthInBytes / GetSqlWCharSize(), &utf8_str); + WcsToUtf8(new_value, input_length_in_bytes / GetSqlWCharSize(), &utf8_str); } - attributeToWrite.assign((char*)utf8_str.data()); + attribute_to_write.assign((char*)utf8_str.data()); } template diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h index 25619bb55551a..ae1ce3568bfb1 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/encoding_utils.h @@ -38,38 +38,39 @@ using driver::odbcabstraction::Utf8ToWcs; // Return the number of bytes required for the conversion. template inline size_t ConvertToSqlWChar(const std::string& str, SQLWCHAR* buffer, - SQLLEN bufferSizeInBytes) { + SQLLEN buffer_size_in_bytes) { thread_local std::vector wstr; Utf8ToWcs(str.data(), str.size(), &wstr); - SQLLEN valueLengthInBytes = wstr.size(); + SQLLEN value_length_in_bytes = wstr.size(); if (buffer) { memcpy(buffer, wstr.data(), - std::min(static_cast(wstr.size()), bufferSizeInBytes)); + std::min(static_cast(wstr.size()), buffer_size_in_bytes)); // Write a NUL terminator - if (bufferSizeInBytes >= - valueLengthInBytes + static_cast(GetSqlWCharSize())) { - reinterpret_cast(buffer)[valueLengthInBytes / GetSqlWCharSize()] = '\0'; + if (buffer_size_in_bytes >= + value_length_in_bytes + static_cast(GetSqlWCharSize())) { + reinterpret_cast(buffer)[value_length_in_bytes / GetSqlWCharSize()] = + '\0'; } else { - SQLLEN numCharsWritten = bufferSizeInBytes / GetSqlWCharSize(); + SQLLEN num_chars_written = buffer_size_in_bytes / GetSqlWCharSize(); // If we failed to even write one char, the buffer is too small to hold a // NUL-terminator. - if (numCharsWritten > 0) { - reinterpret_cast(buffer)[numCharsWritten - 1] = '\0'; + if (num_chars_written > 0) { + reinterpret_cast(buffer)[num_chars_written - 1] = '\0'; } } } - return valueLengthInBytes; + return value_length_in_bytes; } inline size_t ConvertToSqlWChar(const std::string& str, SQLWCHAR* buffer, - SQLLEN bufferSizeInBytes) { + SQLLEN buffer_size_in_bytes) { switch (GetSqlWCharSize()) { case sizeof(char16_t): - return ConvertToSqlWChar(str, buffer, bufferSizeInBytes); + return ConvertToSqlWChar(str, buffer, buffer_size_in_bytes); case sizeof(char32_t): - return ConvertToSqlWChar(str, buffer, bufferSizeInBytes); + return ConvertToSqlWChar(str, buffer, buffer_size_in_bytes); default: assert(false); throw DriverException("Encoding is unsupported, SQLWCHAR size: " + diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h index 6a01fe128d90b..6d46f3b2232b5 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_connection.h @@ -42,56 +42,56 @@ class ODBCConnection : public ODBCHandle { ODBCConnection& operator=(const ODBCConnection&) = delete; ODBCConnection(ODBCEnvironment& environment, - std::shared_ptr spiConnection); + std::shared_ptr spi_connection); - driver::odbcabstraction::Diagnostics& GetDiagnostics_Impl(); + driver::odbcabstraction::Diagnostics& GetDiagnosticsImpl(); const std::string& GetDSN() const; - bool isConnected() const; - void connect(std::string dsn, + bool IsConnected() const; + void Connect(std::string dsn, const driver::odbcabstraction::Connection::ConnPropertyMap& properties, std::vector& missing_properties); - void GetInfo(SQLUSMALLINT infoType, SQLPOINTER value, SQLSMALLINT bufferLength, - SQLSMALLINT* outputLength, bool isUnicode); - void SetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER stringLength, + void GetInfo(SQLUSMALLINT info_type, SQLPOINTER value, SQLSMALLINT buffer_length, + SQLSMALLINT* output_length, bool is_unicode); + void SetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER string_length, bool isUnicode); - void GetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER bufferLength, - SQLINTEGER* outputLength, bool isUnicode); + void GetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, SQLINTEGER buffer_length, + SQLINTEGER* output_length, bool is_unicode); ~ODBCConnection() = default; - inline ODBCStatement& GetTrackingStatement() { return *m_attributeTrackingStatement; } + inline ODBCStatement& GetTrackingStatement() { return *attribute_tracking_statement_; } - void disconnect(); + void Disconnect(); - void releaseConnection(); + void ReleaseConnection(); - std::shared_ptr createStatement(); - void dropStatement(ODBCStatement* statement); + std::shared_ptr CreateStatement(); + void DropStatement(ODBCStatement* statement); - std::shared_ptr createDescriptor(); - void dropDescriptor(ODBCDescriptor* descriptor); + std::shared_ptr CreateDescriptor(); + void DropDescriptor(ODBCDescriptor* descriptor); - inline bool IsOdbc2Connection() const { return m_is2xConnection; } + inline bool IsOdbc2Connection() const { return is_2x_connection_; } /// @return the DSN or empty string if Driver was used. - static std::string getPropertiesFromConnString( - const std::string& connStr, + static std::string GetPropertiesFromConnString( + const std::string& conn_str, driver::odbcabstraction::Connection::ConnPropertyMap& properties); private: - ODBCEnvironment& m_environment; - std::shared_ptr m_spiConnection; + ODBCEnvironment& environment_; + std::shared_ptr spi_connection_; // Extra ODBC statement that's used to track and validate when statement attributes are // set through the connection handle. These attributes get copied to new ODBC statements // when they are allocated. - std::shared_ptr m_attributeTrackingStatement; - std::vector > m_statements; - std::vector > m_descriptors; - std::string m_dsn; - const bool m_is2xConnection; - bool m_isConnected; + std::shared_ptr attribute_tracking_statement_; + std::vector > statements_; + std::vector > descriptors_; + std::string dsn_; + const bool is_2x_connection_; + bool is_connected_; }; } // namespace ODBC diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h index 092483f471994..1c45eb4073d8e 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_descriptor.h @@ -38,40 +38,40 @@ class ODBCStatement; namespace ODBC { struct DescriptorRecord { - std::string m_baseColumnName; - std::string m_baseTableName; - std::string m_catalogName; - std::string m_label; - std::string m_literalPrefix; - std::string m_literalSuffix; - std::string m_localTypeName; - std::string m_name; - std::string m_schemaName; - std::string m_tableName; - std::string m_typeName; - SQLPOINTER m_dataPtr = NULL; - SQLLEN* m_indicatorPtr = NULL; - SQLLEN m_displaySize = 0; - SQLLEN m_octetLength = 0; - SQLULEN m_length = 0; - SQLINTEGER m_autoUniqueValue; - SQLINTEGER m_caseSensitive = SQL_TRUE; - SQLINTEGER m_datetimeIntervalPrecision = 0; - SQLINTEGER m_numPrecRadix = 0; - SQLSMALLINT m_conciseType = SQL_C_DEFAULT; - SQLSMALLINT m_datetimeIntervalCode = 0; - SQLSMALLINT m_fixedPrecScale = 0; - SQLSMALLINT m_nullable = SQL_NULLABLE_UNKNOWN; - SQLSMALLINT m_paramType = SQL_PARAM_INPUT; - SQLSMALLINT m_precision = 0; - SQLSMALLINT m_rowVer = 0; - SQLSMALLINT m_scale = 0; - SQLSMALLINT m_searchable = SQL_SEARCHABLE; - SQLSMALLINT m_type = SQL_C_DEFAULT; - SQLSMALLINT m_unnamed = SQL_TRUE; - SQLSMALLINT m_unsigned = SQL_FALSE; - SQLSMALLINT m_updatable = SQL_FALSE; - bool m_isBound = false; + std::string base_column_name; + std::string base_table_name; + std::string catalog_name; + std::string label; + std::string literal_prefix; + std::string literal_suffix; + std::string local_type_name; + std::string name; + std::string schema_name; + std::string table_name; + std::string type_name; + SQLPOINTER data_ptr = NULL; + SQLLEN* indicator_ptr = NULL; + SQLLEN display_size = 0; + SQLLEN octet_length = 0; + SQLULEN length = 0; + SQLINTEGER auto_unique_value; + SQLINTEGER case_sensitive = SQL_TRUE; + SQLINTEGER datetime_interval_precision = 0; + SQLINTEGER num_prec_radix = 0; + SQLSMALLINT concise_type = SQL_C_DEFAULT; + SQLSMALLINT datetime_interval_code = 0; + SQLSMALLINT fixed_prec_scale = 0; + SQLSMALLINT nullable = SQL_NULLABLE_UNKNOWN; + SQLSMALLINT param_type = SQL_PARAM_INPUT; + SQLSMALLINT precision = 0; + SQLSMALLINT row_ver = 0; + SQLSMALLINT scale = 0; + SQLSMALLINT searchable = SQL_SEARCHABLE; + SQLSMALLINT type = SQL_C_DEFAULT; + SQLSMALLINT unnamed = SQL_TRUE; + SQLSMALLINT is_unsigned = SQL_FALSE; + SQLSMALLINT updatable = SQL_FALSE; + bool is_bound = false; void CheckConsistency(); }; @@ -81,29 +81,29 @@ class ODBCDescriptor : public ODBCHandle { /// \brief Construct a new ODBCDescriptor object. Link the descriptor to a connection, /// if applicable. A nullptr should be supplied for conn if the descriptor should not be /// linked. - ODBCDescriptor(driver::odbcabstraction::Diagnostics& baseDiagnostics, - ODBCConnection* conn, ODBCStatement* stmt, bool isAppDescriptor, - bool isWritable, bool is2xConnection); + ODBCDescriptor(driver::odbcabstraction::Diagnostics& base_diagnostics, + ODBCConnection* conn, ODBCStatement* stmt, bool is_app_descriptor, + bool is_writable, bool is_2x_connection); - driver::odbcabstraction::Diagnostics& GetDiagnostics_Impl(); + driver::odbcabstraction::Diagnostics& GetDiagnosticsImpl(); ODBCConnection& GetConnection(); - void SetHeaderField(SQLSMALLINT fieldIdentifier, SQLPOINTER value, - SQLINTEGER bufferLength); - void SetField(SQLSMALLINT recordNumber, SQLSMALLINT fieldIdentifier, SQLPOINTER value, - SQLINTEGER bufferLength); - void GetHeaderField(SQLSMALLINT fieldIdentifier, SQLPOINTER value, - SQLINTEGER bufferLength, SQLINTEGER* outputLength) const; - void GetField(SQLSMALLINT recordNumber, SQLSMALLINT fieldIdentifier, SQLPOINTER value, - SQLINTEGER bufferLength, SQLINTEGER* outputLength); - SQLSMALLINT getAllocType() const; + void SetHeaderField(SQLSMALLINT field_identifier, SQLPOINTER value, + SQLINTEGER buffer_length); + void SetField(SQLSMALLINT record_number, SQLSMALLINT field_identifier, SQLPOINTER value, + SQLINTEGER buffer_length); + void GetHeaderField(SQLSMALLINT field_identifier, SQLPOINTER value, + SQLINTEGER buffer_length, SQLINTEGER* output_length) const; + void GetField(SQLSMALLINT record_number, SQLSMALLINT field_identifier, SQLPOINTER value, + SQLINTEGER buffer_length, SQLINTEGER* output_length); + SQLSMALLINT GetAllocType() const; bool IsAppDescriptor() const; - inline bool HaveBindingsChanged() const { return m_hasBindingsChanged; } + inline bool HaveBindingsChanged() const { return has_bindings_changed_; } - void RegisterToStatement(ODBCStatement* statement, bool isApd); - void DetachFromStatement(ODBCStatement* statement, bool isApd); + void RegisterToStatement(ODBCStatement* statement, bool is_apd); + void DetachFromStatement(ODBCStatement* statement, bool is_apd); void ReleaseDescriptor(); void PopulateFromResultSetMetadata(driver::odbcabstraction::ResultSetMetadata* rsmd); @@ -111,49 +111,49 @@ class ODBCDescriptor : public ODBCHandle { const std::vector& GetRecords() const; std::vector& GetRecords(); - void BindCol(SQLSMALLINT recordNumber, SQLSMALLINT cType, SQLPOINTER dataPtr, - SQLLEN bufferLength, SQLLEN* indicatorPtr); - void SetDataPtrOnRecord(SQLPOINTER dataPtr, SQLSMALLINT recNumber); + void BindCol(SQLSMALLINT record_number, SQLSMALLINT c_type, SQLPOINTER data_ptr, + SQLLEN buffer_length, SQLLEN* indicator_ptr); + void SetDataPtrOnRecord(SQLPOINTER data_ptr, SQLSMALLINT rec_number); - inline SQLULEN GetBindOffset() { return m_bindOffsetPtr ? *m_bindOffsetPtr : 0UL; } + inline SQLULEN GetBindOffset() { return bind_offset_ptr_ ? *bind_offset_ptr_ : 0UL; } inline SQLULEN GetBoundStructOffset() { - // If this is SQL_BIND_BY_COLUMN, m_bindType is zero which indicates no offset due to + // If this is SQL_BIND_BY_COLUMN, bind_type_ is zero which indicates no offset due to // use of a bound struct. If this is non-zero, row-wise binding is being used so the // app should set this to sizeof(their struct). - return m_bindType; + return bind_type_; } - inline SQLULEN GetArraySize() { return m_arraySize; } + inline SQLULEN GetArraySize() { return array_size_; } - inline SQLUSMALLINT* GetArrayStatusPtr() { return m_arrayStatusPtr; } + inline SQLUSMALLINT* GetArrayStatusPtr() { return array_status_ptr_; } inline void SetRowsProcessed(SQLULEN rows) { - if (m_rowsProccessedPtr) { - *m_rowsProccessedPtr = rows; + if (rows_processed_ptr_) { + *rows_processed_ptr_ = rows; } } - inline void NotifyBindingsHavePropagated() { m_hasBindingsChanged = false; } + inline void NotifyBindingsHavePropagated() { has_bindings_changed_ = false; } - inline void NotifyBindingsHaveChanged() { m_hasBindingsChanged = true; } + inline void NotifyBindingsHaveChanged() { has_bindings_changed_ = true; } private: - driver::odbcabstraction::Diagnostics m_diagnostics; - std::vector m_registeredOnStatementsAsApd; - std::vector m_registeredOnStatementsAsArd; - std::vector m_records; - ODBCConnection* m_owningConnection; - ODBCStatement* m_parentStatement; - SQLUSMALLINT* m_arrayStatusPtr; - SQLULEN* m_bindOffsetPtr; - SQLULEN* m_rowsProccessedPtr; - SQLULEN m_arraySize; - SQLINTEGER m_bindType; - SQLSMALLINT m_highestOneBasedBoundRecord; - const bool m_is2xConnection; - bool m_isAppDescriptor; - bool m_isWritable; - bool m_hasBindingsChanged; + driver::odbcabstraction::Diagnostics diagnostics_; + std::vector registered_on_statements_as_apd_; + std::vector registered_on_statements_as_ard_; + std::vector records_; + ODBCConnection* owning_connection_; + ODBCStatement* parent_statement_; + SQLUSMALLINT* array_status_ptr_; + SQLULEN* bind_offset_ptr_; + SQLULEN* rows_processed_ptr_; + SQLULEN array_size_; + SQLINTEGER bind_type_; + SQLSMALLINT highest_one_based_bound_record_; + const bool is_2x_connection_; + bool is_app_descriptor_; + bool is_writable_; + bool has_bindings_changed_; }; } // namespace ODBC diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h index 584b186d0f998..a77e742a7a01e 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_environment.h @@ -40,21 +40,21 @@ namespace ODBC { class ODBCEnvironment : public ODBCHandle { public: explicit ODBCEnvironment(std::shared_ptr driver); - driver::odbcabstraction::Diagnostics& GetDiagnostics_Impl(); - SQLINTEGER getODBCVersion() const; - void setODBCVersion(SQLINTEGER version); - SQLINTEGER getConnectionPooling() const; - void setConnectionPooling(SQLINTEGER pooling); + driver::odbcabstraction::Diagnostics& GetDiagnosticsImpl(); + SQLINTEGER GetODBCVersion() const; + void SetODBCVersion(SQLINTEGER version); + SQLINTEGER GetConnectionPooling() const; + void SetConnectionPooling(SQLINTEGER pooling); std::shared_ptr CreateConnection(); void DropConnection(ODBCConnection* conn); ~ODBCEnvironment() = default; private: - std::vector > m_connections; - std::shared_ptr m_driver; - std::unique_ptr m_diagnostics; - SQLINTEGER m_version; - SQLINTEGER m_connectionPooling; + std::vector > connections_; + std::shared_ptr driver_; + std::unique_ptr diagnostics_; + SQLINTEGER version_; + SQLINTEGER connection_pooling_; }; } // namespace ODBC diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h index c2428df394d9a..355d950502eba 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_handle.h @@ -33,15 +33,15 @@ template class ODBCHandle { public: inline driver::odbcabstraction::Diagnostics& GetDiagnostics() { - return static_cast(this)->GetDiagnostics_Impl(); + return static_cast(this)->GetDiagnosticsImpl(); } - inline driver::odbcabstraction::Diagnostics& GetDiagnostics_Impl() { + inline driver::odbcabstraction::Diagnostics& GetDiagnosticsImpl() { throw std::runtime_error("Illegal state -- diagnostics requested on invalid handle"); } template - inline SQLRETURN execute(SQLRETURN rc, Function function) { + inline SQLRETURN Execute(SQLRETURN rc, Function function) { try { GetDiagnostics().Clear(); rc = function(); @@ -67,9 +67,9 @@ class ODBCHandle { } template - inline SQLRETURN executeWithLock(SQLRETURN rc, Function function) { + inline SQLRETURN ExecuteWithLock(SQLRETURN rc, Function function) { const std::lock_guard lock(mtx_); - return execute(rc, function); + return Execute(rc, function); } template @@ -79,13 +79,13 @@ class ODBCHandle { return SQL_INVALID_HANDLE; } if (SHOULD_LOCK) { - return reinterpret_cast(handle)->executeWithLock(rc, func); + return reinterpret_cast(handle)->ExecuteWithLock(rc, func); } else { - return reinterpret_cast(handle)->execute(rc, func); + return reinterpret_cast(handle)->Execute(rc, func); } } - static Derived* of(SQLHANDLE handle) { return reinterpret_cast(handle); } + static Derived* Of(SQLHANDLE handle) { return reinterpret_cast(handle); } private: std::mutex mtx_; diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h index bbddfac4185a5..aca0ce8b955a4 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/odbc_statement.h @@ -47,12 +47,12 @@ class ODBCStatement : public ODBCHandle { ODBCStatement& operator=(const ODBCStatement&) = delete; ODBCStatement(ODBCConnection& connection, - std::shared_ptr spiStatement); + std::shared_ptr spi_statement); ~ODBCStatement() = default; - inline driver::odbcabstraction::Diagnostics& GetDiagnostics_Impl() { - return *m_diagnostics; + inline driver::odbcabstraction::Diagnostics& GetDiagnosticsImpl() { + return *diagnostics_; } ODBCConnection& GetConnection(); @@ -66,58 +66,58 @@ class ODBCStatement : public ODBCHandle { * @brief Returns true if the number of rows fetch was greater than zero. */ bool Fetch(size_t rows); - bool isPrepared() const; + bool IsPrepared() const; - void GetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER output, - SQLINTEGER bufferSize, SQLINTEGER* strLenPtr, bool isUnicode); - void SetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER value, SQLINTEGER bufferSize, - bool isUnicode); + void GetStmtAttr(SQLINTEGER statement_attribute, SQLPOINTER output, + SQLINTEGER buffer_size, SQLINTEGER* str_len_ptr, bool is_unicode); + void SetStmtAttr(SQLINTEGER statement_attribute, SQLPOINTER value, + SQLINTEGER buffer_size, bool is_unicode); - void RevertAppDescriptor(bool isApd); + void RevertAppDescriptor(bool is_apd); - inline ODBCDescriptor* GetIRD() { return m_ird.get(); } + inline ODBCDescriptor* GetIRD() { return ird_.get(); } - inline ODBCDescriptor* GetARD() { return m_currentArd; } + inline ODBCDescriptor* GetARD() { return current_ard_; } - inline SQLULEN GetRowsetSize() { return m_rowsetSize; } + inline SQLULEN GetRowsetSize() { return rowset_size_; } - bool GetData(SQLSMALLINT recordNumber, SQLSMALLINT cType, SQLPOINTER dataPtr, - SQLLEN bufferLength, SQLLEN* indicatorPtr); + bool GetData(SQLSMALLINT record_number, SQLSMALLINT c_type, SQLPOINTER data_ptr, + SQLLEN buffer_length, SQLLEN* indicator_ptr); /** * @brief Closes the cursor. This does _not_ un-prepare the statement or change * bindings. */ - void closeCursor(bool suppressErrors); + void CloseCursor(bool suppress_errors); /** * @brief Releases this statement from memory. */ - void releaseStatement(); + void ReleaseStatement(); void GetTables(const std::string* catalog, const std::string* schema, - const std::string* table, const std::string* tableType); + const std::string* table, const std::string* table_type); void GetColumns(const std::string* catalog, const std::string* schema, const std::string* table, const std::string* column); - void GetTypeInfo(SQLSMALLINT dataType); + void GetTypeInfo(SQLSMALLINT data_type); void Cancel(); private: - ODBCConnection& m_connection; - std::shared_ptr m_spiStatement; - std::shared_ptr m_currenResult; - driver::odbcabstraction::Diagnostics* m_diagnostics; - - std::shared_ptr m_builtInArd; - std::shared_ptr m_builtInApd; - std::shared_ptr m_ipd; - std::shared_ptr m_ird; - ODBCDescriptor* m_currentArd; - ODBCDescriptor* m_currentApd; - SQLULEN m_rowNumber; - SQLULEN m_maxRows; - SQLULEN m_rowsetSize; // Used by SQLExtendedFetch instead of the ARD array size. - bool m_isPrepared; - bool m_hasReachedEndOfResult; + ODBCConnection& connection_; + std::shared_ptr spi_statement_; + std::shared_ptr current_result_; + driver::odbcabstraction::Diagnostics* diagnostics_; + + std::shared_ptr built_in_ard_; + std::shared_ptr built_in_apd_; + std::shared_ptr ipd_; + std::shared_ptr ird_; + ODBCDescriptor* current_ard_; + ODBCDescriptor* current_apd_; + SQLULEN row_number_; + SQLULEN max_rows_; + SQLULEN rowset_size_; // Used by SQLExtendedFetch instead of the ARD array size. + bool is_prepared_; + bool has_reached_end_of_result_; }; } // namespace ODBC diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/type_utilities.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/type_utilities.h index eee97d7f5627d..dc14d5823205f 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/type_utilities.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/odbc_impl/type_utilities.h @@ -21,19 +21,19 @@ #include namespace ODBC { -inline SQLSMALLINT GetSqlTypeForODBCVersion(SQLSMALLINT type, bool isOdbc2x) { +inline SQLSMALLINT GetSqlTypeForODBCVersion(SQLSMALLINT type, bool is_odbc_2x) { switch (type) { case SQL_DATE: case SQL_TYPE_DATE: - return isOdbc2x ? SQL_DATE : SQL_TYPE_DATE; + return is_odbc_2x ? SQL_DATE : SQL_TYPE_DATE; case SQL_TIME: case SQL_TYPE_TIME: - return isOdbc2x ? SQL_TIME : SQL_TYPE_TIME; + return is_odbc_2x ? SQL_TIME : SQL_TYPE_TIME; case SQL_TIMESTAMP: case SQL_TYPE_TIMESTAMP: - return isOdbc2x ? SQL_TIMESTAMP : SQL_TYPE_TIMESTAMP; + return is_odbc_2x ? SQL_TIMESTAMP : SQL_TYPE_TIMESTAMP; default: return type; diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h index e5d206a2ca7c2..cecc1bee9a201 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/types.h @@ -172,9 +172,9 @@ enum RowStatus : uint16_t { }; struct MetadataSettings { - boost::optional string_column_length_{boost::none}; - size_t chunk_buffer_capacity_; - bool use_wide_char_; + boost::optional string_column_length{boost::none}; + size_t chunk_buffer_capacity; + bool use_wide_char; }; } // namespace odbcabstraction diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h index 5e541a1d45fc6..c2c4d020edc0a 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/include/odbcabstraction/utils.h @@ -32,22 +32,22 @@ boost::optional AsBool(const std::string& value); /// Looks up for a value inside the ConnPropertyMap and then try to parse it. /// In case it does not find or it cannot parse, the default value will be returned. -/// \param connPropertyMap the map with the connection properties. +/// \param conn_property_map the map with the connection properties. /// \param property_name the name of the property that will be looked up. /// \return the parsed valued. -boost::optional AsBool(const Connection::ConnPropertyMap& connPropertyMap, +boost::optional AsBool(const Connection::ConnPropertyMap& conn_property_map, const std::string_view& property_name); /// Looks up for a value inside the ConnPropertyMap and then try to parse it. /// In case it does not find or it cannot parse, the default value will be returned. /// \param min_value the minimum value to be parsed, else the default -/// value is returned. \param connPropertyMap the map with the connection +/// value is returned. \param conn_property_map the map with the connection /// properties. \param property_name the name of the property that will be /// looked up. \return the parsed valued. \exception /// std::invalid_argument exception from std::stoi \exception /// std::out_of_range exception from std::stoi boost::optional AsInt32(int32_t min_value, - const Connection::ConnPropertyMap& connPropertyMap, + const Connection::ConnPropertyMap& conn_property_map, const std::string_view& property_name); } // namespace odbcabstraction } // namespace driver diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_connection.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_connection.cc index 0143976bb4881..95dc230f3b680 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_connection.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_connection.cc @@ -103,179 +103,179 @@ void loadPropertiesFromDSN(const std::string& dsn, // Public // ========================================================================================= ODBCConnection::ODBCConnection(ODBCEnvironment& environment, - std::shared_ptr spiConnection) - : m_environment(environment), - m_spiConnection(std::move(spiConnection)), - m_is2xConnection(environment.getODBCVersion() == SQL_OV_ODBC2), - m_isConnected(false) {} - -Diagnostics& ODBCConnection::GetDiagnostics_Impl() { - return m_spiConnection->GetDiagnostics(); + std::shared_ptr spi_connection) + : environment_(environment), + spi_connection_(std::move(spi_connection)), + is_2x_connection_(environment.GetODBCVersion() == SQL_OV_ODBC2), + is_connected_(false) {} + +Diagnostics& ODBCConnection::GetDiagnosticsImpl() { + return spi_connection_->GetDiagnostics(); } -bool ODBCConnection::isConnected() const { return m_isConnected; } +bool ODBCConnection::IsConnected() const { return is_connected_; } -const std::string& ODBCConnection::GetDSN() const { return m_dsn; } +const std::string& ODBCConnection::GetDSN() const { return dsn_; } -void ODBCConnection::connect(std::string dsn, +void ODBCConnection::Connect(std::string dsn, const Connection::ConnPropertyMap& properties, std::vector& missing_properties) { - if (m_isConnected) { + if (is_connected_) { throw DriverException("Already connected.", "HY010"); } - m_dsn = std::move(dsn); - m_spiConnection->Connect(properties, missing_properties); - m_isConnected = true; - std::shared_ptr spiStatement = m_spiConnection->CreateStatement(); - m_attributeTrackingStatement = std::make_shared(*this, spiStatement); + dsn_ = std::move(dsn); + spi_connection_->Connect(properties, missing_properties); + is_connected_ = true; + std::shared_ptr spi_statement = spi_connection_->CreateStatement(); + attribute_tracking_statement_ = std::make_shared(*this, spi_statement); } -void ODBCConnection::GetInfo(SQLUSMALLINT infoType, SQLPOINTER value, - SQLSMALLINT bufferLength, SQLSMALLINT* outputLength, - bool isUnicode) { - switch (infoType) { +void ODBCConnection::GetInfo(SQLUSMALLINT info_type, SQLPOINTER value, + SQLSMALLINT buffer_length, SQLSMALLINT* output_length, + bool is_unicode) { + switch (info_type) { case SQL_ACTIVE_ENVIRONMENTS: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; #ifdef SQL_ASYNC_DBC_FUNCTIONS case SQL_ASYNC_DBC_FUNCTIONS: GetAttribute(static_cast(SQL_ASYNC_DBC_NOT_CAPABLE), value, - bufferLength, outputLength); + buffer_length, output_length); break; #endif case SQL_ASYNC_MODE: - GetAttribute(static_cast(SQL_AM_NONE), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_AM_NONE), value, buffer_length, + output_length); break; #ifdef SQL_ASYNC_NOTIFICATION case SQL_ASYNC_NOTIFICATION: GetAttribute(static_cast(SQL_ASYNC_NOTIFICATION_NOT_CAPABLE), value, - bufferLength, outputLength); + buffer_length, output_length); break; #endif case SQL_BATCH_ROW_COUNT: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_BATCH_SUPPORT: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_DATA_SOURCE_NAME: - GetStringAttribute(isUnicode, m_dsn, true, value, bufferLength, outputLength, + GetStringAttribute(is_unicode, dsn_, true, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DRIVER_ODBC_VER: - GetStringAttribute(isUnicode, "03.80", true, value, bufferLength, outputLength, + GetStringAttribute(is_unicode, "03.80", true, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DYNAMIC_CURSOR_ATTRIBUTES1: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_DYNAMIC_CURSOR_ATTRIBUTES2: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES1: - GetAttribute(static_cast(SQL_CA1_NEXT), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_CA1_NEXT), value, buffer_length, + output_length); break; case SQL_FORWARD_ONLY_CURSOR_ATTRIBUTES2: GetAttribute(static_cast(SQL_CA2_READ_ONLY_CONCURRENCY), value, - bufferLength, outputLength); + buffer_length, output_length); break; case SQL_FILE_USAGE: - GetAttribute(static_cast(SQL_FILE_NOT_SUPPORTED), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_FILE_NOT_SUPPORTED), value, + buffer_length, output_length); break; case SQL_KEYSET_CURSOR_ATTRIBUTES1: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_KEYSET_CURSOR_ATTRIBUTES2: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_MAX_ASYNC_CONCURRENT_STATEMENTS: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_ODBC_INTERFACE_CONFORMANCE: - GetAttribute(static_cast(SQL_OIC_CORE), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_OIC_CORE), value, buffer_length, + output_length); break; // case SQL_ODBC_STANDARD_CLI_CONFORMANCE: - mentioned in SQLGetInfo spec with no // description and there is no constant for this. case SQL_PARAM_ARRAY_ROW_COUNTS: - GetAttribute(static_cast(SQL_PARC_NO_BATCH), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_PARC_NO_BATCH), value, buffer_length, + output_length); break; case SQL_PARAM_ARRAY_SELECTS: - GetAttribute(static_cast(SQL_PAS_NO_SELECT), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_PAS_NO_SELECT), value, buffer_length, + output_length); break; case SQL_ROW_UPDATES: - GetStringAttribute(isUnicode, "N", true, value, bufferLength, outputLength, + GetStringAttribute(is_unicode, "N", true, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_SCROLL_OPTIONS: - GetAttribute(static_cast(SQL_SO_FORWARD_ONLY), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_SO_FORWARD_ONLY), value, buffer_length, + output_length); break; case SQL_STATIC_CURSOR_ATTRIBUTES1: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_STATIC_CURSOR_ATTRIBUTES2: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_BOOKMARK_PERSISTENCE: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_DESCRIBE_PARAMETER: - GetStringAttribute(isUnicode, "N", true, value, bufferLength, outputLength, + GetStringAttribute(is_unicode, "N", true, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_MULT_RESULT_SETS: - GetStringAttribute(isUnicode, "N", true, value, bufferLength, outputLength, + GetStringAttribute(is_unicode, "N", true, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_MULTIPLE_ACTIVE_TXN: - GetStringAttribute(isUnicode, "N", true, value, bufferLength, outputLength, + GetStringAttribute(is_unicode, "N", true, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_NEED_LONG_DATA_LEN: - GetStringAttribute(isUnicode, "N", true, value, bufferLength, outputLength, + GetStringAttribute(is_unicode, "N", true, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_TXN_CAPABLE: - GetAttribute(static_cast(SQL_TC_NONE), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_TC_NONE), value, buffer_length, + output_length); break; case SQL_TXN_ISOLATION_OPTION: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_TABLE_TERM: - GetStringAttribute(isUnicode, "table", true, value, bufferLength, outputLength, + GetStringAttribute(is_unicode, "table", true, value, buffer_length, output_length, GetDiagnostics()); break; // Deprecated ODBC 2.x fields required for backwards compatibility. case SQL_ODBC_API_CONFORMANCE: - GetAttribute(static_cast(SQL_OAC_LEVEL1), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_OAC_LEVEL1), value, buffer_length, + output_length); break; case SQL_FETCH_DIRECTION: - GetAttribute(static_cast(SQL_FETCH_NEXT), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_FETCH_NEXT), value, buffer_length, + output_length); break; case SQL_LOCK_TYPES: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_POS_OPERATIONS: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_POSITIONED_STATEMENTS: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_SCROLL_CONCURRENCY: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; case SQL_STATIC_SENSITIVITY: - GetAttribute(static_cast(0), value, bufferLength, outputLength); + GetAttribute(static_cast(0), value, buffer_length, output_length); break; // Driver-level string properties. @@ -309,10 +309,10 @@ void ODBCConnection::GetInfo(SQLUSMALLINT infoType, SQLPOINTER value, case SQL_PROCEDURES: case SQL_SPECIAL_CHARACTERS: case SQL_XOPEN_CLI_YEAR: { - const auto& info = m_spiConnection->GetInfo(infoType); - const std::string& infoValue = boost::get(info); - GetStringAttribute(isUnicode, infoValue, true, value, bufferLength, outputLength, - GetDiagnostics()); + const auto& info = spi_connection_->GetInfo(info_type); + const std::string& info_value = boost::get(info); + GetStringAttribute(is_unicode, info_value, true, value, buffer_length, + output_length, GetDiagnostics()); break; } @@ -400,9 +400,9 @@ void ODBCConnection::GetInfo(SQLUSMALLINT infoType, SQLPOINTER value, case SQL_SQL92_STRING_FUNCTIONS: case SQL_SQL92_VALUE_EXPRESSIONS: case SQL_STANDARD_CLI_CONFORMANCE: { - const auto& info = m_spiConnection->GetInfo(infoType); - uint32_t infoValue = boost::get(info); - GetAttribute(infoValue, value, bufferLength, outputLength); + const auto& info = spi_connection_->GetInfo(info_type); + uint32_t info_value = boost::get(info); + GetAttribute(info_value, value, buffer_length, output_length); break; } @@ -435,31 +435,31 @@ void ODBCConnection::GetInfo(SQLUSMALLINT infoType, SQLPOINTER value, case SQL_MAX_USER_NAME_LEN: case SQL_ODBC_SQL_CONFORMANCE: case SQL_ODBC_SAG_CLI_CONFORMANCE: { - const auto& info = m_spiConnection->GetInfo(infoType); - uint16_t infoValue = boost::get(info); - GetAttribute(infoValue, value, bufferLength, outputLength); + const auto& info = spi_connection_->GetInfo(info_type); + uint16_t info_value = boost::get(info); + GetAttribute(info_value, value, buffer_length, output_length); break; } // Special case - SQL_DATABASE_NAME is an alias for SQL_ATTR_CURRENT_CATALOG. case SQL_DATABASE_NAME: { - const auto& attr = m_spiConnection->GetAttribute(Connection::CURRENT_CATALOG); + const auto& attr = spi_connection_->GetAttribute(Connection::CURRENT_CATALOG); if (!attr) { throw DriverException("Optional feature not supported.", "HYC00"); } - const std::string& infoValue = boost::get(*attr); - GetStringAttribute(isUnicode, infoValue, true, value, bufferLength, outputLength, - GetDiagnostics()); + const std::string& info_value = boost::get(*attr); + GetStringAttribute(is_unicode, info_value, true, value, buffer_length, + output_length, GetDiagnostics()); break; } default: - throw DriverException("Unknown SQLGetInfo type: " + std::to_string(infoType)); + throw DriverException("Unknown SQLGetInfo type: " + std::to_string(info_type)); } } void ODBCConnection::SetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, - SQLINTEGER stringLength, bool isUnicode) { - uint32_t attributeToWrite = 0; + SQLINTEGER string_length, bool is_unicode) { + uint32_t attribute_to_write = 0; bool successfully_written = false; switch (attribute) { // Internal connection attributes @@ -511,12 +511,12 @@ void ODBCConnection::SetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, // ODBCAbstraction-level attributes case SQL_ATTR_CURRENT_CATALOG: { std::string catalog; - if (isUnicode) { - SetAttributeUTF8(value, stringLength, catalog); + if (is_unicode) { + SetAttributeUTF8(value, string_length, catalog); } else { - SetAttributeSQLWCHAR(value, stringLength, catalog); + SetAttributeSQLWCHAR(value, string_length, catalog); } - if (!m_spiConnection->SetAttribute(Connection::CURRENT_CATALOG, catalog)) { + if (!spi_connection_->SetAttribute(Connection::CURRENT_CATALOG, catalog)) { throw DriverException("Option value changed.", "01S02"); } return; @@ -539,29 +539,29 @@ void ODBCConnection::SetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, case SQL_ATTR_ROW_BIND_TYPE: case SQL_ATTR_SIMULATE_CURSOR: case SQL_ATTR_USE_BOOKMARKS: - m_attributeTrackingStatement->SetStmtAttr(attribute, value, stringLength, - isUnicode); + attribute_tracking_statement_->SetStmtAttr(attribute, value, string_length, + is_unicode); return; case SQL_ATTR_ACCESS_MODE: - SetAttribute(value, attributeToWrite); + SetAttribute(value, attribute_to_write); successfully_written = - m_spiConnection->SetAttribute(Connection::ACCESS_MODE, attributeToWrite); + spi_connection_->SetAttribute(Connection::ACCESS_MODE, attribute_to_write); break; case SQL_ATTR_CONNECTION_TIMEOUT: - SetAttribute(value, attributeToWrite); - successfully_written = - m_spiConnection->SetAttribute(Connection::CONNECTION_TIMEOUT, attributeToWrite); + SetAttribute(value, attribute_to_write); + successfully_written = spi_connection_->SetAttribute(Connection::CONNECTION_TIMEOUT, + attribute_to_write); break; case SQL_ATTR_LOGIN_TIMEOUT: - SetAttribute(value, attributeToWrite); + SetAttribute(value, attribute_to_write); successfully_written = - m_spiConnection->SetAttribute(Connection::LOGIN_TIMEOUT, attributeToWrite); + spi_connection_->SetAttribute(Connection::LOGIN_TIMEOUT, attribute_to_write); break; case SQL_ATTR_PACKET_SIZE: - SetAttribute(value, attributeToWrite); + SetAttribute(value, attribute_to_write); successfully_written = - m_spiConnection->SetAttribute(Connection::PACKET_SIZE, attributeToWrite); + spi_connection_->SetAttribute(Connection::PACKET_SIZE, attribute_to_write); break; default: throw DriverException("Invalid attribute: " + std::to_string(attribute), "HY092"); @@ -574,57 +574,57 @@ void ODBCConnection::SetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, } void ODBCConnection::GetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, - SQLINTEGER bufferLength, SQLINTEGER* outputLength, - bool isUnicode) { + SQLINTEGER buffer_length, SQLINTEGER* output_length, + bool is_unicode) { using driver::odbcabstraction::Connection; - boost::optional spiAttribute; + boost::optional spi_attribute; switch (attribute) { // Internal connection attributes #ifdef SQL_ATR_ASYNC_DBC_EVENT case SQL_ATTR_ASYNC_DBC_EVENT: - GetAttribute(static_cast(NULL), value, bufferLength, outputLength); + GetAttribute(static_cast(NULL), value, buffer_length, output_length); return; #endif #ifdef SQL_ATTR_ASYNC_DBC_FUNCTIONS_ENABLE case SQL_ATTR_ASYNC_DBC_FUNCTIONS_ENABLE: GetAttribute(static_cast(SQL_ASYNC_DBC_ENABLE_OFF), value, - bufferLength, outputLength); + buffer_length, output_length); return; #endif #ifdef SQL_ATTR_ASYNC_PCALLBACK case SQL_ATTR_ASYNC_DBC_PCALLBACK: - GetAttribute(static_cast(NULL), value, bufferLength, outputLength); + GetAttribute(static_cast(NULL), value, buffer_length, output_length); return; #endif #ifdef SQL_ATTR_ASYNC_DBC_PCONTEXT case SQL_ATTR_ASYNC_DBC_PCONTEXT: - GetAttribute(static_cast(NULL), value, bufferLength, outputLength); + GetAttribute(static_cast(NULL), value, buffer_length, output_length); return; #endif case SQL_ATTR_ASYNC_ENABLE: - GetAttribute(static_cast(SQL_ASYNC_ENABLE_OFF), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_ASYNC_ENABLE_OFF), value, buffer_length, + output_length); return; case SQL_ATTR_AUTO_IPD: - GetAttribute(static_cast(SQL_FALSE), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_FALSE), value, buffer_length, + output_length); return; case SQL_ATTR_AUTOCOMMIT: - GetAttribute(static_cast(SQL_AUTOCOMMIT_ON), value, bufferLength, - outputLength); + GetAttribute(static_cast(SQL_AUTOCOMMIT_ON), value, buffer_length, + output_length); return; #ifdef SQL_ATTR_DBC_INFO_TOKEN case SQL_ATTR_DBC_INFO_TOKEN: throw DriverException("Cannot read set-only attribute", "HY092"); #endif case SQL_ATTR_ENLIST_IN_DTC: - GetAttribute(static_cast(NULL), value, bufferLength, outputLength); + GetAttribute(static_cast(NULL), value, buffer_length, output_length); return; case SQL_ATTR_ODBC_CURSORS: // DM-only. throw DriverException("Invalid attribute", "HY092"); case SQL_ATTR_QUIET_MODE: - GetAttribute(static_cast(NULL), value, bufferLength, outputLength); + GetAttribute(static_cast(NULL), value, buffer_length, output_length); return; case SQL_ATTR_TRACE: // DM-only throw DriverException("Invalid attribute", "HY092"); @@ -639,127 +639,127 @@ void ODBCConnection::GetConnectAttr(SQLINTEGER attribute, SQLPOINTER value, // ODBCAbstraction-level connection attributes. case SQL_ATTR_CURRENT_CATALOG: { - const auto& catalog = m_spiConnection->GetAttribute(Connection::CURRENT_CATALOG); + const auto& catalog = spi_connection_->GetAttribute(Connection::CURRENT_CATALOG); if (!catalog) { throw DriverException("Optional feature not supported.", "HYC00"); } - const std::string& infoValue = boost::get(*catalog); - GetStringAttribute(isUnicode, infoValue, true, value, bufferLength, outputLength, - GetDiagnostics()); + const std::string& info_value = boost::get(*catalog); + GetStringAttribute(is_unicode, info_value, true, value, buffer_length, + output_length, GetDiagnostics()); return; } // These all are uint32_t attributes. case SQL_ATTR_ACCESS_MODE: - spiAttribute = m_spiConnection->GetAttribute(Connection::ACCESS_MODE); + spi_attribute = spi_connection_->GetAttribute(Connection::ACCESS_MODE); break; case SQL_ATTR_CONNECTION_DEAD: - spiAttribute = m_spiConnection->GetAttribute(Connection::CONNECTION_DEAD); + spi_attribute = spi_connection_->GetAttribute(Connection::CONNECTION_DEAD); break; case SQL_ATTR_CONNECTION_TIMEOUT: - spiAttribute = m_spiConnection->GetAttribute(Connection::CONNECTION_TIMEOUT); + spi_attribute = spi_connection_->GetAttribute(Connection::CONNECTION_TIMEOUT); break; case SQL_ATTR_LOGIN_TIMEOUT: - spiAttribute = m_spiConnection->GetAttribute(Connection::LOGIN_TIMEOUT); + spi_attribute = spi_connection_->GetAttribute(Connection::LOGIN_TIMEOUT); break; case SQL_ATTR_PACKET_SIZE: - spiAttribute = m_spiConnection->GetAttribute(Connection::PACKET_SIZE); + spi_attribute = spi_connection_->GetAttribute(Connection::PACKET_SIZE); break; default: throw DriverException("Invalid attribute", "HY092"); } - if (!spiAttribute) { + if (!spi_attribute) { throw DriverException("Invalid attribute", "HY092"); } - GetAttribute(static_cast(boost::get(*spiAttribute)), value, - bufferLength, outputLength); + GetAttribute(static_cast(boost::get(*spi_attribute)), value, + buffer_length, output_length); } -void ODBCConnection::disconnect() { - if (m_isConnected) { +void ODBCConnection::Disconnect() { + if (is_connected_) { // Ensure that all statements (and corresponding SPI statements) get cleaned // up before terminating the SPI connection in case they need to be de-allocated in // the reverse of the allocation order. - m_statements.clear(); - m_spiConnection->Close(); - m_isConnected = false; + statements_.clear(); + spi_connection_->Close(); + is_connected_ = false; } } -void ODBCConnection::releaseConnection() { - disconnect(); - m_environment.DropConnection(this); +void ODBCConnection::ReleaseConnection() { + Disconnect(); + environment_.DropConnection(this); } -std::shared_ptr ODBCConnection::createStatement() { - std::shared_ptr spiStatement = m_spiConnection->CreateStatement(); +std::shared_ptr ODBCConnection::CreateStatement() { + std::shared_ptr spi_statement = spi_connection_->CreateStatement(); std::shared_ptr statement = - std::make_shared(*this, spiStatement); - m_statements.push_back(statement); + std::make_shared(*this, spi_statement); + statements_.push_back(statement); statement->CopyAttributesFromConnection(*this); return statement; } -void ODBCConnection::dropStatement(ODBCStatement* stmt) { - auto it = std::find_if(m_statements.begin(), m_statements.end(), +void ODBCConnection::DropStatement(ODBCStatement* stmt) { + auto it = std::find_if(statements_.begin(), statements_.end(), [&stmt](const std::shared_ptr& statement) { return statement.get() == stmt; }); - if (m_statements.end() != it) { - m_statements.erase(it); + if (statements_.end() != it) { + statements_.erase(it); } } -std::shared_ptr ODBCConnection::createDescriptor() { +std::shared_ptr ODBCConnection::CreateDescriptor() { std::shared_ptr desc = std::make_shared( - m_spiConnection->GetDiagnostics(), this, nullptr, true, true, false); - m_descriptors.push_back(desc); + spi_connection_->GetDiagnostics(), this, nullptr, true, true, false); + descriptors_.push_back(desc); return desc; } -void ODBCConnection::dropDescriptor(ODBCDescriptor* desc) { - auto it = std::find_if(m_descriptors.begin(), m_descriptors.end(), +void ODBCConnection::DropDescriptor(ODBCDescriptor* desc) { + auto it = std::find_if(descriptors_.begin(), descriptors_.end(), [&desc](const std::shared_ptr& descriptor) { return descriptor.get() == desc; }); - if (m_descriptors.end() != it) { - m_descriptors.erase(it); + if (descriptors_.end() != it) { + descriptors_.erase(it); } } // Public Static // =================================================================================== -std::string ODBCConnection::getPropertiesFromConnString( - const std::string& connStr, Connection::ConnPropertyMap& properties) { +std::string ODBCConnection::GetPropertiesFromConnString( + const std::string& conn_str, Connection::ConnPropertyMap& properties) { const int groups[] = {1, 2}; // CONNECTION_STR_REGEX has two groups. key: 1, value: 2 - boost::xpressive::sregex_token_iterator regexIter(connStr.begin(), connStr.end(), - CONNECTION_STR_REGEX, groups), + boost::xpressive::sregex_token_iterator regex_iter(conn_str.begin(), conn_str.end(), + CONNECTION_STR_REGEX, groups), end; - bool isDsnFirst = false; - bool isDriverFirst = false; + bool is_dsn_first = false; + bool is_driver_first = false; std::string dsn; - for (auto it = regexIter; end != regexIter; ++regexIter) { - std::string key = *regexIter; - std::string value = *++regexIter; + for (auto it = regex_iter; end != regex_iter; ++regex_iter) { + std::string key = *regex_iter; + std::string value = *++regex_iter; // If the DSN shows up before driver key, load settings from the DSN. // Only load values from the DSN once regardless of how many times the DSN // key shows up. if (boost::iequals(key, "DSN")) { - if (!isDriverFirst) { - if (!isDsnFirst) { - isDsnFirst = true; + if (!is_driver_first) { + if (!is_dsn_first) { + is_dsn_first = true; loadPropertiesFromDSN(value, properties); dsn.swap(value); } } continue; } else if (boost::iequals(key, "Driver")) { - if (!isDsnFirst) { - isDriverFirst = true; + if (!is_dsn_first) { + is_driver_first = true; } continue; } diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc index b578bea360952..990209bdcc3b7 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_descriptor.cc @@ -42,7 +42,7 @@ SQLSMALLINT CalculateHighestBoundRecord(const std::vector& rec // Most applications will bind every column, so optimistically assume that we'll // find the next bound record fastest by counting backwards. for (size_t i = records.size(); i > 0; --i) { - if (records[i - 1].m_isBound) { + if (records[i - 1].is_bound) { return i; } } @@ -52,76 +52,77 @@ SQLSMALLINT CalculateHighestBoundRecord(const std::vector& rec // Public // ========================================================================================= -ODBCDescriptor::ODBCDescriptor(Diagnostics& baseDiagnostics, ODBCConnection* conn, - ODBCStatement* stmt, bool isAppDescriptor, bool isWritable, - bool is2xConnection) - : m_diagnostics(baseDiagnostics.GetVendor(), baseDiagnostics.GetDataSourceComponent(), - driver::odbcabstraction::V_3), - m_owningConnection(conn), - m_parentStatement(stmt), - m_arrayStatusPtr(nullptr), - m_bindOffsetPtr(nullptr), - m_rowsProccessedPtr(nullptr), - m_arraySize(1), - m_bindType(SQL_BIND_BY_COLUMN), - m_highestOneBasedBoundRecord(0), - m_is2xConnection(is2xConnection), - m_isAppDescriptor(isAppDescriptor), - m_isWritable(isWritable), - m_hasBindingsChanged(true) {} - -Diagnostics& ODBCDescriptor::GetDiagnostics_Impl() { return m_diagnostics; } +ODBCDescriptor::ODBCDescriptor(Diagnostics& base_diagnostics, ODBCConnection* conn, + ODBCStatement* stmt, bool is_app_descriptor, + bool is_writable, bool is_2x_connection) + : diagnostics_(base_diagnostics.GetVendor(), + base_diagnostics.GetDataSourceComponent(), + driver::odbcabstraction::V_3), + owning_connection_(conn), + parent_statement_(stmt), + array_status_ptr_(nullptr), + bind_offset_ptr_(nullptr), + rows_processed_ptr_(nullptr), + array_size_(1), + bind_type_(SQL_BIND_BY_COLUMN), + highest_one_based_bound_record_(0), + is_2x_connection_(is_2x_connection), + is_app_descriptor_(is_app_descriptor), + is_writable_(is_writable), + has_bindings_changed_(true) {} + +Diagnostics& ODBCDescriptor::GetDiagnosticsImpl() { return diagnostics_; } ODBCConnection& ODBCDescriptor::GetConnection() { - if (m_owningConnection) { - return *m_owningConnection; + if (owning_connection_) { + return *owning_connection_; } - assert(m_parentStatement); - return m_parentStatement->GetConnection(); + assert(parent_statement_); + return parent_statement_->GetConnection(); } -void ODBCDescriptor::SetHeaderField(SQLSMALLINT fieldIdentifier, SQLPOINTER value, - SQLINTEGER bufferLength) { +void ODBCDescriptor::SetHeaderField(SQLSMALLINT field_identifier, SQLPOINTER value, + SQLINTEGER buffer_length) { // Only these two fields can be set on the IRD. - if (!m_isWritable && fieldIdentifier != SQL_DESC_ARRAY_STATUS_PTR && - fieldIdentifier != SQL_DESC_ROWS_PROCESSED_PTR) { + if (!is_writable_ && field_identifier != SQL_DESC_ARRAY_STATUS_PTR && + field_identifier != SQL_DESC_ROWS_PROCESSED_PTR) { throw DriverException("Cannot modify read-only descriptor", "HY016"); } - switch (fieldIdentifier) { + switch (field_identifier) { case SQL_DESC_ALLOC_TYPE: throw DriverException("Invalid descriptor field", "HY091"); case SQL_DESC_ARRAY_SIZE: - SetAttribute(value, m_arraySize); - m_hasBindingsChanged = true; + SetAttribute(value, array_size_); + has_bindings_changed_ = true; break; case SQL_DESC_ARRAY_STATUS_PTR: - SetPointerAttribute(value, m_arrayStatusPtr); - m_hasBindingsChanged = true; + SetPointerAttribute(value, array_status_ptr_); + has_bindings_changed_ = true; break; case SQL_DESC_BIND_OFFSET_PTR: - SetPointerAttribute(value, m_bindOffsetPtr); - m_hasBindingsChanged = true; + SetPointerAttribute(value, bind_offset_ptr_); + has_bindings_changed_ = true; break; case SQL_DESC_BIND_TYPE: - SetAttribute(value, m_bindType); - m_hasBindingsChanged = true; + SetAttribute(value, bind_type_); + has_bindings_changed_ = true; break; case SQL_DESC_ROWS_PROCESSED_PTR: - SetPointerAttribute(value, m_rowsProccessedPtr); - m_hasBindingsChanged = true; + SetPointerAttribute(value, rows_processed_ptr_); + has_bindings_changed_ = true; break; case SQL_DESC_COUNT: { - SQLSMALLINT newCount; - SetAttribute(value, newCount); - m_records.resize(newCount); + SQLSMALLINT new_count; + SetAttribute(value, new_count); + records_.resize(new_count); - if (m_isAppDescriptor && newCount <= m_highestOneBasedBoundRecord) { - m_highestOneBasedBoundRecord = CalculateHighestBoundRecord(m_records); + if (is_app_descriptor_ && new_count <= highest_one_based_bound_record_) { + highest_one_based_bound_record_ = CalculateHighestBoundRecord(records_); } else { - m_highestOneBasedBoundRecord = newCount; + highest_one_based_bound_record_ = new_count; } - m_hasBindingsChanged = true; + has_bindings_changed_ = true; break; } default: @@ -129,14 +130,14 @@ void ODBCDescriptor::SetHeaderField(SQLSMALLINT fieldIdentifier, SQLPOINTER valu } } -void ODBCDescriptor::SetField(SQLSMALLINT recordNumber, SQLSMALLINT fieldIdentifier, - SQLPOINTER value, SQLINTEGER bufferLength) { - if (!m_isWritable) { +void ODBCDescriptor::SetField(SQLSMALLINT record_number, SQLSMALLINT field_identifier, + SQLPOINTER value, SQLINTEGER buffer_length) { + if (!is_writable_) { throw DriverException("Cannot modify read-only descriptor", "HY016"); } // Handle header fields before validating the record number. - switch (fieldIdentifier) { + switch (field_identifier) { case SQL_DESC_ALLOC_TYPE: case SQL_DESC_ARRAY_SIZE: case SQL_DESC_ARRAY_STATUS_PTR: @@ -144,23 +145,23 @@ void ODBCDescriptor::SetField(SQLSMALLINT recordNumber, SQLSMALLINT fieldIdentif case SQL_DESC_BIND_TYPE: case SQL_DESC_ROWS_PROCESSED_PTR: case SQL_DESC_COUNT: - SetHeaderField(fieldIdentifier, value, bufferLength); + SetHeaderField(field_identifier, value, buffer_length); return; default: break; } - if (recordNumber == 0) { + if (record_number == 0) { throw DriverException("Bookmarks are unsupported.", "07009"); } - if (recordNumber > m_records.size()) { + if (record_number > records_.size()) { throw DriverException("Invalid descriptor index", "HY009"); } - SQLSMALLINT zeroBasedRecord = recordNumber - 1; - DescriptorRecord& record = m_records[zeroBasedRecord]; - switch (fieldIdentifier) { + SQLSMALLINT zero_based_record = record_number - 1; + DescriptorRecord& record = records_[zero_based_record]; + switch (field_identifier) { case SQL_DESC_AUTO_UNIQUE_VALUE: case SQL_DESC_BASE_COLUMN_NAME: case SQL_DESC_BASE_TABLE_NAME: @@ -184,98 +185,98 @@ void ODBCDescriptor::SetField(SQLSMALLINT recordNumber, SQLSMALLINT fieldIdentif case SQL_DESC_UPDATABLE: throw DriverException("Cannot modify read-only field.", "HY092"); case SQL_DESC_CONCISE_TYPE: - SetAttribute(value, record.m_conciseType); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.concise_type); + record.is_bound = false; + has_bindings_changed_ = true; break; case SQL_DESC_DATA_PTR: - SetDataPtrOnRecord(value, recordNumber); + SetDataPtrOnRecord(value, record_number); break; case SQL_DESC_DATETIME_INTERVAL_CODE: - SetAttribute(value, record.m_datetimeIntervalCode); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.datetime_interval_code); + record.is_bound = false; + has_bindings_changed_ = true; break; case SQL_DESC_DATETIME_INTERVAL_PRECISION: - SetAttribute(value, record.m_datetimeIntervalPrecision); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.datetime_interval_precision); + record.is_bound = false; + has_bindings_changed_ = true; break; case SQL_DESC_INDICATOR_PTR: case SQL_DESC_OCTET_LENGTH_PTR: - SetPointerAttribute(value, record.m_indicatorPtr); - m_hasBindingsChanged = true; + SetPointerAttribute(value, record.indicator_ptr); + has_bindings_changed_ = true; break; case SQL_DESC_LENGTH: - SetAttribute(value, record.m_length); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.length); + record.is_bound = false; + has_bindings_changed_ = true; break; case SQL_DESC_NAME: - SetAttributeUTF8(value, bufferLength, record.m_name); - m_hasBindingsChanged = true; + SetAttributeUTF8(value, buffer_length, record.name); + has_bindings_changed_ = true; break; case SQL_DESC_OCTET_LENGTH: - SetAttribute(value, record.m_octetLength); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.octet_length); + record.is_bound = false; + has_bindings_changed_ = true; break; case SQL_DESC_PARAMETER_TYPE: - SetAttribute(value, record.m_paramType); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.param_type); + record.is_bound = false; + has_bindings_changed_ = true; break; case SQL_DESC_PRECISION: - SetAttribute(value, record.m_precision); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.precision); + record.is_bound = false; + has_bindings_changed_ = true; break; case SQL_DESC_SCALE: - SetAttribute(value, record.m_scale); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.scale); + record.is_bound = false; + has_bindings_changed_ = true; break; case SQL_DESC_TYPE: - SetAttribute(value, record.m_type); - record.m_isBound = false; - m_hasBindingsChanged = true; + SetAttribute(value, record.type); + record.is_bound = false; + has_bindings_changed_ = true; break; default: throw DriverException("Invalid descriptor field", "HY091"); } } -void ODBCDescriptor::GetHeaderField(SQLSMALLINT fieldIdentifier, SQLPOINTER value, - SQLINTEGER bufferLength, - SQLINTEGER* outputLength) const { - switch (fieldIdentifier) { +void ODBCDescriptor::GetHeaderField(SQLSMALLINT field_identifier, SQLPOINTER value, + SQLINTEGER buffer_length, + SQLINTEGER* output_length) const { + switch (field_identifier) { case SQL_DESC_ALLOC_TYPE: { SQLSMALLINT result; - if (m_owningConnection) { + if (owning_connection_) { result = SQL_DESC_ALLOC_USER; } else { result = SQL_DESC_ALLOC_AUTO; } - GetAttribute(result, value, bufferLength, outputLength); + GetAttribute(result, value, buffer_length, output_length); break; } case SQL_DESC_ARRAY_SIZE: - GetAttribute(m_arraySize, value, bufferLength, outputLength); + GetAttribute(array_size_, value, buffer_length, output_length); break; case SQL_DESC_ARRAY_STATUS_PTR: - GetAttribute(m_arrayStatusPtr, value, bufferLength, outputLength); + GetAttribute(array_status_ptr_, value, buffer_length, output_length); break; case SQL_DESC_BIND_OFFSET_PTR: - GetAttribute(m_bindOffsetPtr, value, bufferLength, outputLength); + GetAttribute(bind_offset_ptr_, value, buffer_length, output_length); break; case SQL_DESC_BIND_TYPE: - GetAttribute(m_bindType, value, bufferLength, outputLength); + GetAttribute(bind_type_, value, buffer_length, output_length); break; case SQL_DESC_ROWS_PROCESSED_PTR: - GetAttribute(m_rowsProccessedPtr, value, bufferLength, outputLength); + GetAttribute(rows_processed_ptr_, value, buffer_length, output_length); break; case SQL_DESC_COUNT: { - GetAttribute(m_highestOneBasedBoundRecord, value, bufferLength, outputLength); + GetAttribute(highest_one_based_bound_record_, value, buffer_length, output_length); break; } default: @@ -283,11 +284,11 @@ void ODBCDescriptor::GetHeaderField(SQLSMALLINT fieldIdentifier, SQLPOINTER valu } } -void ODBCDescriptor::GetField(SQLSMALLINT recordNumber, SQLSMALLINT fieldIdentifier, - SQLPOINTER value, SQLINTEGER bufferLength, - SQLINTEGER* outputLength) { +void ODBCDescriptor::GetField(SQLSMALLINT record_number, SQLSMALLINT field_identifier, + SQLPOINTER value, SQLINTEGER buffer_length, + SQLINTEGER* output_length) { // Handle header fields before validating the record number. - switch (fieldIdentifier) { + switch (field_identifier) { case SQL_DESC_ALLOC_TYPE: case SQL_DESC_ARRAY_SIZE: case SQL_DESC_ARRAY_STATUS_PTR: @@ -295,279 +296,281 @@ void ODBCDescriptor::GetField(SQLSMALLINT recordNumber, SQLSMALLINT fieldIdentif case SQL_DESC_BIND_TYPE: case SQL_DESC_ROWS_PROCESSED_PTR: case SQL_DESC_COUNT: - GetHeaderField(fieldIdentifier, value, bufferLength, outputLength); + GetHeaderField(field_identifier, value, buffer_length, output_length); return; default: break; } - if (recordNumber == 0) { + if (record_number == 0) { throw DriverException("Bookmarks are unsupported.", "07009"); } - if (recordNumber > m_records.size()) { + if (record_number > records_.size()) { throw DriverException("Invalid descriptor index", "07009"); } // TODO: Restrict fields based on AppDescriptor IPD, and IRD. - SQLSMALLINT zeroBasedRecord = recordNumber - 1; - const DescriptorRecord& record = m_records[zeroBasedRecord]; - switch (fieldIdentifier) { + SQLSMALLINT zero_based_record = record_number - 1; + const DescriptorRecord& record = records_[zero_based_record]; + switch (field_identifier) { case SQL_DESC_BASE_COLUMN_NAME: - GetAttributeUTF8(record.m_baseColumnName, value, bufferLength, outputLength, + GetAttributeUTF8(record.base_column_name, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_BASE_TABLE_NAME: - GetAttributeUTF8(record.m_baseTableName, value, bufferLength, outputLength, + GetAttributeUTF8(record.base_table_name, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_CATALOG_NAME: - GetAttributeUTF8(record.m_catalogName, value, bufferLength, outputLength, + GetAttributeUTF8(record.catalog_name, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_LABEL: - GetAttributeUTF8(record.m_label, value, bufferLength, outputLength, + GetAttributeUTF8(record.label, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_LITERAL_PREFIX: - GetAttributeUTF8(record.m_literalPrefix, value, bufferLength, outputLength, + GetAttributeUTF8(record.literal_prefix, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_LITERAL_SUFFIX: - GetAttributeUTF8(record.m_literalSuffix, value, bufferLength, outputLength, + GetAttributeUTF8(record.literal_suffix, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_LOCAL_TYPE_NAME: - GetAttributeUTF8(record.m_localTypeName, value, bufferLength, outputLength, + GetAttributeUTF8(record.local_type_name, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_NAME: - GetAttributeUTF8(record.m_name, value, bufferLength, outputLength, + GetAttributeUTF8(record.name, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_SCHEMA_NAME: - GetAttributeUTF8(record.m_schemaName, value, bufferLength, outputLength, + GetAttributeUTF8(record.schema_name, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_TABLE_NAME: - GetAttributeUTF8(record.m_tableName, value, bufferLength, outputLength, + GetAttributeUTF8(record.table_name, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_TYPE_NAME: - GetAttributeUTF8(record.m_typeName, value, bufferLength, outputLength, + GetAttributeUTF8(record.type_name, value, buffer_length, output_length, GetDiagnostics()); break; case SQL_DESC_DATA_PTR: - GetAttribute(record.m_dataPtr, value, bufferLength, outputLength); + GetAttribute(record.data_ptr, value, buffer_length, output_length); break; case SQL_DESC_INDICATOR_PTR: case SQL_DESC_OCTET_LENGTH_PTR: - GetAttribute(record.m_indicatorPtr, value, bufferLength, outputLength); + GetAttribute(record.indicator_ptr, value, buffer_length, output_length); break; case SQL_DESC_LENGTH: - GetAttribute(record.m_length, value, bufferLength, outputLength); + GetAttribute(record.length, value, buffer_length, output_length); break; case SQL_DESC_OCTET_LENGTH: - GetAttribute(record.m_octetLength, value, bufferLength, outputLength); + GetAttribute(record.octet_length, value, buffer_length, output_length); break; case SQL_DESC_AUTO_UNIQUE_VALUE: - GetAttribute(record.m_autoUniqueValue, value, bufferLength, outputLength); + GetAttribute(record.auto_unique_value, value, buffer_length, output_length); break; case SQL_DESC_CASE_SENSITIVE: - GetAttribute(record.m_caseSensitive, value, bufferLength, outputLength); + GetAttribute(record.case_sensitive, value, buffer_length, output_length); break; case SQL_DESC_DATETIME_INTERVAL_PRECISION: - GetAttribute(record.m_datetimeIntervalPrecision, value, bufferLength, outputLength); + GetAttribute(record.datetime_interval_precision, value, buffer_length, + output_length); break; case SQL_DESC_NUM_PREC_RADIX: - GetAttribute(record.m_numPrecRadix, value, bufferLength, outputLength); + GetAttribute(record.num_prec_radix, value, buffer_length, output_length); break; case SQL_DESC_CONCISE_TYPE: - GetAttribute(record.m_conciseType, value, bufferLength, outputLength); + GetAttribute(record.concise_type, value, buffer_length, output_length); break; case SQL_DESC_DATETIME_INTERVAL_CODE: - GetAttribute(record.m_datetimeIntervalCode, value, bufferLength, outputLength); + GetAttribute(record.datetime_interval_code, value, buffer_length, output_length); break; case SQL_DESC_DISPLAY_SIZE: - GetAttribute(record.m_displaySize, value, bufferLength, outputLength); + GetAttribute(record.display_size, value, buffer_length, output_length); break; case SQL_DESC_FIXED_PREC_SCALE: - GetAttribute(record.m_fixedPrecScale, value, bufferLength, outputLength); + GetAttribute(record.fixed_prec_scale, value, buffer_length, output_length); break; case SQL_DESC_NULLABLE: - GetAttribute(record.m_nullable, value, bufferLength, outputLength); + GetAttribute(record.nullable, value, buffer_length, output_length); break; case SQL_DESC_PARAMETER_TYPE: - GetAttribute(record.m_paramType, value, bufferLength, outputLength); + GetAttribute(record.param_type, value, buffer_length, output_length); break; case SQL_DESC_PRECISION: - GetAttribute(record.m_precision, value, bufferLength, outputLength); + GetAttribute(record.precision, value, buffer_length, output_length); break; case SQL_DESC_ROWVER: - GetAttribute(record.m_rowVer, value, bufferLength, outputLength); + GetAttribute(record.row_ver, value, buffer_length, output_length); break; case SQL_DESC_SCALE: - GetAttribute(record.m_scale, value, bufferLength, outputLength); + GetAttribute(record.scale, value, buffer_length, output_length); break; case SQL_DESC_SEARCHABLE: - GetAttribute(record.m_searchable, value, bufferLength, outputLength); + GetAttribute(record.searchable, value, buffer_length, output_length); break; case SQL_DESC_TYPE: - GetAttribute(record.m_type, value, bufferLength, outputLength); + GetAttribute(record.type, value, buffer_length, output_length); break; case SQL_DESC_UNNAMED: - GetAttribute(record.m_unnamed, value, bufferLength, outputLength); + GetAttribute(record.unnamed, value, buffer_length, output_length); break; case SQL_DESC_UNSIGNED: - GetAttribute(record.m_unsigned, value, bufferLength, outputLength); + GetAttribute(record.is_unsigned, value, buffer_length, output_length); break; case SQL_DESC_UPDATABLE: - GetAttribute(record.m_updatable, value, bufferLength, outputLength); + GetAttribute(record.updatable, value, buffer_length, output_length); break; default: throw DriverException("Invalid descriptor field", "HY091"); } } -SQLSMALLINT ODBCDescriptor::getAllocType() const { - return m_owningConnection != nullptr ? SQL_DESC_ALLOC_USER : SQL_DESC_ALLOC_AUTO; +SQLSMALLINT ODBCDescriptor::GetAllocType() const { + return owning_connection_ != nullptr ? SQL_DESC_ALLOC_USER : SQL_DESC_ALLOC_AUTO; } -bool ODBCDescriptor::IsAppDescriptor() const { return m_isAppDescriptor; } +bool ODBCDescriptor::IsAppDescriptor() const { return is_app_descriptor_; } -void ODBCDescriptor::RegisterToStatement(ODBCStatement* statement, bool isApd) { - if (isApd) { - m_registeredOnStatementsAsApd.push_back(statement); +void ODBCDescriptor::RegisterToStatement(ODBCStatement* statement, bool is_apd) { + if (is_apd) { + registered_on_statements_as_apd_.push_back(statement); } else { - m_registeredOnStatementsAsArd.push_back(statement); + registered_on_statements_as_ard_.push_back(statement); } } -void ODBCDescriptor::DetachFromStatement(ODBCStatement* statement, bool isApd) { - auto& vectorToUpdate = - isApd ? m_registeredOnStatementsAsApd : m_registeredOnStatementsAsArd; - auto it = std::find(vectorToUpdate.begin(), vectorToUpdate.end(), statement); - if (it != vectorToUpdate.end()) { - vectorToUpdate.erase(it); +void ODBCDescriptor::DetachFromStatement(ODBCStatement* statement, bool is_apd) { + auto& vector_to_update = + is_apd ? registered_on_statements_as_apd_ : registered_on_statements_as_ard_; + auto it = std::find(vector_to_update.begin(), vector_to_update.end(), statement); + if (it != vector_to_update.end()) { + vector_to_update.erase(it); } } void ODBCDescriptor::ReleaseDescriptor() { - for (ODBCStatement* stmt : m_registeredOnStatementsAsApd) { + for (ODBCStatement* stmt : registered_on_statements_as_apd_) { stmt->RevertAppDescriptor(true); } - for (ODBCStatement* stmt : m_registeredOnStatementsAsArd) { + for (ODBCStatement* stmt : registered_on_statements_as_ard_) { stmt->RevertAppDescriptor(false); } - if (m_owningConnection) { - m_owningConnection->dropDescriptor(this); + if (owning_connection_) { + owning_connection_->DropDescriptor(this); } } void ODBCDescriptor::PopulateFromResultSetMetadata(ResultSetMetadata* rsmd) { - m_records.assign(rsmd->GetColumnCount(), DescriptorRecord()); - m_highestOneBasedBoundRecord = m_records.size() + 1; - - for (size_t i = 0; i < m_records.size(); ++i) { - size_t oneBasedIndex = i + 1; - m_records[i].m_baseColumnName = rsmd->GetBaseColumnName(oneBasedIndex); - m_records[i].m_baseTableName = rsmd->GetBaseTableName(oneBasedIndex); - m_records[i].m_catalogName = rsmd->GetCatalogName(oneBasedIndex); - m_records[i].m_label = rsmd->GetColumnLabel(oneBasedIndex); - m_records[i].m_literalPrefix = rsmd->GetLiteralPrefix(oneBasedIndex); - m_records[i].m_literalSuffix = rsmd->GetLiteralSuffix(oneBasedIndex); - m_records[i].m_localTypeName = rsmd->GetLocalTypeName(oneBasedIndex); - m_records[i].m_name = rsmd->GetName(oneBasedIndex); - m_records[i].m_schemaName = rsmd->GetSchemaName(oneBasedIndex); - m_records[i].m_tableName = rsmd->GetTableName(oneBasedIndex); - m_records[i].m_typeName = rsmd->GetTypeName(oneBasedIndex); - m_records[i].m_conciseType = - GetSqlTypeForODBCVersion(rsmd->GetConciseType(oneBasedIndex), m_is2xConnection); - m_records[i].m_dataPtr = nullptr; - m_records[i].m_indicatorPtr = nullptr; - m_records[i].m_displaySize = rsmd->GetColumnDisplaySize(oneBasedIndex); - m_records[i].m_octetLength = rsmd->GetOctetLength(oneBasedIndex); - m_records[i].m_length = rsmd->GetLength(oneBasedIndex); - m_records[i].m_autoUniqueValue = - rsmd->IsAutoUnique(oneBasedIndex) ? SQL_TRUE : SQL_FALSE; - m_records[i].m_caseSensitive = - rsmd->IsCaseSensitive(oneBasedIndex) ? SQL_TRUE : SQL_FALSE; - m_records[i].m_datetimeIntervalPrecision; // TODO - update when rsmd adds this - m_records[i].m_numPrecRadix = rsmd->GetNumPrecRadix(oneBasedIndex); - m_records[i].m_datetimeIntervalCode; // TODO - m_records[i].m_fixedPrecScale = - rsmd->IsFixedPrecScale(oneBasedIndex) ? SQL_TRUE : SQL_FALSE; - m_records[i].m_nullable = rsmd->IsNullable(oneBasedIndex); - m_records[i].m_paramType = SQL_PARAM_INPUT; - m_records[i].m_precision = rsmd->GetPrecision(oneBasedIndex); - m_records[i].m_rowVer = SQL_FALSE; - m_records[i].m_scale = rsmd->GetScale(oneBasedIndex); - m_records[i].m_searchable = rsmd->IsSearchable(oneBasedIndex); - m_records[i].m_type = - GetSqlTypeForODBCVersion(rsmd->GetDataType(oneBasedIndex), m_is2xConnection); - m_records[i].m_unnamed = m_records[i].m_name.empty() ? SQL_TRUE : SQL_FALSE; - m_records[i].m_unsigned = rsmd->IsUnsigned(oneBasedIndex) ? SQL_TRUE : SQL_FALSE; - m_records[i].m_updatable = rsmd->GetUpdatable(oneBasedIndex); + records_.assign(rsmd->GetColumnCount(), DescriptorRecord()); + highest_one_based_bound_record_ = records_.size() + 1; + + for (size_t i = 0; i < records_.size(); ++i) { + size_t one_based_index = i + 1; + int16_t concise_type = rsmd->GetConciseType(one_based_index); + + records_[i].base_column_name = rsmd->GetBaseColumnName(one_based_index); + records_[i].base_table_name = rsmd->GetBaseTableName(one_based_index); + records_[i].catalog_name = rsmd->GetCatalogName(one_based_index); + records_[i].label = rsmd->GetColumnLabel(one_based_index); + records_[i].literal_prefix = rsmd->GetLiteralPrefix(one_based_index); + records_[i].literal_suffix = rsmd->GetLiteralSuffix(one_based_index); + records_[i].local_type_name = rsmd->GetLocalTypeName(one_based_index); + records_[i].name = rsmd->GetName(one_based_index); + records_[i].schema_name = rsmd->GetSchemaName(one_based_index); + records_[i].table_name = rsmd->GetTableName(one_based_index); + records_[i].type_name = rsmd->GetTypeName(one_based_index, concise_type); + records_[i].concise_type = GetSqlTypeForODBCVersion(concise_type, is_2x_connection_); + records_[i].data_ptr = nullptr; + records_[i].indicator_ptr = nullptr; + records_[i].display_size = rsmd->GetColumnDisplaySize(one_based_index); + records_[i].octet_length = rsmd->GetOctetLength(one_based_index); + records_[i].length = rsmd->GetLength(one_based_index); + records_[i].auto_unique_value = + rsmd->IsAutoUnique(one_based_index) ? SQL_TRUE : SQL_FALSE; + records_[i].case_sensitive = + rsmd->IsCaseSensitive(one_based_index) ? SQL_TRUE : SQL_FALSE; + records_[i].datetime_interval_precision; // TODO - update when rsmd adds this + SQLINTEGER num_prec_radix = rsmd->GetNumPrecRadix(one_based_index); + records_[i].num_prec_radix = num_prec_radix > 0 ? num_prec_radix : 0; + records_[i].datetime_interval_code; // TODO + records_[i].fixed_prec_scale = + rsmd->IsFixedPrecScale(one_based_index) ? SQL_TRUE : SQL_FALSE; + records_[i].nullable = rsmd->IsNullable(one_based_index); + records_[i].param_type = SQL_PARAM_INPUT; + records_[i].precision = rsmd->GetPrecision(one_based_index); + records_[i].row_ver = SQL_FALSE; + records_[i].scale = rsmd->GetScale(one_based_index); + records_[i].searchable = rsmd->IsSearchable(one_based_index); + records_[i].type = rsmd->GetDataType(one_based_index); + records_[i].unnamed = records_[i].name.empty() ? SQL_TRUE : SQL_FALSE; + records_[i].is_unsigned = rsmd->IsUnsigned(one_based_index) ? SQL_TRUE : SQL_FALSE; + records_[i].updatable = rsmd->GetUpdatable(one_based_index); } } const std::vector& ODBCDescriptor::GetRecords() const { - return m_records; + return records_; } -std::vector& ODBCDescriptor::GetRecords() { return m_records; } +std::vector& ODBCDescriptor::GetRecords() { return records_; } -void ODBCDescriptor::BindCol(SQLSMALLINT recordNumber, SQLSMALLINT cType, - SQLPOINTER dataPtr, SQLLEN bufferLength, - SQLLEN* indicatorPtr) { - assert(m_isAppDescriptor); - assert(m_isWritable); +void ODBCDescriptor::BindCol(SQLSMALLINT record_number, SQLSMALLINT c_type, + SQLPOINTER data_ptr, SQLLEN buffer_length, + SQLLEN* indicator_ptr) { + assert(is_app_descriptor_); + assert(is_writable_); // The set of records auto-expands to the supplied record number. - if (m_records.size() < recordNumber) { - m_records.resize(recordNumber); + if (records_.size() < record_number) { + records_.resize(record_number); } - SQLSMALLINT zeroBasedRecordIndex = recordNumber - 1; - DescriptorRecord& record = m_records[zeroBasedRecordIndex]; + SQLSMALLINT zero_based_record_index = record_number - 1; + DescriptorRecord& record = records_[zero_based_record_index]; - record.m_type = cType; - record.m_indicatorPtr = indicatorPtr; - record.m_length = bufferLength; + record.type = c_type; + record.indicator_ptr = indicator_ptr; + record.length = buffer_length; // Initialize default precision and scale for SQL_C_NUMERIC. - if (record.m_type == SQL_C_NUMERIC) { - record.m_precision = 38; - record.m_scale = 0; + if (record.type == SQL_C_NUMERIC) { + record.precision = 38; + record.scale = 0; } - SetDataPtrOnRecord(dataPtr, recordNumber); + SetDataPtrOnRecord(data_ptr, record_number); } -void ODBCDescriptor::SetDataPtrOnRecord(SQLPOINTER dataPtr, SQLSMALLINT recordNumber) { - assert(recordNumber <= m_records.size()); - DescriptorRecord& record = m_records[recordNumber - 1]; - if (dataPtr) { +void ODBCDescriptor::SetDataPtrOnRecord(SQLPOINTER data_ptr, SQLSMALLINT record_number) { + assert(record_number <= records_.size()); + DescriptorRecord& record = records_[record_number - 1]; + if (data_ptr) { record.CheckConsistency(); - record.m_isBound = true; + record.is_bound = true; } else { - record.m_isBound = false; + record.is_bound = false; } - record.m_dataPtr = dataPtr; + record.data_ptr = data_ptr; // Bookkeeping on the highest bound record (used for returning SQL_DESC_COUNT) - if (m_highestOneBasedBoundRecord < recordNumber && dataPtr) { - m_highestOneBasedBoundRecord = recordNumber; - } else if (m_highestOneBasedBoundRecord == recordNumber && !dataPtr) { - m_highestOneBasedBoundRecord = CalculateHighestBoundRecord(m_records); + if (highest_one_based_bound_record_ < record_number && data_ptr) { + highest_one_based_bound_record_ = record_number; + } else if (highest_one_based_bound_record_ == record_number && !data_ptr) { + highest_one_based_bound_record_ = CalculateHighestBoundRecord(records_); } - m_hasBindingsChanged = true; + has_bindings_changed_ = true; } void DescriptorRecord::CheckConsistency() { diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_environment.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_environment.cc index 7781235688fd8..d0f93813e8f49 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_environment.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_environment.cc @@ -35,49 +35,49 @@ using driver::odbcabstraction::Driver; // Public // ========================================================================================= ODBCEnvironment::ODBCEnvironment(std::shared_ptr driver) - : m_driver(std::move(driver)), - m_diagnostics(new Diagnostics(m_driver->GetDiagnostics().GetVendor(), - m_driver->GetDiagnostics().GetDataSourceComponent(), - driver::odbcabstraction::V_2)), - m_version(SQL_OV_ODBC2), - m_connectionPooling(SQL_CP_OFF) {} + : driver_(std::move(driver)), + diagnostics_(new Diagnostics(driver_->GetDiagnostics().GetVendor(), + driver_->GetDiagnostics().GetDataSourceComponent(), + driver::odbcabstraction::V_2)), + version_(SQL_OV_ODBC2), + connection_pooling_(SQL_CP_OFF) {} -Diagnostics& ODBCEnvironment::GetDiagnostics_Impl() { return *m_diagnostics; } +Diagnostics& ODBCEnvironment::GetDiagnosticsImpl() { return *diagnostics_; } -SQLINTEGER ODBCEnvironment::getODBCVersion() const { return m_version; } +SQLINTEGER ODBCEnvironment::GetODBCVersion() const { return version_; } -void ODBCEnvironment::setODBCVersion(SQLINTEGER version) { - if (version != m_version) { - m_version = version; - m_diagnostics.reset(new Diagnostics( - m_diagnostics->GetVendor(), m_diagnostics->GetDataSourceComponent(), - version == SQL_OV_ODBC2 ? driver::odbcabstraction::V_2 - : driver::odbcabstraction::V_3)); +void ODBCEnvironment::SetODBCVersion(SQLINTEGER version) { + if (version != version_) { + version_ = version; + diagnostics_.reset( + new Diagnostics(diagnostics_->GetVendor(), diagnostics_->GetDataSourceComponent(), + version == SQL_OV_ODBC2 ? driver::odbcabstraction::V_2 + : driver::odbcabstraction::V_3)); } } -SQLINTEGER ODBCEnvironment::getConnectionPooling() const { return m_connectionPooling; } +SQLINTEGER ODBCEnvironment::GetConnectionPooling() const { return connection_pooling_; } -void ODBCEnvironment::setConnectionPooling(SQLINTEGER connectionPooling) { - m_connectionPooling = connectionPooling; +void ODBCEnvironment::SetConnectionPooling(SQLINTEGER connection_pooling) { + connection_pooling_ = connection_pooling; } std::shared_ptr ODBCEnvironment::CreateConnection() { - std::shared_ptr spiConnection = m_driver->CreateConnection( - m_version == SQL_OV_ODBC2 ? driver::odbcabstraction::V_2 - : driver::odbcabstraction::V_3); - std::shared_ptr newConn = - std::make_shared(*this, spiConnection); - m_connections.push_back(newConn); - return newConn; + std::shared_ptr spi_connection = + driver_->CreateConnection(version_ == SQL_OV_ODBC2 ? driver::odbcabstraction::V_2 + : driver::odbcabstraction::V_3); + std::shared_ptr new_conn = + std::make_shared(*this, spi_connection); + connections_.push_back(new_conn); + return new_conn; } void ODBCEnvironment::DropConnection(ODBCConnection* conn) { - auto it = std::find_if(m_connections.begin(), m_connections.end(), + auto it = std::find_if(connections_.begin(), connections_.end(), [&conn](const std::shared_ptr& connection) { return connection.get() == conn; }); - if (m_connections.end() != it) { - m_connections.erase(it); + if (connections_.end() != it) { + connections_.erase(it); } } diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc index a5db0cc25dde0..231653acb2513 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/odbc_impl/odbc_statement.cc @@ -43,22 +43,22 @@ using driver::odbcabstraction::Statement; namespace { void DescriptorToHandle(SQLPOINTER output, ODBCDescriptor* descriptor, - SQLINTEGER* lenPtr) { + SQLINTEGER* len_ptr) { if (output) { - SQLHANDLE* outputHandle = static_cast(output); - *outputHandle = reinterpret_cast(descriptor); + SQLHANDLE* output_handle = static_cast(output); + *output_handle = reinterpret_cast(descriptor); } - if (lenPtr) { - *lenPtr = sizeof(SQLHANDLE); + if (len_ptr) { + *len_ptr = sizeof(SQLHANDLE); } } size_t GetLength(const DescriptorRecord& record) { - switch (record.m_type) { + switch (record.type) { case SQL_C_CHAR: case SQL_C_WCHAR: case SQL_C_BINARY: - return record.m_length; + return record.length; case SQL_C_BIT: case SQL_C_TINYINT: @@ -112,12 +112,12 @@ size_t GetLength(const DescriptorRecord& record) { case SQL_C_INTERVAL_MONTH: return sizeof(SQL_INTERVAL_STRUCT); default: - return record.m_length; + return record.length; } } -SQLSMALLINT getCTypeForSQLType(const DescriptorRecord& record) { - switch (record.m_conciseType) { +SQLSMALLINT getc_typeForSQLType(const DescriptorRecord& record) { + switch (record.concise_type) { case SQL_CHAR: case SQL_VARCHAR: case SQL_LONGVARCHAR: @@ -134,16 +134,16 @@ SQLSMALLINT getCTypeForSQLType(const DescriptorRecord& record) { return SQL_C_BINARY; case SQL_TINYINT: - return record.m_unsigned ? SQL_C_UTINYINT : SQL_C_STINYINT; + return record.is_unsigned ? SQL_C_UTINYINT : SQL_C_STINYINT; case SQL_SMALLINT: - return record.m_unsigned ? SQL_C_USHORT : SQL_C_SSHORT; + return record.is_unsigned ? SQL_C_USHORT : SQL_C_SSHORT; case SQL_INTEGER: - return record.m_unsigned ? SQL_C_ULONG : SQL_C_SLONG; + return record.is_unsigned ? SQL_C_ULONG : SQL_C_SLONG; case SQL_BIGINT: - return record.m_unsigned ? SQL_C_UBIGINT : SQL_C_SBIGINT; + return record.is_unsigned ? SQL_C_UBIGINT : SQL_C_SBIGINT; case SQL_REAL: return SQL_C_FLOAT; @@ -192,16 +192,16 @@ SQLSMALLINT getCTypeForSQLType(const DescriptorRecord& record) { return SQL_INTERVAL_MONTH; default: - throw DriverException("Unknown SQL type: " + std::to_string(record.m_conciseType), + throw DriverException("Unknown SQL type: " + std::to_string(record.concise_type), "HY003"); } } void CopyAttribute(Statement& source, Statement& target, - Statement::StatementAttributeId attributeId) { - auto optionalValue = source.GetAttribute(attributeId); - if (optionalValue) { - target.SetAttribute(attributeId, *optionalValue); + Statement::StatementAttributeId attribute_id) { + auto optional_value = source.GetAttribute(attribute_id); + if (optional_value) { + target.SetAttribute(attribute_id, *optional_value); } } } // namespace @@ -210,36 +210,36 @@ void CopyAttribute(Statement& source, Statement& target, // ========================================================================================= ODBCStatement::ODBCStatement( ODBCConnection& connection, - std::shared_ptr spiStatement) - : m_connection(connection), - m_spiStatement(std::move(spiStatement)), - m_diagnostics(&m_spiStatement->GetDiagnostics()), - m_builtInArd(std::make_shared(m_spiStatement->GetDiagnostics(), - nullptr, this, true, true, - connection.IsOdbc2Connection())), - m_builtInApd(std::make_shared(m_spiStatement->GetDiagnostics(), - nullptr, this, true, true, - connection.IsOdbc2Connection())), - m_ipd(std::make_shared(m_spiStatement->GetDiagnostics(), nullptr, - this, false, true, - connection.IsOdbc2Connection())), - m_ird(std::make_shared(m_spiStatement->GetDiagnostics(), nullptr, - this, false, false, - connection.IsOdbc2Connection())), - m_currentArd(m_builtInApd.get()), - m_currentApd(m_builtInApd.get()), - m_rowNumber(0), - m_maxRows(0), - m_rowsetSize(1), - m_isPrepared(false), - m_hasReachedEndOfResult(false) {} - -ODBCConnection& ODBCStatement::GetConnection() { return m_connection; } + std::shared_ptr spi_statement) + : connection_(connection), + spi_statement_(std::move(spi_statement)), + diagnostics_(&spi_statement_->GetDiagnostics()), + built_in_ard_(std::make_shared(spi_statement_->GetDiagnostics(), + nullptr, this, true, true, + connection.IsOdbc2Connection())), + built_in_apd_(std::make_shared(spi_statement_->GetDiagnostics(), + nullptr, this, true, true, + connection.IsOdbc2Connection())), + ipd_(std::make_shared(spi_statement_->GetDiagnostics(), nullptr, + this, false, true, + connection.IsOdbc2Connection())), + ird_(std::make_shared(spi_statement_->GetDiagnostics(), nullptr, + this, false, false, + connection.IsOdbc2Connection())), + current_ard_(built_in_apd_.get()), + current_apd_(built_in_apd_.get()), + row_number_(0), + max_rows_(0), + rowset_size_(1), + is_prepared_(false), + has_reached_end_of_result_(false) {} + +ODBCConnection& ODBCStatement::GetConnection() { return connection_; } void ODBCStatement::CopyAttributesFromConnection(ODBCConnection& connection) { - ODBCStatement& trackingStatement = connection.GetTrackingStatement(); + ODBCStatement& tracking_statement = connection.GetTrackingStatement(); - // Get abstraction attributes and copy to this m_spiStatement. + // Get abstraction attributes and copy to this spi_statement_. // Possible ODBC attributes are below, but many of these are not supported by warpdrive // or ODBCAbstaction: // SQL_ATTR_ASYNC_ENABLE: @@ -254,166 +254,166 @@ void ODBCStatement::CopyAttributesFromConnection(ODBCConnection& connection) { // SQL_ATTR_RETRIEVE_DATA: // SQL_ATTR_SIMULATE_CURSOR: // SQL_ATTR_USE_BOOKMARKS: - CopyAttribute(*trackingStatement.m_spiStatement, *m_spiStatement, + CopyAttribute(*tracking_statement.spi_statement_, *spi_statement_, Statement::METADATA_ID); - CopyAttribute(*trackingStatement.m_spiStatement, *m_spiStatement, + CopyAttribute(*tracking_statement.spi_statement_, *spi_statement_, Statement::MAX_LENGTH); - CopyAttribute(*trackingStatement.m_spiStatement, *m_spiStatement, Statement::NOSCAN); - CopyAttribute(*trackingStatement.m_spiStatement, *m_spiStatement, + CopyAttribute(*tracking_statement.spi_statement_, *spi_statement_, Statement::NOSCAN); + CopyAttribute(*tracking_statement.spi_statement_, *spi_statement_, Statement::QUERY_TIMEOUT); // SQL_ATTR_ROW_BIND_TYPE: - m_currentArd->SetHeaderField( + current_ard_->SetHeaderField( SQL_DESC_BIND_TYPE, reinterpret_cast( - static_cast(trackingStatement.m_currentArd->GetBoundStructOffset())), + static_cast(tracking_statement.current_ard_->GetBoundStructOffset())), 0); } -bool ODBCStatement::isPrepared() const { return m_isPrepared; } +bool ODBCStatement::IsPrepared() const { return is_prepared_; } void ODBCStatement::Prepare(const std::string& query) { boost::optional > metadata = - m_spiStatement->Prepare(query); + spi_statement_->Prepare(query); if (metadata) { - m_ird->PopulateFromResultSetMetadata(metadata->get()); + ird_->PopulateFromResultSetMetadata(metadata->get()); } - m_isPrepared = true; + is_prepared_ = true; } void ODBCStatement::ExecutePrepared() { - if (!m_isPrepared) { + if (!is_prepared_) { throw DriverException("Function sequence error", "HY010"); } - if (m_spiStatement->ExecutePrepared()) { - m_currenResult = m_spiStatement->GetResultSet(); - m_ird->PopulateFromResultSetMetadata( - m_spiStatement->GetResultSet()->GetMetadata().get()); - m_hasReachedEndOfResult = false; + if (spi_statement_->ExecutePrepared()) { + current_result_ = spi_statement_->GetResultSet(); + ird_->PopulateFromResultSetMetadata( + spi_statement_->GetResultSet()->GetMetadata().get()); + has_reached_end_of_result_ = false; } } void ODBCStatement::ExecuteDirect(const std::string& query) { - if (m_spiStatement->Execute(query)) { - m_currenResult = m_spiStatement->GetResultSet(); - m_ird->PopulateFromResultSetMetadata(m_currenResult->GetMetadata().get()); - m_hasReachedEndOfResult = false; + if (spi_statement_->Execute(query)) { + current_result_ = spi_statement_->GetResultSet(); + ird_->PopulateFromResultSetMetadata(current_result_->GetMetadata().get()); + has_reached_end_of_result_ = false; } // Direct execution wipes out the prepared state. - m_isPrepared = false; + is_prepared_ = false; } bool ODBCStatement::Fetch(size_t rows) { - if (m_hasReachedEndOfResult) { - m_ird->SetRowsProcessed(0); + if (has_reached_end_of_result_) { + ird_->SetRowsProcessed(0); return false; } - if (m_maxRows) { - rows = std::min(rows, m_maxRows - m_rowNumber); + if (max_rows_) { + rows = std::min(rows, max_rows_ - row_number_); } - if (m_currentArd->HaveBindingsChanged()) { - // TODO: Deal handle when offset != bufferlength. + if (current_ard_->HaveBindingsChanged()) { + // TODO: Deal handle when offset != buffer_length. // Wipe out all bindings in the ResultSet. // Note that the number of ARD records can both be more or less // than the number of columns. - for (size_t i = 0; i < m_ird->GetRecords().size(); i++) { - if (i < m_currentArd->GetRecords().size() && - m_currentArd->GetRecords()[i].m_isBound) { - const DescriptorRecord& ardRecord = m_currentArd->GetRecords()[i]; - m_currenResult->BindColumn(i + 1, ardRecord.m_type, ardRecord.m_precision, - ardRecord.m_scale, ardRecord.m_dataPtr, - GetLength(ardRecord), ardRecord.m_indicatorPtr); + for (size_t i = 0; i < ird_->GetRecords().size(); i++) { + if (i < current_ard_->GetRecords().size() && + current_ard_->GetRecords()[i].is_bound) { + const DescriptorRecord& ard_record = current_ard_->GetRecords()[i]; + current_result_->BindColumn(i + 1, ard_record.type, ard_record.precision, + ard_record.scale, ard_record.data_ptr, + GetLength(ard_record), ard_record.indicator_ptr); } else { - m_currenResult->BindColumn(i + 1, - driver::odbcabstraction::CDataType_CHAR - /* arbitrary type, not used */, - 0, 0, nullptr, 0, nullptr); + current_result_->BindColumn(i + 1, + driver::odbcabstraction::CDataType_CHAR + /* arbitrary type, not used */, + 0, 0, nullptr, 0, nullptr); } } - m_currentArd->NotifyBindingsHavePropagated(); + current_ard_->NotifyBindingsHavePropagated(); } - size_t rowsFetched = m_currenResult->Move(rows, m_currentArd->GetBindOffset(), - m_currentArd->GetBoundStructOffset(), - m_ird->GetArrayStatusPtr()); - m_ird->SetRowsProcessed(static_cast(rowsFetched)); + size_t rows_fetched = current_result_->Move(rows, current_ard_->GetBindOffset(), + current_ard_->GetBoundStructOffset(), + ird_->GetArrayStatusPtr()); + ird_->SetRowsProcessed(static_cast(rows_fetched)); - m_rowNumber += rowsFetched; - m_hasReachedEndOfResult = rowsFetched != rows; - return rowsFetched != 0; + row_number_ += rows_fetched; + has_reached_end_of_result_ = rows_fetched != rows; + return rows_fetched != 0; } -void ODBCStatement::GetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER output, - SQLINTEGER bufferSize, SQLINTEGER* strLenPtr, - bool isUnicode) { +void ODBCStatement::GetStmtAttr(SQLINTEGER statement_attribute, SQLPOINTER output, + SQLINTEGER buffer_size, SQLINTEGER* str_len_ptr, + bool is_unicode) { using driver::odbcabstraction::Statement; - boost::optional spiAttribute; - switch (statementAttribute) { + boost::optional spi_attribute; + switch (statement_attribute) { // Descriptor accessor attributes case SQL_ATTR_APP_PARAM_DESC: - DescriptorToHandle(output, m_currentApd, strLenPtr); + DescriptorToHandle(output, current_apd_, str_len_ptr); return; case SQL_ATTR_APP_ROW_DESC: - DescriptorToHandle(output, m_currentArd, strLenPtr); + DescriptorToHandle(output, current_ard_, str_len_ptr); return; case SQL_ATTR_IMP_PARAM_DESC: - DescriptorToHandle(output, m_ipd.get(), strLenPtr); + DescriptorToHandle(output, ipd_.get(), str_len_ptr); return; case SQL_ATTR_IMP_ROW_DESC: - DescriptorToHandle(output, m_ird.get(), strLenPtr); + DescriptorToHandle(output, ird_.get(), str_len_ptr); return; // Attributes that are descriptor fields case SQL_ATTR_PARAM_BIND_OFFSET_PTR: - m_currentApd->GetHeaderField(SQL_DESC_BIND_OFFSET_PTR, output, bufferSize, - strLenPtr); + current_apd_->GetHeaderField(SQL_DESC_BIND_OFFSET_PTR, output, buffer_size, + str_len_ptr); return; case SQL_ATTR_PARAM_BIND_TYPE: - m_currentApd->GetHeaderField(SQL_DESC_BIND_TYPE, output, bufferSize, strLenPtr); + current_apd_->GetHeaderField(SQL_DESC_BIND_TYPE, output, buffer_size, str_len_ptr); return; case SQL_ATTR_PARAM_OPERATION_PTR: - m_currentApd->GetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, output, bufferSize, - strLenPtr); + current_apd_->GetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, output, buffer_size, + str_len_ptr); return; case SQL_ATTR_PARAM_STATUS_PTR: - m_ipd->GetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, output, bufferSize, strLenPtr); + ipd_->GetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, output, buffer_size, str_len_ptr); return; case SQL_ATTR_PARAMS_PROCESSED_PTR: - m_ipd->GetHeaderField(SQL_DESC_ROWS_PROCESSED_PTR, output, bufferSize, strLenPtr); + ipd_->GetHeaderField(SQL_DESC_ROWS_PROCESSED_PTR, output, buffer_size, str_len_ptr); return; case SQL_ATTR_PARAMSET_SIZE: - m_currentApd->GetHeaderField(SQL_DESC_ARRAY_SIZE, output, bufferSize, strLenPtr); + current_apd_->GetHeaderField(SQL_DESC_ARRAY_SIZE, output, buffer_size, str_len_ptr); return; case SQL_ATTR_ROW_ARRAY_SIZE: - m_currentArd->GetHeaderField(SQL_DESC_ARRAY_SIZE, output, bufferSize, strLenPtr); + current_ard_->GetHeaderField(SQL_DESC_ARRAY_SIZE, output, buffer_size, str_len_ptr); return; case SQL_ATTR_ROW_BIND_OFFSET_PTR: - m_currentArd->GetHeaderField(SQL_DESC_BIND_OFFSET_PTR, output, bufferSize, - strLenPtr); + current_ard_->GetHeaderField(SQL_DESC_BIND_OFFSET_PTR, output, buffer_size, + str_len_ptr); return; case SQL_ATTR_ROW_BIND_TYPE: - m_currentArd->GetHeaderField(SQL_DESC_BIND_TYPE, output, bufferSize, strLenPtr); + current_ard_->GetHeaderField(SQL_DESC_BIND_TYPE, output, buffer_size, str_len_ptr); return; case SQL_ATTR_ROW_OPERATION_PTR: - m_currentArd->GetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, output, bufferSize, - strLenPtr); + current_ard_->GetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, output, buffer_size, + str_len_ptr); return; case SQL_ATTR_ROW_STATUS_PTR: - m_ird->GetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, output, bufferSize, strLenPtr); + ird_->GetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, output, buffer_size, str_len_ptr); return; case SQL_ATTR_ROWS_FETCHED_PTR: - m_ird->GetHeaderField(SQL_DESC_ROWS_PROCESSED_PTR, output, bufferSize, strLenPtr); + ird_->GetHeaderField(SQL_DESC_ROWS_PROCESSED_PTR, output, buffer_size, str_len_ptr); return; case SQL_ATTR_ASYNC_ENABLE: - GetAttribute(static_cast(SQL_ASYNC_ENABLE_OFF), output, bufferSize, - strLenPtr); + GetAttribute(static_cast(SQL_ASYNC_ENABLE_OFF), output, buffer_size, + str_len_ptr); return; #ifdef SQL_ATTR_ASYNC_STMT_EVENT @@ -429,96 +429,97 @@ void ODBCStatement::GetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER output throw DriverException("Unsupported attribute", "HYC00"); #endif case SQL_ATTR_CURSOR_SCROLLABLE: - GetAttribute(static_cast(SQL_NONSCROLLABLE), output, bufferSize, - strLenPtr); + GetAttribute(static_cast(SQL_NONSCROLLABLE), output, buffer_size, + str_len_ptr); return; case SQL_ATTR_CURSOR_SENSITIVITY: - GetAttribute(static_cast(SQL_UNSPECIFIED), output, bufferSize, strLenPtr); + GetAttribute(static_cast(SQL_UNSPECIFIED), output, buffer_size, + str_len_ptr); return; case SQL_ATTR_CURSOR_TYPE: - GetAttribute(static_cast(SQL_CURSOR_FORWARD_ONLY), output, bufferSize, - strLenPtr); + GetAttribute(static_cast(SQL_CURSOR_FORWARD_ONLY), output, buffer_size, + str_len_ptr); return; case SQL_ATTR_ENABLE_AUTO_IPD: - GetAttribute(static_cast(SQL_FALSE), output, bufferSize, strLenPtr); + GetAttribute(static_cast(SQL_FALSE), output, buffer_size, str_len_ptr); return; case SQL_ATTR_FETCH_BOOKMARK_PTR: - GetAttribute(static_cast(NULL), output, bufferSize, strLenPtr); + GetAttribute(static_cast(NULL), output, buffer_size, str_len_ptr); return; case SQL_ATTR_KEYSET_SIZE: - GetAttribute(static_cast(0), output, bufferSize, strLenPtr); + GetAttribute(static_cast(0), output, buffer_size, str_len_ptr); return; case SQL_ATTR_ROW_NUMBER: - GetAttribute(static_cast(m_rowNumber), output, bufferSize, strLenPtr); + GetAttribute(static_cast(row_number_), output, buffer_size, str_len_ptr); return; case SQL_ATTR_SIMULATE_CURSOR: - GetAttribute(static_cast(SQL_SC_UNIQUE), output, bufferSize, strLenPtr); + GetAttribute(static_cast(SQL_SC_UNIQUE), output, buffer_size, str_len_ptr); return; case SQL_ATTR_USE_BOOKMARKS: - GetAttribute(static_cast(SQL_UB_OFF), output, bufferSize, strLenPtr); + GetAttribute(static_cast(SQL_UB_OFF), output, buffer_size, str_len_ptr); return; case SQL_ATTR_CONCURRENCY: - GetAttribute(static_cast(SQL_CONCUR_READ_ONLY), output, bufferSize, - strLenPtr); + GetAttribute(static_cast(SQL_CONCUR_READ_ONLY), output, buffer_size, + str_len_ptr); return; case SQL_ATTR_MAX_ROWS: - GetAttribute(static_cast(m_maxRows), output, bufferSize, strLenPtr); + GetAttribute(static_cast(max_rows_), output, buffer_size, str_len_ptr); return; case SQL_ATTR_RETRIEVE_DATA: - GetAttribute(static_cast(SQL_RD_ON), output, bufferSize, strLenPtr); + GetAttribute(static_cast(SQL_RD_ON), output, buffer_size, str_len_ptr); return; case SQL_ROWSET_SIZE: - GetAttribute(static_cast(m_rowsetSize), output, bufferSize, strLenPtr); + GetAttribute(static_cast(rowset_size_), output, buffer_size, str_len_ptr); return; // Driver-level statement attributes. These are all SQLULEN attributes. case SQL_ATTR_MAX_LENGTH: - spiAttribute = m_spiStatement->GetAttribute(Statement::MAX_LENGTH); + spi_attribute = spi_statement_->GetAttribute(Statement::MAX_LENGTH); break; case SQL_ATTR_METADATA_ID: - spiAttribute = m_spiStatement->GetAttribute(Statement::METADATA_ID); + spi_attribute = spi_statement_->GetAttribute(Statement::METADATA_ID); break; case SQL_ATTR_NOSCAN: - spiAttribute = m_spiStatement->GetAttribute(Statement::NOSCAN); + spi_attribute = spi_statement_->GetAttribute(Statement::NOSCAN); break; case SQL_ATTR_QUERY_TIMEOUT: - spiAttribute = m_spiStatement->GetAttribute(Statement::QUERY_TIMEOUT); + spi_attribute = spi_statement_->GetAttribute(Statement::QUERY_TIMEOUT); break; default: throw DriverException( - "Invalid statement attribute: " + std::to_string(statementAttribute), "HY092"); + "Invalid statement attribute: " + std::to_string(statement_attribute), "HY092"); } - if (spiAttribute) { - GetAttribute(static_cast(boost::get(*spiAttribute)), output, - bufferSize, strLenPtr); + if (spi_attribute) { + GetAttribute(static_cast(boost::get(*spi_attribute)), output, + buffer_size, str_len_ptr); return; } throw DriverException( - "Invalid statement attribute: " + std::to_string(statementAttribute), "HY092"); + "Invalid statement attribute: " + std::to_string(statement_attribute), "HY092"); } -void ODBCStatement::SetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER value, - SQLINTEGER bufferSize, bool isUnicode) { - size_t attributeToWrite = 0; +void ODBCStatement::SetStmtAttr(SQLINTEGER statement_attribute, SQLPOINTER value, + SQLINTEGER buffer_size, bool is_unicode) { + size_t attribute_to_write = 0; bool successfully_written = false; - switch (statementAttribute) { + switch (statement_attribute) { case SQL_ATTR_APP_PARAM_DESC: { ODBCDescriptor* desc = static_cast(value); - if (m_currentApd != desc) { - if (m_currentApd != m_builtInApd.get()) { - m_currentApd->DetachFromStatement(this, true); + if (current_apd_ != desc) { + if (current_apd_ != built_in_apd_.get()) { + current_apd_->DetachFromStatement(this, true); } - m_currentApd = desc; - if (m_currentApd != m_builtInApd.get()) { + current_apd_ = desc; + if (current_apd_ != built_in_apd_.get()) { desc->RegisterToStatement(this, true); } } @@ -526,12 +527,12 @@ void ODBCStatement::SetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER value, } case SQL_ATTR_APP_ROW_DESC: { ODBCDescriptor* desc = static_cast(value); - if (m_currentArd != desc) { - if (m_currentArd != m_builtInArd.get()) { - m_currentArd->DetachFromStatement(this, false); + if (current_ard_ != desc) { + if (current_ard_ != built_in_ard_.get()) { + current_ard_->DetachFromStatement(this, false); } - m_currentArd = desc; - if (m_currentArd != m_builtInArd.get()) { + current_ard_ = desc; + if (current_ard_ != built_in_ard_.get()) { desc->RegisterToStatement(this, false); } } @@ -543,40 +544,40 @@ void ODBCStatement::SetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER value, throw DriverException("Cannot assign implementation descriptor.", "HY017"); // Attributes that are descriptor fields case SQL_ATTR_PARAM_BIND_OFFSET_PTR: - m_currentApd->SetHeaderField(SQL_DESC_BIND_OFFSET_PTR, value, bufferSize); + current_apd_->SetHeaderField(SQL_DESC_BIND_OFFSET_PTR, value, buffer_size); return; case SQL_ATTR_PARAM_BIND_TYPE: - m_currentApd->SetHeaderField(SQL_DESC_BIND_TYPE, value, bufferSize); + current_apd_->SetHeaderField(SQL_DESC_BIND_TYPE, value, buffer_size); return; case SQL_ATTR_PARAM_OPERATION_PTR: - m_currentApd->SetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, value, bufferSize); + current_apd_->SetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, value, buffer_size); return; case SQL_ATTR_PARAM_STATUS_PTR: - m_ipd->SetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, value, bufferSize); + ipd_->SetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, value, buffer_size); return; case SQL_ATTR_PARAMS_PROCESSED_PTR: - m_ipd->SetHeaderField(SQL_DESC_ROWS_PROCESSED_PTR, value, bufferSize); + ipd_->SetHeaderField(SQL_DESC_ROWS_PROCESSED_PTR, value, buffer_size); return; case SQL_ATTR_PARAMSET_SIZE: - m_currentApd->SetHeaderField(SQL_DESC_ARRAY_SIZE, value, bufferSize); + current_apd_->SetHeaderField(SQL_DESC_ARRAY_SIZE, value, buffer_size); return; case SQL_ATTR_ROW_ARRAY_SIZE: - m_currentArd->SetHeaderField(SQL_DESC_ARRAY_SIZE, value, bufferSize); + current_ard_->SetHeaderField(SQL_DESC_ARRAY_SIZE, value, buffer_size); return; case SQL_ATTR_ROW_BIND_OFFSET_PTR: - m_currentArd->SetHeaderField(SQL_DESC_BIND_OFFSET_PTR, value, bufferSize); + current_ard_->SetHeaderField(SQL_DESC_BIND_OFFSET_PTR, value, buffer_size); return; case SQL_ATTR_ROW_BIND_TYPE: - m_currentArd->SetHeaderField(SQL_DESC_BIND_TYPE, value, bufferSize); + current_ard_->SetHeaderField(SQL_DESC_BIND_TYPE, value, buffer_size); return; case SQL_ATTR_ROW_OPERATION_PTR: - m_currentArd->SetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, value, bufferSize); + current_ard_->SetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, value, buffer_size); return; case SQL_ATTR_ROW_STATUS_PTR: - m_ird->SetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, value, bufferSize); + ird_->SetHeaderField(SQL_DESC_ARRAY_STATUS_PTR, value, buffer_size); return; case SQL_ATTR_ROWS_FETCHED_PTR: - m_ird->SetHeaderField(SQL_DESC_ROWS_PROCESSED_PTR, value, bufferSize); + ird_->SetHeaderField(SQL_DESC_ROWS_PROCESSED_PTR, value, buffer_size); return; case SQL_ATTR_ASYNC_ENABLE: @@ -630,7 +631,7 @@ void ODBCStatement::SetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER value, CheckIfAttributeIsSetToOnlyValidValue(value, static_cast(SQL_TRUE)); return; case SQL_ROWSET_SIZE: - SetAttribute(value, m_rowsetSize); + SetAttribute(value, rowset_size_); return; case SQL_ATTR_MAX_ROWS: @@ -638,27 +639,27 @@ void ODBCStatement::SetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER value, // Driver-leve statement attributes. These are all size_t attributes case SQL_ATTR_MAX_LENGTH: - SetAttribute(value, attributeToWrite); + SetAttribute(value, attribute_to_write); successfully_written = - m_spiStatement->SetAttribute(Statement::MAX_LENGTH, attributeToWrite); + spi_statement_->SetAttribute(Statement::MAX_LENGTH, attribute_to_write); break; case SQL_ATTR_METADATA_ID: - SetAttribute(value, attributeToWrite); + SetAttribute(value, attribute_to_write); successfully_written = - m_spiStatement->SetAttribute(Statement::METADATA_ID, attributeToWrite); + spi_statement_->SetAttribute(Statement::METADATA_ID, attribute_to_write); break; case SQL_ATTR_NOSCAN: - SetAttribute(value, attributeToWrite); + SetAttribute(value, attribute_to_write); successfully_written = - m_spiStatement->SetAttribute(Statement::NOSCAN, attributeToWrite); + spi_statement_->SetAttribute(Statement::NOSCAN, attribute_to_write); break; case SQL_ATTR_QUERY_TIMEOUT: - SetAttribute(value, attributeToWrite); + SetAttribute(value, attribute_to_write); successfully_written = - m_spiStatement->SetAttribute(Statement::QUERY_TIMEOUT, attributeToWrite); + spi_statement_->SetAttribute(Statement::QUERY_TIMEOUT, attribute_to_write); break; default: - throw DriverException("Invalid attribute: " + std::to_string(attributeToWrite), + throw DriverException("Invalid attribute: " + std::to_string(attribute_to_write), "HY092"); } if (!successfully_written) { @@ -669,119 +670,119 @@ void ODBCStatement::SetStmtAttr(SQLINTEGER statementAttribute, SQLPOINTER value, void ODBCStatement::RevertAppDescriptor(bool isApd) { if (isApd) { - m_currentApd = m_builtInApd.get(); + current_apd_ = built_in_apd_.get(); } else { - m_currentArd = m_builtInArd.get(); + current_ard_ = built_in_ard_.get(); } } -void ODBCStatement::closeCursor(bool suppressErrors) { - if (!suppressErrors && !m_currenResult) { +void ODBCStatement::CloseCursor(bool suppress_errors) { + if (!suppress_errors && !current_result_) { throw DriverException("Invalid cursor state", "28000"); } - if (m_currenResult) { - m_currenResult->Close(); - m_currenResult = nullptr; + if (current_result_) { + current_result_->Close(); + current_result_ = nullptr; } // Reset the fetching state of this statement. - m_currentArd->NotifyBindingsHaveChanged(); - m_rowNumber = 0; - m_hasReachedEndOfResult = false; + current_ard_->NotifyBindingsHaveChanged(); + row_number_ = 0; + has_reached_end_of_result_ = false; } -bool ODBCStatement::GetData(SQLSMALLINT recordNumber, SQLSMALLINT cType, - SQLPOINTER dataPtr, SQLLEN bufferLength, - SQLLEN* indicatorPtr) { - if (recordNumber == 0) { +bool ODBCStatement::GetData(SQLSMALLINT record_number, SQLSMALLINT c_type, + SQLPOINTER data_ptr, SQLLEN buffer_length, + SQLLEN* indicator_ptr) { + if (record_number == 0) { throw DriverException("Bookmarks are not supported", "07009"); - } else if (recordNumber > m_ird->GetRecords().size()) { - throw DriverException("Invalid column index: " + std::to_string(recordNumber), + } else if (record_number > ird_->GetRecords().size()) { + throw DriverException("Invalid column index: " + std::to_string(record_number), "07009"); } - SQLSMALLINT evaluatedCType = cType; + SQLSMALLINT evaluated_c_type = c_type; // TODO: Get proper default precision and scale from abstraction. int precision = 38; // arrow::Decimal128Type::kMaxPrecision; int scale = 0; - if (cType == SQL_ARD_TYPE) { - if (recordNumber > m_currentArd->GetRecords().size()) { - throw DriverException("Invalid column index: " + std::to_string(recordNumber), + if (c_type == SQL_ARD_TYPE) { + if (record_number > current_ard_->GetRecords().size()) { + throw DriverException("Invalid column index: " + std::to_string(record_number), "07009"); } - const DescriptorRecord& record = m_currentArd->GetRecords()[recordNumber - 1]; - evaluatedCType = record.m_conciseType; - precision = record.m_precision; - scale = record.m_scale; + const DescriptorRecord& record = current_ard_->GetRecords()[record_number - 1]; + evaluated_c_type = record.concise_type; + precision = record.precision; + scale = record.scale; } // Note: this is intentionally not an else if, since the type can be SQL_C_DEFAULT in // the ARD. - if (evaluatedCType == SQL_C_DEFAULT) { - if (recordNumber <= m_currentArd->GetRecords().size()) { - const DescriptorRecord& ardRecord = m_currentArd->GetRecords()[recordNumber - 1]; - precision = ardRecord.m_precision; - scale = ardRecord.m_scale; + if (evaluated_c_type == SQL_C_DEFAULT) { + if (record_number <= current_ard_->GetRecords().size()) { + const DescriptorRecord& ard_record = current_ard_->GetRecords()[record_number - 1]; + precision = ard_record.precision; + scale = ard_record.scale; } - const DescriptorRecord& irdRecord = m_ird->GetRecords()[recordNumber - 1]; - evaluatedCType = getCTypeForSQLType(irdRecord); + const DescriptorRecord& ird_record = ird_->GetRecords()[record_number - 1]; + evaluated_c_type = getc_typeForSQLType(ird_record); } - return m_currenResult->GetData(recordNumber, evaluatedCType, precision, scale, dataPtr, - bufferLength, indicatorPtr); + return current_result_->GetData(record_number, evaluated_c_type, precision, scale, + data_ptr, buffer_length, indicator_ptr); } -void ODBCStatement::releaseStatement() { - closeCursor(true); - m_connection.dropStatement(this); +void ODBCStatement::ReleaseStatement() { + CloseCursor(true); + connection_.DropStatement(this); } void ODBCStatement::GetTables(const std::string* catalog, const std::string* schema, const std::string* table, const std::string* tableType) { - closeCursor(true); - if (m_connection.IsOdbc2Connection()) { - m_currenResult = m_spiStatement->GetTables_V2(catalog, schema, table, tableType); + CloseCursor(true); + if (connection_.IsOdbc2Connection()) { + current_result_ = spi_statement_->GetTables_V2(catalog, schema, table, tableType); } else { - m_currenResult = m_spiStatement->GetTables_V3(catalog, schema, table, tableType); + current_result_ = spi_statement_->GetTables_V3(catalog, schema, table, tableType); } - m_ird->PopulateFromResultSetMetadata(m_currenResult->GetMetadata().get()); - m_hasReachedEndOfResult = false; + ird_->PopulateFromResultSetMetadata(current_result_->GetMetadata().get()); + has_reached_end_of_result_ = false; // Direct execution wipes out the prepared state. - m_isPrepared = false; + is_prepared_ = false; } void ODBCStatement::GetColumns(const std::string* catalog, const std::string* schema, const std::string* table, const std::string* column) { - closeCursor(true); - if (m_connection.IsOdbc2Connection()) { - m_currenResult = m_spiStatement->GetColumns_V2(catalog, schema, table, column); + CloseCursor(true); + if (connection_.IsOdbc2Connection()) { + current_result_ = spi_statement_->GetColumns_V2(catalog, schema, table, column); } else { - m_currenResult = m_spiStatement->GetColumns_V3(catalog, schema, table, column); + current_result_ = spi_statement_->GetColumns_V3(catalog, schema, table, column); } - m_ird->PopulateFromResultSetMetadata(m_currenResult->GetMetadata().get()); - m_hasReachedEndOfResult = false; + ird_->PopulateFromResultSetMetadata(current_result_->GetMetadata().get()); + has_reached_end_of_result_ = false; // Direct execution wipes out the prepared state. - m_isPrepared = false; + is_prepared_ = false; } -void ODBCStatement::GetTypeInfo(SQLSMALLINT dataType) { - closeCursor(true); - if (m_connection.IsOdbc2Connection()) { - m_currenResult = m_spiStatement->GetTypeInfo_V2(dataType); +void ODBCStatement::GetTypeInfo(SQLSMALLINT data_type) { + CloseCursor(true); + if (connection_.IsOdbc2Connection()) { + current_result_ = spi_statement_->GetTypeInfo_V2(data_type); } else { - m_currenResult = m_spiStatement->GetTypeInfo_V3(dataType); + current_result_ = spi_statement_->GetTypeInfo_V3(data_type); } - m_ird->PopulateFromResultSetMetadata(m_currenResult->GetMetadata().get()); - m_hasReachedEndOfResult = false; + ird_->PopulateFromResultSetMetadata(current_result_->GetMetadata().get()); + has_reached_end_of_result_ = false; // Direct execution wipes out the prepared state. - m_isPrepared = false; + is_prepared_ = false; } -void ODBCStatement::Cancel() { m_spiStatement->Cancel(); } +void ODBCStatement::Cancel() { spi_statement_->Cancel(); } diff --git a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc index d76b341f1273e..074e542bc3432 100644 --- a/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc +++ b/cpp/src/arrow/flight/sql/odbc/odbcabstraction/utils.cc @@ -34,11 +34,11 @@ boost::optional AsBool(const std::string& value) { } } -boost::optional AsBool(const Connection::ConnPropertyMap& connPropertyMap, +boost::optional AsBool(const Connection::ConnPropertyMap& conn_property_map, const std::string_view& property_name) { - auto extracted_property = connPropertyMap.find(property_name); + auto extracted_property = conn_property_map.find(std::string(property_name)); - if (extracted_property != connPropertyMap.end()) { + if (extracted_property != conn_property_map.end()) { return AsBool(extracted_property->second); } @@ -46,15 +46,15 @@ boost::optional AsBool(const Connection::ConnPropertyMap& connPropertyMap, } boost::optional AsInt32(int32_t min_value, - const Connection::ConnPropertyMap& connPropertyMap, + const Connection::ConnPropertyMap& conn_property_map, const std::string_view& property_name) { - auto extracted_property = connPropertyMap.find(property_name); + auto extracted_property = conn_property_map.find(std::string(property_name)); - if (extracted_property != connPropertyMap.end()) { - const int32_t stringColumnLength = std::stoi(extracted_property->second); + if (extracted_property != conn_property_map.end()) { + const int32_t string_column_length = std::stoi(extracted_property->second); - if (stringColumnLength >= min_value && stringColumnLength <= INT32_MAX) { - return stringColumnLength; + if (string_column_length >= min_value && string_column_length <= INT32_MAX) { + return string_column_length; } } return boost::none;