File indexing completed on 2025-12-16 09:58:26
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_MYSQL_CONNECTION_HPP
0009 #define BOOST_MYSQL_CONNECTION_HPP
0010
0011 #include <boost/mysql/buffer_params.hpp>
0012 #include <boost/mysql/defaults.hpp>
0013 #include <boost/mysql/diagnostics.hpp>
0014 #include <boost/mysql/error_code.hpp>
0015 #include <boost/mysql/execution_state.hpp>
0016 #include <boost/mysql/handshake_params.hpp>
0017 #include <boost/mysql/metadata_mode.hpp>
0018 #include <boost/mysql/results.hpp>
0019 #include <boost/mysql/rows_view.hpp>
0020 #include <boost/mysql/statement.hpp>
0021 #include <boost/mysql/string_view.hpp>
0022
0023 #include <boost/mysql/detail/access.hpp>
0024 #include <boost/mysql/detail/algo_params.hpp>
0025 #include <boost/mysql/detail/connection_impl.hpp>
0026 #include <boost/mysql/detail/engine_stream_adaptor.hpp>
0027 #include <boost/mysql/detail/execution_concepts.hpp>
0028 #include <boost/mysql/detail/rebind_executor.hpp>
0029 #include <boost/mysql/detail/socket_stream.hpp>
0030 #include <boost/mysql/detail/throw_on_error_loc.hpp>
0031 #include <boost/mysql/detail/writable_field_traits.hpp>
0032
0033 #include <boost/assert.hpp>
0034
0035 #include <cstddef>
0036 #include <type_traits>
0037 #include <utility>
0038
0039
0040 namespace boost {
0041
0042 namespace mysql {
0043
0044
0045 template <class... StaticRow>
0046 class static_execution_state;
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064
0065
0066
0067
0068
0069
0070
0071
0072
0073 template <class Stream>
0074 class connection
0075 {
0076 detail::connection_impl impl_;
0077
0078 public:
0079
0080
0081
0082
0083
0084
0085
0086
0087
0088
0089
0090 template <
0091 class... Args,
0092 class EnableIf = typename std::enable_if<std::is_constructible<Stream, Args...>::value>::type>
0093 connection(Args&&... args) : connection(buffer_params(), std::forward<Args>(args)...)
0094 {
0095 }
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 template <
0110 class... Args,
0111 class EnableIf = typename std::enable_if<std::is_constructible<Stream, Args...>::value>::type>
0112 connection(const buffer_params& buff_params, Args&&... args)
0113 : impl_(
0114 buff_params.initial_read_size(),
0115 static_cast<std::size_t>(-1),
0116 detail::make_engine<Stream>(std::forward<Args>(args)...)
0117 )
0118 {
0119 }
0120
0121
0122
0123
0124 connection(connection&& other) = default;
0125
0126
0127
0128
0129 connection& operator=(connection&& rhs) = default;
0130
0131 #ifndef BOOST_MYSQL_DOXYGEN
0132 connection(const connection&) = delete;
0133 connection& operator=(const connection&) = delete;
0134 #endif
0135
0136
0137 using executor_type = typename Stream::executor_type;
0138
0139
0140 executor_type get_executor() { return stream().get_executor(); }
0141
0142
0143 using stream_type = Stream;
0144
0145
0146
0147
0148
0149
0150
0151
0152 Stream& stream() noexcept { return detail::stream_from_engine<Stream>(impl_.get_engine()); }
0153
0154
0155
0156
0157
0158
0159
0160
0161 const Stream& stream() const noexcept { return detail::stream_from_engine<Stream>(impl_.get_engine()); }
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177
0178
0179
0180 bool uses_ssl() const noexcept { return impl_.ssl_active(); }
0181
0182
0183 metadata_mode meta_mode() const noexcept { return impl_.meta_mode(); }
0184
0185
0186 void set_meta_mode(metadata_mode v) noexcept { impl_.set_meta_mode(v); }
0187
0188
0189
0190
0191
0192
0193
0194
0195
0196
0197
0198
0199
0200
0201
0202 template <typename EndpointType>
0203 void connect(
0204 const EndpointType& endpoint,
0205 const handshake_params& params,
0206 error_code& ec,
0207 diagnostics& diag
0208 )
0209 {
0210 static_assert(
0211 detail::is_socket_stream<Stream>::value,
0212 "connect can only be used if Stream satisfies the SocketStream concept"
0213 );
0214 impl_.connect<typename Stream::lowest_layer_type::endpoint_type>(endpoint, params, ec, diag);
0215 }
0216
0217
0218 template <typename EndpointType>
0219 void connect(const EndpointType& endpoint, const handshake_params& params)
0220 {
0221 static_assert(
0222 detail::is_socket_stream<Stream>::value,
0223 "connect can only be used if Stream satisfies the SocketStream concept"
0224 );
0225 error_code err;
0226 diagnostics diag;
0227 connect(endpoint, params, err, diag);
0228 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0229 }
0230
0231
0232
0233
0234
0235
0236
0237
0238
0239
0240
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251 template <
0252 typename EndpointType,
0253 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0254 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0255 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code))
0256 async_connect(
0257 const EndpointType& endpoint,
0258 const handshake_params& params,
0259 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0260 )
0261 {
0262 static_assert(
0263 detail::is_socket_stream<Stream>::value,
0264 "async_connect can only be used if Stream satisfies the SocketStream concept"
0265 );
0266 return async_connect(endpoint, params, impl_.shared_diag(), std::forward<CompletionToken>(token));
0267 }
0268
0269
0270 template <
0271 typename EndpointType,
0272 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0273 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0274 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code))
0275 async_connect(
0276 const EndpointType& endpoint,
0277 const handshake_params& params,
0278 diagnostics& diag,
0279 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0280 )
0281 {
0282 static_assert(
0283 detail::is_socket_stream<Stream>::value,
0284 "async_connect can only be used if Stream satisfies the SocketStream concept"
0285 );
0286 return impl_.async_connect<typename Stream::lowest_layer_type::endpoint_type>(
0287 endpoint,
0288 params,
0289 diag,
0290 std::forward<CompletionToken>(token)
0291 );
0292 }
0293
0294
0295
0296
0297
0298
0299
0300
0301
0302
0303 void handshake(const handshake_params& params, error_code& ec, diagnostics& diag)
0304 {
0305 impl_.run(impl_.make_params_handshake(params), ec, diag);
0306 }
0307
0308
0309 void handshake(const handshake_params& params)
0310 {
0311 error_code err;
0312 diagnostics diag;
0313 handshake(params, err, diag);
0314 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0315 }
0316
0317
0318
0319
0320
0321
0322
0323
0324
0325
0326
0327
0328
0329
0330
0331
0332
0333
0334
0335
0336 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0337 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0338 auto async_handshake(
0339 const handshake_params& params,
0340 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0341 ) BOOST_MYSQL_RETURN_TYPE(detail::async_handshake_t<CompletionToken&&>)
0342 {
0343 return async_handshake(params, impl_.shared_diag(), std::forward<CompletionToken>(token));
0344 }
0345
0346
0347 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0348 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0349 auto async_handshake(
0350 const handshake_params& params,
0351 diagnostics& diag,
0352 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0353 ) BOOST_MYSQL_RETURN_TYPE(detail::async_handshake_t<CompletionToken&&>)
0354 {
0355 return impl_
0356 .async_run(impl_.make_params_handshake(params), diag, std::forward<CompletionToken>(token));
0357 }
0358
0359
0360 template <BOOST_MYSQL_EXECUTION_REQUEST ExecutionRequest, BOOST_MYSQL_RESULTS_TYPE ResultsType>
0361 void execute(ExecutionRequest&& req, ResultsType& result, error_code& err, diagnostics& diag)
0362 {
0363 impl_.execute(std::forward<ExecutionRequest>(req), result, err, diag);
0364 }
0365
0366
0367 template <BOOST_MYSQL_EXECUTION_REQUEST ExecutionRequest, BOOST_MYSQL_RESULTS_TYPE ResultsType>
0368 void execute(ExecutionRequest&& req, ResultsType& result)
0369 {
0370 error_code err;
0371 diagnostics diag;
0372 execute(std::forward<ExecutionRequest>(req), result, err, diag);
0373 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0374 }
0375
0376
0377 template <
0378 BOOST_MYSQL_EXECUTION_REQUEST ExecutionRequest,
0379 BOOST_MYSQL_RESULTS_TYPE ResultsType,
0380 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0381 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0382 auto async_execute(
0383 ExecutionRequest&& req,
0384 ResultsType& result,
0385 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0386 ) BOOST_MYSQL_RETURN_TYPE(detail::async_execute_t<ExecutionRequest&&, ResultsType, CompletionToken&&>)
0387 {
0388 return async_execute(
0389 std::forward<ExecutionRequest>(req),
0390 result,
0391 impl_.shared_diag(),
0392 std::forward<CompletionToken>(token)
0393 );
0394 }
0395
0396
0397 template <
0398 BOOST_MYSQL_EXECUTION_REQUEST ExecutionRequest,
0399 BOOST_MYSQL_RESULTS_TYPE ResultsType,
0400 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0401 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0402 auto async_execute(
0403 ExecutionRequest&& req,
0404 ResultsType& result,
0405 diagnostics& diag,
0406 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0407 ) BOOST_MYSQL_RETURN_TYPE(detail::async_execute_t<ExecutionRequest&&, ResultsType, CompletionToken&&>)
0408 {
0409 return impl_.async_execute(
0410 std::forward<ExecutionRequest>(req),
0411 result,
0412 diag,
0413 std::forward<CompletionToken>(token)
0414 );
0415 }
0416
0417
0418 template <
0419 BOOST_MYSQL_EXECUTION_REQUEST ExecutionRequest,
0420 BOOST_MYSQL_EXECUTION_STATE_TYPE ExecutionStateType>
0421 void start_execution(ExecutionRequest&& req, ExecutionStateType& st, error_code& err, diagnostics& diag)
0422 {
0423 impl_.start_execution(std::forward<ExecutionRequest>(req), st, err, diag);
0424 }
0425
0426
0427 template <
0428 BOOST_MYSQL_EXECUTION_REQUEST ExecutionRequest,
0429 BOOST_MYSQL_EXECUTION_STATE_TYPE ExecutionStateType>
0430 void start_execution(ExecutionRequest&& req, ExecutionStateType& st)
0431 {
0432 error_code err;
0433 diagnostics diag;
0434 start_execution(std::forward<ExecutionRequest>(req), st, err, diag);
0435 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0436 }
0437
0438
0439 template <
0440 BOOST_MYSQL_EXECUTION_REQUEST ExecutionRequest,
0441 BOOST_MYSQL_EXECUTION_STATE_TYPE ExecutionStateType,
0442 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0443 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0444 auto async_start_execution(
0445 ExecutionRequest&& req,
0446 ExecutionStateType& st,
0447 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0448 )
0449 BOOST_MYSQL_RETURN_TYPE(detail::async_start_execution_t<
0450 ExecutionRequest&&,
0451 ExecutionStateType,
0452 CompletionToken&&>)
0453 {
0454 return async_start_execution(
0455 std::forward<ExecutionRequest>(req),
0456 st,
0457 impl_.shared_diag(),
0458 std::forward<CompletionToken>(token)
0459 );
0460 }
0461
0462
0463 template <
0464 BOOST_MYSQL_EXECUTION_REQUEST ExecutionRequest,
0465 BOOST_MYSQL_EXECUTION_STATE_TYPE ExecutionStateType,
0466 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0467 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0468 auto async_start_execution(
0469 ExecutionRequest&& req,
0470 ExecutionStateType& st,
0471 diagnostics& diag,
0472 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0473 )
0474 BOOST_MYSQL_RETURN_TYPE(detail::async_start_execution_t<
0475 ExecutionRequest&&,
0476 ExecutionStateType,
0477 CompletionToken&&>)
0478 {
0479 return impl_.async_start_execution(
0480 std::forward<ExecutionRequest>(req),
0481 st,
0482 diag,
0483 std::forward<CompletionToken>(token)
0484 );
0485 }
0486
0487
0488 statement prepare_statement(string_view stmt, error_code& err, diagnostics& diag)
0489 {
0490 return impl_.run(detail::prepare_statement_algo_params{stmt}, err, diag);
0491 }
0492
0493
0494 statement prepare_statement(string_view stmt)
0495 {
0496 error_code err;
0497 diagnostics diag;
0498 statement res = prepare_statement(stmt, err, diag);
0499 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0500 return res;
0501 }
0502
0503
0504 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code, ::boost::mysql::statement))
0505 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0506 auto async_prepare_statement(
0507 string_view stmt,
0508 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0509 ) BOOST_MYSQL_RETURN_TYPE(detail::async_prepare_statement_t<CompletionToken&&>)
0510 {
0511 return async_prepare_statement(stmt, impl_.shared_diag(), std::forward<CompletionToken>(token));
0512 }
0513
0514
0515 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code, ::boost::mysql::statement))
0516 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0517 auto async_prepare_statement(
0518 string_view stmt,
0519 diagnostics& diag,
0520 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0521 ) BOOST_MYSQL_RETURN_TYPE(detail::async_prepare_statement_t<CompletionToken&&>)
0522 {
0523 return impl_.async_run(
0524 detail::prepare_statement_algo_params{stmt},
0525 diag,
0526 std::forward<CompletionToken>(token)
0527 );
0528 }
0529
0530
0531 void close_statement(const statement& stmt, error_code& err, diagnostics& diag)
0532 {
0533 impl_.run(impl_.make_params_close_statement(stmt), err, diag);
0534 }
0535
0536
0537 void close_statement(const statement& stmt)
0538 {
0539 error_code err;
0540 diagnostics diag;
0541 close_statement(stmt, err, diag);
0542 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0543 }
0544
0545
0546 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0547 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0548 auto async_close_statement(
0549 const statement& stmt,
0550 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0551 ) BOOST_MYSQL_RETURN_TYPE(detail::async_close_statement_t<CompletionToken&&>)
0552 {
0553 return async_close_statement(stmt, impl_.shared_diag(), std::forward<CompletionToken>(token));
0554 }
0555
0556
0557 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0558 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0559 auto async_close_statement(
0560 const statement& stmt,
0561 diagnostics& diag,
0562 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0563 ) BOOST_MYSQL_RETURN_TYPE(detail::async_close_statement_t<CompletionToken&&>)
0564 {
0565 return impl_
0566 .async_run(impl_.make_params_close_statement(stmt), diag, std::forward<CompletionToken>(token));
0567 }
0568
0569
0570 rows_view read_some_rows(execution_state& st, error_code& err, diagnostics& diag)
0571 {
0572 return impl_.run(impl_.make_params_read_some_rows(st), err, diag);
0573 }
0574
0575
0576 rows_view read_some_rows(execution_state& st)
0577 {
0578 error_code err;
0579 diagnostics diag;
0580 rows_view res = read_some_rows(st, err, diag);
0581 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0582 return res;
0583 }
0584
0585
0586 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code, ::boost::mysql::rows_view))
0587 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0588 auto async_read_some_rows(
0589 execution_state& st,
0590 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0591 ) BOOST_MYSQL_RETURN_TYPE(detail::async_read_some_rows_dynamic_t<CompletionToken&&>)
0592 {
0593 return async_read_some_rows(st, impl_.shared_diag(), std::forward<CompletionToken>(token));
0594 }
0595
0596
0597 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code, ::boost::mysql::rows_view))
0598 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0599 auto async_read_some_rows(
0600 execution_state& st,
0601 diagnostics& diag,
0602 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0603 ) BOOST_MYSQL_RETURN_TYPE(detail::async_read_some_rows_dynamic_t<CompletionToken&&>)
0604 {
0605 return impl_
0606 .async_run(impl_.make_params_read_some_rows(st), diag, std::forward<CompletionToken>(token));
0607 }
0608
0609 #ifdef BOOST_MYSQL_CXX14
0610
0611
0612
0613
0614
0615
0616
0617
0618
0619
0620
0621
0622
0623
0624
0625
0626
0627
0628
0629
0630
0631
0632
0633
0634
0635
0636
0637
0638
0639 template <class SpanElementType, class... StaticRow>
0640 std::size_t read_some_rows(
0641 static_execution_state<StaticRow...>& st,
0642 span<SpanElementType> output,
0643 error_code& err,
0644 diagnostics& diag
0645 )
0646 {
0647 return impl_.run(impl_.make_params_read_some_rows_static(st, output), err, diag);
0648 }
0649
0650
0651
0652
0653
0654
0655
0656
0657
0658
0659
0660
0661
0662
0663
0664
0665
0666
0667
0668
0669
0670
0671
0672
0673
0674
0675
0676
0677
0678 template <class SpanElementType, class... StaticRow>
0679 std::size_t read_some_rows(static_execution_state<StaticRow...>& st, span<SpanElementType> output)
0680 {
0681 error_code err;
0682 diagnostics diag;
0683 std::size_t res = read_some_rows(st, output, err, diag);
0684 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0685 return res;
0686 }
0687
0688
0689
0690
0691
0692
0693
0694
0695
0696
0697
0698
0699
0700
0701
0702
0703
0704
0705
0706
0707
0708
0709
0710
0711
0712
0713
0714
0715
0716
0717
0718
0719
0720
0721
0722
0723
0724
0725
0726
0727
0728
0729
0730
0731
0732
0733 template <
0734 class SpanElementType,
0735 class... StaticRow,
0736 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code, std::size_t))
0737 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0738 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code, std::size_t))
0739 async_read_some_rows(
0740 static_execution_state<StaticRow...>& st,
0741 span<SpanElementType> output,
0742 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0743 )
0744 {
0745 return async_read_some_rows(st, output, impl_.shared_diag(), std::forward<CompletionToken>(token));
0746 }
0747
0748
0749
0750
0751
0752
0753
0754
0755
0756
0757
0758
0759
0760
0761
0762
0763
0764
0765
0766
0767
0768
0769
0770
0771
0772
0773
0774
0775
0776
0777
0778
0779
0780
0781
0782
0783
0784
0785
0786
0787
0788
0789
0790
0791
0792
0793 template <
0794 class SpanElementType,
0795 class... StaticRow,
0796 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code, std::size_t))
0797 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0798 BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(CompletionToken, void(error_code, std::size_t))
0799 async_read_some_rows(
0800 static_execution_state<StaticRow...>& st,
0801 span<SpanElementType> output,
0802 diagnostics& diag,
0803 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0804 )
0805 {
0806 return impl_.async_run(
0807 impl_.make_params_read_some_rows_static(st, output),
0808 diag,
0809 std::forward<CompletionToken>(token)
0810 );
0811 }
0812 #endif
0813
0814
0815 template <BOOST_MYSQL_EXECUTION_STATE_TYPE ExecutionStateType>
0816 void read_resultset_head(ExecutionStateType& st, error_code& err, diagnostics& diag)
0817 {
0818 return impl_.run(impl_.make_params_read_resultset_head(st), err, diag);
0819 }
0820
0821
0822 template <BOOST_MYSQL_EXECUTION_STATE_TYPE ExecutionStateType>
0823 void read_resultset_head(ExecutionStateType& st)
0824 {
0825 error_code err;
0826 diagnostics diag;
0827 read_resultset_head(st, err, diag);
0828 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0829 }
0830
0831
0832 template <
0833 BOOST_MYSQL_EXECUTION_STATE_TYPE ExecutionStateType,
0834 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0835 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0836 auto async_read_resultset_head(
0837 ExecutionStateType& st,
0838 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0839 ) BOOST_MYSQL_RETURN_TYPE(detail::async_read_resultset_head_t<CompletionToken&&>)
0840 {
0841 return async_read_resultset_head(st, impl_.shared_diag(), std::forward<CompletionToken>(token));
0842 }
0843
0844
0845 template <
0846 BOOST_MYSQL_EXECUTION_STATE_TYPE ExecutionStateType,
0847 BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0848 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0849 auto async_read_resultset_head(
0850 ExecutionStateType& st,
0851 diagnostics& diag,
0852 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0853 ) BOOST_MYSQL_RETURN_TYPE(detail::async_read_resultset_head_t<CompletionToken&&>)
0854 {
0855 return impl_
0856 .async_run(impl_.make_params_read_resultset_head(st), diag, std::forward<CompletionToken>(token));
0857 }
0858
0859
0860 void ping(error_code& err, diagnostics& diag) { impl_.run(detail::ping_algo_params{}, err, diag); }
0861
0862
0863 void ping()
0864 {
0865 error_code err;
0866 diagnostics diag;
0867 ping(err, diag);
0868 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0869 }
0870
0871
0872 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0873 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0874 auto async_ping(CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
0875 BOOST_MYSQL_RETURN_TYPE(detail::async_ping_t<CompletionToken&&>)
0876 {
0877 return async_ping(impl_.shared_diag(), std::forward<CompletionToken>(token));
0878 }
0879
0880
0881 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0882 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0883 auto async_ping(
0884 diagnostics& diag,
0885 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0886 ) BOOST_MYSQL_RETURN_TYPE(detail::async_ping_t<CompletionToken&&>)
0887 {
0888 return impl_.async_run(detail::ping_algo_params{}, diag, std::forward<CompletionToken>(token));
0889 }
0890
0891
0892
0893
0894
0895
0896
0897
0898
0899
0900
0901
0902
0903
0904
0905
0906
0907
0908
0909
0910
0911
0912
0913
0914
0915
0916
0917
0918
0919
0920
0921
0922
0923 void reset_connection(error_code& err, diagnostics& diag)
0924 {
0925 impl_.run(detail::reset_connection_algo_params{}, err, diag);
0926 }
0927
0928
0929 void reset_connection()
0930 {
0931 error_code err;
0932 diagnostics diag;
0933 reset_connection(err, diag);
0934 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
0935 }
0936
0937
0938
0939
0940
0941
0942
0943
0944
0945
0946
0947
0948
0949
0950
0951
0952
0953
0954 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0955 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0956 auto async_reset_connection(CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
0957 BOOST_MYSQL_RETURN_TYPE(detail::async_reset_connection_t<CompletionToken&&>)
0958 {
0959 return async_reset_connection(impl_.shared_diag(), std::forward<CompletionToken>(token));
0960 }
0961
0962
0963 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
0964 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
0965 auto async_reset_connection(
0966 diagnostics& diag,
0967 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
0968 ) BOOST_MYSQL_RETURN_TYPE(detail::async_reset_connection_t<CompletionToken&&>)
0969 {
0970 return impl_
0971 .async_run(detail::reset_connection_algo_params{}, diag, std::forward<CompletionToken>(token));
0972 }
0973
0974
0975
0976
0977
0978
0979
0980
0981
0982
0983 void close(error_code& err, diagnostics& diag)
0984 {
0985 static_assert(
0986 detail::is_socket_stream<Stream>::value,
0987 "close can only be used if Stream satisfies the SocketStream concept"
0988 );
0989 impl_.run(detail::close_connection_algo_params{}, err, diag);
0990 }
0991
0992
0993 void close()
0994 {
0995 static_assert(
0996 detail::is_socket_stream<Stream>::value,
0997 "close can only be used if Stream satisfies the SocketStream concept"
0998 );
0999 error_code err;
1000 diagnostics diag;
1001 close(err, diag);
1002 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
1003 }
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
1022 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
1023 auto async_close(CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
1024 BOOST_MYSQL_RETURN_TYPE(detail::async_close_connection_t<CompletionToken&&>)
1025 {
1026 static_assert(
1027 detail::is_socket_stream<Stream>::value,
1028 "async_close can only be used if Stream satisfies the SocketStream concept"
1029 );
1030 return async_close(impl_.shared_diag(), std::forward<CompletionToken>(token));
1031 }
1032
1033
1034 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
1035 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
1036 auto async_close(
1037 diagnostics& diag,
1038 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
1039 ) BOOST_MYSQL_RETURN_TYPE(detail::async_close_connection_t<CompletionToken&&>)
1040 {
1041 static_assert(
1042 detail::is_socket_stream<Stream>::value,
1043 "async_close can only be used if Stream satisfies the SocketStream concept"
1044 );
1045 return impl_
1046 .async_run(detail::close_connection_algo_params{}, diag, std::forward<CompletionToken>(token));
1047 }
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059 void quit(error_code& err, diagnostics& diag)
1060 {
1061 impl_.run(detail::quit_connection_algo_params{}, err, diag);
1062 }
1063
1064
1065 void quit()
1066 {
1067 error_code err;
1068 diagnostics diag;
1069 quit(err, diag);
1070 detail::throw_on_error_loc(err, diag, BOOST_CURRENT_LOCATION);
1071 }
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
1090 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
1091 auto async_quit(CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
1092 BOOST_MYSQL_RETURN_TYPE(detail::async_quit_connection_t<CompletionToken&&>)
1093 {
1094 return async_quit(impl_.shared_diag(), std::forward<CompletionToken>(token));
1095 }
1096
1097
1098 template <BOOST_ASIO_COMPLETION_TOKEN_FOR(void(::boost::mysql::error_code))
1099 CompletionToken BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
1100 auto async_quit(
1101 diagnostics& diag,
1102 CompletionToken&& token BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type)
1103 ) BOOST_MYSQL_RETURN_TYPE(detail::async_quit_connection_t<CompletionToken&&>)
1104 {
1105 return impl_
1106 .async_run(detail::quit_connection_algo_params{}, diag, std::forward<CompletionToken>(token));
1107 }
1108
1109
1110
1111
1112
1113
1114
1115
1116 template <typename Executor1>
1117 struct rebind_executor
1118 {
1119
1120 using other = connection<typename detail::rebind_executor<Stream, Executor1>::type>;
1121 };
1122 };
1123
1124 }
1125 }
1126
1127 #endif