File indexing completed on 2025-01-18 09:42:42
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MYSQL_IMPL_STATIC_RESULTS_IMPL_IPP
0009 #define BOOST_MYSQL_IMPL_STATIC_RESULTS_IMPL_IPP
0010
0011 #pragma once
0012
0013 #include <boost/mysql/detail/config.hpp>
0014 #include <boost/mysql/detail/execution_processor/static_results_impl.hpp>
0015 #include <boost/mysql/detail/row_impl.hpp>
0016
0017 #include <boost/mysql/impl/internal/protocol/protocol.hpp>
0018
0019 #ifdef BOOST_MYSQL_CXX14
0020 void boost::mysql::detail::static_results_erased_impl::reset_impl() noexcept
0021 {
0022 ext_.reset_fn()(ext_.rows());
0023 info_.clear();
0024 meta_.clear();
0025 resultset_index_ = 0;
0026 }
0027
0028 boost::mysql::error_code boost::mysql::detail::static_results_erased_impl::on_head_ok_packet_impl(
0029 const ok_view& pack,
0030 diagnostics& diag
0031 )
0032 {
0033 add_resultset();
0034 auto err = on_ok_packet_impl(pack);
0035 if (err)
0036 return err;
0037 return meta_check(diag);
0038 }
0039
0040 void boost::mysql::detail::static_results_erased_impl::on_num_meta_impl(std::size_t num_columns)
0041 {
0042 auto& resultset_data = add_resultset();
0043 meta_.reserve(meta_.size() + num_columns);
0044 resultset_data.meta_size = num_columns;
0045 }
0046
0047 boost::mysql::error_code boost::mysql::detail::static_results_erased_impl::on_meta_impl(
0048 const coldef_view& coldef,
0049 bool is_last,
0050 diagnostics& diag
0051 )
0052
0053 {
0054 std::size_t meta_index = meta_.size() - current_resultset().meta_offset;
0055
0056
0057 meta_.push_back(create_meta(coldef));
0058
0059
0060 pos_map_add_field(current_pos_map(), current_name_table(), meta_index, coldef.name);
0061
0062 return is_last ? meta_check(diag) : error_code();
0063 }
0064
0065 boost::mysql::error_code boost::mysql::detail::static_results_erased_impl::on_row_impl(
0066 span<const std::uint8_t> msg,
0067 const output_ref&,
0068 std::vector<field_view>& fields
0069 )
0070
0071 {
0072 auto meta = current_resultset_meta();
0073
0074
0075 fields.clear();
0076 span<field_view> storage = add_fields(fields, meta.size());
0077
0078
0079 auto err = deserialize_row(encoding(), msg, meta, storage);
0080 if (err)
0081 return err;
0082
0083
0084 return ext_.parse_fn(resultset_index_ - 1)(current_pos_map(), storage, ext_.rows());
0085 }
0086
0087 boost::mysql::error_code boost::mysql::detail::static_results_erased_impl::on_row_ok_packet_impl(
0088 const ok_view& pack
0089 )
0090 {
0091 return on_ok_packet_impl(pack);
0092 }
0093
0094 boost::mysql::detail::static_per_resultset_data& boost::mysql::detail::static_results_erased_impl::
0095 add_resultset()
0096 {
0097 ++resultset_index_;
0098 auto& resultset_data = current_resultset();
0099 resultset_data = static_per_resultset_data();
0100 resultset_data.meta_offset = meta_.size();
0101 resultset_data.info_offset = info_.size();
0102 pos_map_reset(current_pos_map());
0103 return resultset_data;
0104 }
0105
0106 boost::mysql::error_code boost::mysql::detail::static_results_erased_impl::on_ok_packet_impl(
0107 const ok_view& pack
0108 )
0109 {
0110 auto& resultset_data = current_resultset();
0111 resultset_data.affected_rows = pack.affected_rows;
0112 resultset_data.last_insert_id = pack.last_insert_id;
0113 resultset_data.warnings = pack.warnings;
0114 resultset_data.info_size = pack.info.size();
0115 resultset_data.has_ok_packet_data = true;
0116 resultset_data.is_out_params = pack.is_out_params();
0117 info_.insert(info_.end(), pack.info.begin(), pack.info.end());
0118 bool should_be_last = resultset_index_ == ext_.num_resultsets();
0119 bool is_last = !pack.more_results();
0120 return should_be_last == is_last ? error_code() : client_errc::num_resultsets_mismatch;
0121 }
0122 #endif
0123
0124 #endif