cql3: Add feature service to ks_prop_defs::as_ks_metadata()

To call prepare_options() with tablets feature state later

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2023-12-08 13:40:06 +03:00
parent 267770bf0f
commit 4dede19e4f
4 changed files with 8 additions and 5 deletions

View File

@@ -92,11 +92,12 @@ void create_keyspace_statement::validate(query_processor& qp, const service::cli
future<std::tuple<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>, cql3::cql_warnings_vec>> create_keyspace_statement::prepare_schema_mutations(query_processor& qp, api::timestamp_type ts) const {
using namespace cql_transport;
const auto& tm = *qp.proxy().get_token_metadata_ptr();
const auto& feat = qp.proxy().features();
::shared_ptr<event::schema_change> ret;
std::vector<mutation> m;
try {
m = service::prepare_new_keyspace_announcement(qp.db().real_database(), _attrs->as_ks_metadata(_name, tm), ts);
m = service::prepare_new_keyspace_announcement(qp.db().real_database(), _attrs->as_ks_metadata(_name, tm, feat), ts);
ret = ::make_shared<event::schema_change>(
event::schema_change::change_type::CREATED,
@@ -257,7 +258,7 @@ create_keyspace_statement::execute(query_processor& qp, service::query_state& st
lw_shared_ptr<data_dictionary::keyspace_metadata> create_keyspace_statement::get_keyspace_metadata(const locator::token_metadata& tm, const gms::feature_service& feat) {
_attrs->validate();
return _attrs->as_ks_metadata(_name, tm);
return _attrs->as_ks_metadata(_name, tm, feat);
}
}

View File

@@ -157,7 +157,7 @@ std::optional<sstring> ks_prop_defs::get_replication_strategy_class() const {
return _strategy_class;
}
lw_shared_ptr<data_dictionary::keyspace_metadata> ks_prop_defs::as_ks_metadata(sstring ks_name, const locator::token_metadata& tm) {
lw_shared_ptr<data_dictionary::keyspace_metadata> ks_prop_defs::as_ks_metadata(sstring ks_name, const locator::token_metadata& tm, const gms::feature_service& feat) {
auto sc = get_replication_strategy_class().value();
std::optional<unsigned> initial_tablets = get_initial_tablets(sc);
auto options = prepare_options(sc, tm, get_replication_options(), initial_tablets);

View File

@@ -25,6 +25,8 @@ namespace gms {
class inet_address;
}
namespace gms { class feature_service; }
namespace locator {
class token_metadata;
class shared_token_metadata;
@@ -53,7 +55,7 @@ public:
std::optional<sstring> get_replication_strategy_class() const;
std::optional<unsigned> get_initial_tablets(const sstring& strategy_class) const;
data_dictionary::storage_options get_storage_options() const;
lw_shared_ptr<data_dictionary::keyspace_metadata> as_ks_metadata(sstring ks_name, const locator::token_metadata&);
lw_shared_ptr<data_dictionary::keyspace_metadata> as_ks_metadata(sstring ks_name, const locator::token_metadata&, const gms::feature_service&);
lw_shared_ptr<data_dictionary::keyspace_metadata> as_ks_metadata_update(lw_shared_ptr<data_dictionary::keyspace_metadata> old, const locator::token_metadata&);
#if 0

View File

@@ -189,7 +189,7 @@ future<> create_keyspace_if_not_exists_impl(seastar::sharded<service::storage_pr
attrs.add_property(cql3::statements::ks_prop_defs::KW_REPLICATION, replication_properties);
attrs.validate();
ksms.push_back(attrs.as_ks_metadata(ks_name, *tm));
ksms.push_back(attrs.as_ks_metadata(ks_name, *tm, proxy.local().features()));
}
auto group0_guard = co_await mml.start_group0_operation();