/* * Copyright (C) 2016-present ScyllaDB * * Modified by ScyllaDB */ /* * SPDX-License-Identifier: (LicenseRef-ScyllaDB-Source-Available-1.0 and Apache-2.0) */ #pragma once #include "audit/audit.hh" #include #include #include #include #include "exceptions/exceptions.hh" #include "types/types.hh" namespace cql3 { class prepare_context; class column_specification; class cql_statement; struct cql_metadata_id_type { explicit cql_metadata_id_type(bytes&& metadata_id) : _metadata_id(std::move(metadata_id)) {} bytes _metadata_id; bool operator==(const cql_metadata_id_type& other) const = default; }; namespace statements { struct invalidated_prepared_usage_attempt { void operator()() const { throw exceptions::invalidated_prepared_usage_attempt_exception(); } }; class prepared_statement : public seastar::weakly_referencable { public: typedef seastar::checked_ptr> checked_weak_ptr; public: const seastar::shared_ptr statement; const std::vector> bound_names; const std::vector partition_key_bind_indices; std::vector warnings; private: cql_metadata_id_type _metadata_id; public: prepared_statement(audit::audit_info_ptr&& audit_info, seastar::shared_ptr statement_, std::vector> bound_names_, std::vector partition_key_bind_indices, std::vector warnings = {}); prepared_statement(audit::audit_info_ptr&& audit_info, seastar::shared_ptr statement_, const prepare_context& ctx, const std::vector& partition_key_bind_indices, std::vector warnings = {}); prepared_statement(audit::audit_info_ptr&& audit_info, seastar::shared_ptr statement_, prepare_context&& ctx, std::vector&& partition_key_bind_indices); prepared_statement(audit::audit_info_ptr&& audit_info, seastar::shared_ptr&& statement_, std::vector warnings = {}); checked_weak_ptr checked_weak_from_this() const { return checked_weak_ptr(this->weak_from_this()); } void calculate_metadata_id(); cql_metadata_id_type get_metadata_id() const; }; } } template <> struct fmt::formatter { constexpr auto parse(format_parse_context& ctx) { return ctx.begin(); } auto format(const cql3::cql_metadata_id_type& m, fmt::format_context& ctx) const { return fmt::format_to(ctx.out(), "{}", m._metadata_id); } };