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 {
44 clients::dns::Resolver& resolver,
45 const settings::MysqlSettings& settings,
46 const components::ComponentConfig& config
58 template <
typename... Args>
71 template <
typename... Args>
73 OptionalCommandControl command_control,
104 template <
typename T>
106 OptionalCommandControl command_control,
124 template <
typename Container>
143 template <
typename Container>
145 OptionalCommandControl command_control,
148 const Container& params
166 template <
typename MapTo,
typename Container>
169 const Container& params)
const;
191 template <
typename MapTo,
typename Container>
193 OptionalCommandControl command_control,
196 const Container& params
244 template <
typename T,
typename... Args>
262 template <
typename T,
typename... Args>
264 OptionalCommandControl command_control,
266 std::size_t batch_size,
275 static CommandControl GetDefaultCommandControl();
277 StatementResultSet DoExecute(
278 OptionalCommandControl command_control,
281 impl::io::ParamsBinderBase& params,
282 std::optional<std::size_t> batch_size
285 std::unique_ptr<infra::topology::TopologyBase> topology_;
288template <
typename... Args>
290 return Execute(std::nullopt, host_type, query, args...);
293template <
typename... Args>
295 OptionalCommandControl command_control,
300 auto params_binder = impl::BindHelper::BindParams(args...);
302 return DoExecute(command_control, host_type, query, params_binder, std::nullopt);
307 return ExecuteDecompose(std::nullopt, host_type, query, row);
312 OptionalCommandControl command_control,
317 auto params_binder = impl::BindHelper::BindRowAsParams(row);
319 return DoExecute(command_control, host_type, query, params_binder, std::nullopt);
322template <
typename Container>
324 return ExecuteBulk(std::nullopt, host_type, query, params);
327template <
typename Container>
329 OptionalCommandControl command_control,
332 const Container& params
334 UINVARIANT(!params.empty(),
"Empty params in bulk execution");
336 auto params_binder = impl::BindHelper::BindContainerAsParams(params);
338 return DoExecute(command_control, host_type, query, params_binder, std::nullopt);
341template <
typename MapTo,
typename Container>
344 return ExecuteBulkMapped<MapTo>(std::nullopt, host_type, query, params);
347template <
typename MapTo,
typename Container>
349 OptionalCommandControl command_control,
352 const Container& params
354 UINVARIANT(!params.empty(),
"Empty params in bulk execution");
356 auto params_binder = impl::BindHelper::BindContainerAsParamsMapped<MapTo>(params);
358 return DoExecute(command_control, host_type, query, params_binder, std::nullopt);
361template <
typename T,
typename... Args>
364 return GetCursor<T>(std::nullopt, host_type, batch_size, query, args...);
367template <
typename T,
typename... Args>
369 OptionalCommandControl command_control,
371 std::size_t batch_size,
375 auto params_binder = impl::BindHelper::BindParams(args...);
377 return CursorResultSet<T>{DoExecute(command_control, host_type, query, params_binder, batch_size)};