Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:42

0001 //
0002 // Copyright (c) 2019-2023 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
0003 //
0004 // Distributed under the Boost Software License, Version 1.0. (See accompanying
0005 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 //
0007 
0008 #ifndef BOOST_MYSQL_IMPL_STATIC_EXECUTION_STATE_IMPL_IPP
0009 #define BOOST_MYSQL_IMPL_STATIC_EXECUTION_STATE_IMPL_IPP
0010 
0011 #pragma once
0012 
0013 #include <boost/mysql/detail/execution_processor/static_execution_state_impl.hpp>
0014 #include <boost/mysql/detail/row_impl.hpp>
0015 
0016 #include <boost/mysql/impl/internal/protocol/protocol.hpp>
0017 
0018 #ifdef BOOST_MYSQL_CXX14
0019 void boost::mysql::detail::static_execution_state_erased_impl::reset_impl() noexcept
0020 {
0021     resultset_index_ = 0;
0022     ok_data_ = ok_packet_data();
0023     info_.clear();
0024     meta_.clear();
0025 }
0026 
0027 boost::mysql::error_code boost::mysql::detail::static_execution_state_erased_impl::on_head_ok_packet_impl(
0028     const ok_view& pack,
0029     diagnostics& diag
0030 )
0031 {
0032     on_new_resultset();
0033     auto err = on_ok_packet_impl(pack);
0034     if (err)
0035         return err;
0036     return meta_check(diag);
0037 }
0038 
0039 void boost::mysql::detail::static_execution_state_erased_impl::on_num_meta_impl(std::size_t num_columns)
0040 {
0041     on_new_resultset();
0042     meta_.reserve(num_columns);
0043 }
0044 
0045 boost::mysql::error_code boost::mysql::detail::static_execution_state_erased_impl::on_meta_impl(
0046     const coldef_view& coldef,
0047     bool is_last,
0048     diagnostics& diag
0049 )
0050 
0051 {
0052     std::size_t meta_index = meta_.size();
0053 
0054     // Store the object
0055     meta_.push_back(create_meta(coldef));
0056 
0057     // Record its position
0058     pos_map_add_field(current_pos_map(), current_name_table(), meta_index, coldef.name);
0059 
0060     return is_last ? meta_check(diag) : error_code();
0061 }
0062 
0063 boost::mysql::error_code boost::mysql::detail::static_execution_state_erased_impl::on_row_impl(
0064     span<const std::uint8_t> msg,
0065     const output_ref& ref,
0066     std::vector<field_view>& fields
0067 )
0068 
0069 {
0070     // check output
0071     if (ref.type_index() != ext_.type_index(resultset_index_ - 1))
0072         return client_errc::row_type_mismatch;
0073 
0074     // Allocate temporary space
0075     fields.clear();
0076     span<field_view> storage = add_fields(fields, meta_.size());
0077 
0078     // deserialize the row
0079     auto err = deserialize_row(encoding(), msg, meta_, storage);
0080     if (err)
0081         return err;
0082 
0083     // parse it into the output ref
0084     err = ext_.parse_fn(resultset_index_ - 1)(current_pos_map(), storage, ref);
0085     if (err)
0086         return err;
0087 
0088     return error_code();
0089 }
0090 
0091 boost::mysql::error_code boost::mysql::detail::static_execution_state_erased_impl::on_row_ok_packet_impl(
0092     const ok_view& pack
0093 )
0094 {
0095     return on_ok_packet_impl(pack);
0096 }
0097 
0098 void boost::mysql::detail::static_execution_state_erased_impl::on_new_resultset() noexcept
0099 {
0100     ++resultset_index_;
0101     ok_data_ = ok_packet_data{};
0102     info_.clear();
0103     meta_.clear();
0104     pos_map_reset(current_pos_map());
0105 }
0106 
0107 boost::mysql::error_code boost::mysql::detail::static_execution_state_erased_impl::on_ok_packet_impl(
0108     const ok_view& pack
0109 )
0110 {
0111     ok_data_.has_value = true;
0112     ok_data_.affected_rows = pack.affected_rows;
0113     ok_data_.last_insert_id = pack.last_insert_id;
0114     ok_data_.warnings = pack.warnings;
0115     ok_data_.is_out_params = pack.is_out_params();
0116     info_.assign(pack.info.begin(), pack.info.end());
0117     bool should_be_last = resultset_index_ == ext_.num_resultsets();
0118     bool is_last = !pack.more_results();
0119     return should_be_last == is_last ? error_code() : client_errc::num_resultsets_mismatch;
0120 }
0121 #endif
0122 
0123 #endif