execution_state_impl.ipp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // Copyright (c) 2019-2024 Ruben Perez Hidalgo (rubenperez038 at gmail dot com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. #ifndef BOOST_MYSQL_IMPL_EXECUTION_STATE_IMPL_IPP
  8. #define BOOST_MYSQL_IMPL_EXECUTION_STATE_IMPL_IPP
  9. #pragma once
  10. #include <boost/mysql/detail/execution_processor/execution_state_impl.hpp>
  11. #include <boost/mysql/detail/row_impl.hpp>
  12. #include <boost/mysql/impl/internal/protocol/deserialization.hpp>
  13. void boost::mysql::detail::execution_state_impl::on_ok_packet_impl(const ok_view& pack)
  14. {
  15. eof_data_.has_value = true;
  16. eof_data_.affected_rows = pack.affected_rows;
  17. eof_data_.last_insert_id = pack.last_insert_id;
  18. eof_data_.warnings = pack.warnings;
  19. eof_data_.is_out_params = pack.is_out_params();
  20. info_.assign(pack.info.begin(), pack.info.end());
  21. }
  22. void boost::mysql::detail::execution_state_impl::reset_impl() noexcept
  23. {
  24. meta_.clear();
  25. eof_data_ = ok_data();
  26. info_.clear();
  27. }
  28. boost::mysql::error_code boost::mysql::detail::execution_state_impl::
  29. on_head_ok_packet_impl(const ok_view& pack, diagnostics&)
  30. {
  31. on_new_resultset();
  32. on_ok_packet_impl(pack);
  33. return error_code();
  34. }
  35. void boost::mysql::detail::execution_state_impl::on_num_meta_impl(std::size_t num_columns)
  36. {
  37. on_new_resultset();
  38. meta_.reserve(num_columns);
  39. }
  40. boost::mysql::error_code boost::mysql::detail::execution_state_impl::
  41. on_meta_impl(const coldef_view& coldef, bool, diagnostics&)
  42. {
  43. meta_.push_back(create_meta(coldef));
  44. return error_code();
  45. }
  46. boost::mysql::error_code boost::mysql::detail::execution_state_impl::on_row_impl(
  47. span<const std::uint8_t> msg,
  48. const output_ref&,
  49. std::vector<field_view>& fields
  50. )
  51. {
  52. // add row storage
  53. span<field_view> storage = add_fields(fields, meta_.size());
  54. // deserialize the row
  55. return deserialize_row(encoding(), msg, meta_, storage);
  56. }
  57. boost::mysql::error_code boost::mysql::detail::execution_state_impl::on_row_ok_packet_impl(const ok_view& pack
  58. )
  59. {
  60. on_ok_packet_impl(pack);
  61. return error_code();
  62. }
  63. #endif