10#include <userver/clients/dns/resolver_fwd.hpp>
11#include <userver/components/component_fwd.hpp>
12#include <userver/engine/deadline.hpp>
13#include <userver/utils/statistics/writer.hpp>
15#include <userver/storages/mysql/cluster_host_type.hpp>
16#include <userver/storages/mysql/command_result_set.hpp>
17#include <userver/storages/mysql/cursor_result_set.hpp>
18#include <userver/storages/mysql/impl/bind_helper.hpp>
19#include <userver/storages/mysql/options.hpp>
20#include <userver/storages/mysql/query.hpp>
21#include <userver/storages/mysql/statement_result_set.hpp>
22#include <userver/storages/mysql/transaction.hpp>
24USERVER_NAMESPACE_BEGIN
26namespace storages::
mysql {
32namespace infra::topology {
45 const settings::MysqlSettings& settings,
58 template <
typename... Args>
73 template <
typename... Args>
75 OptionalCommandControl command_control,
106 template <
typename T>
108 OptionalCommandControl command_control,
126 template <
typename Container>
145 template <
typename Container>
147 OptionalCommandControl command_control,
150 const Container& params
168 template <
typename MapTo,
typename Container>
171 const Container& params)
const;
193 template <
typename MapTo,
typename Container>
195 OptionalCommandControl command_control,
198 const Container& params
245 template <
typename T,
typename... Args>
263 template <
typename T,
typename... Args>
265 OptionalCommandControl command_control,
267 std::size_t batch_size,
276 static CommandControl GetDefaultCommandControl();
278 StatementResultSet DoExecute(
279 OptionalCommandControl command_control,
282 impl::io::ParamsBinderBase& params,
283 std::optional<std::size_t> batch_size
286 std::unique_ptr<infra::topology::TopologyBase> topology_;
289template <
typename... Args>
291 return Execute(std::nullopt, host_type, query, args...);
294template <
typename... Args>
296 OptionalCommandControl command_control,
301 auto params_binder = impl::BindHelper::BindParams(args...);
303 return DoExecute(command_control, host_type, query.GetStatement(), params_binder, std::nullopt);
308 return ExecuteDecompose(std::nullopt, host_type, query, row);
313 OptionalCommandControl command_control,
318 auto params_binder = impl::BindHelper::BindRowAsParams(row);
320 return DoExecute(command_control, host_type, query, params_binder, std::nullopt);
323template <
typename Container>
325 return ExecuteBulk(std::nullopt, host_type, query, params);
328template <
typename Container>
330 OptionalCommandControl command_control,
333 const Container& params
335 UINVARIANT(!params.empty(),
"Empty params in bulk execution");
337 auto params_binder = impl::BindHelper::BindContainerAsParams(params);
339 return DoExecute(command_control, host_type, query.GetStatement(), params_binder, std::nullopt);
342template <
typename MapTo,
typename Container>
345 return ExecuteBulkMapped<MapTo>(std::nullopt, host_type, query, params);
348template <
typename MapTo,
typename Container>
350 OptionalCommandControl command_control,
353 const Container& params
355 UINVARIANT(!params.empty(),
"Empty params in bulk execution");
357 auto params_binder = impl::BindHelper::BindContainerAsParamsMapped<MapTo>(params);
359 return DoExecute(command_control, host_type, query.GetStatement(), params_binder, std::nullopt);
362template <
typename T,
typename... Args>
365 return GetCursor<T>(std::nullopt, host_type, batch_size, query, args...);
368template <
typename T,
typename... Args>
370 OptionalCommandControl command_control,
372 std::size_t batch_size,
376 auto params_binder = impl::BindHelper::BindParams(args...);
378 return CursorResultSet<T>{DoExecute(command_control, host_type, query, params_binder, batch_size)};