diff --git a/cql3/cql_config.hh b/cql3/cql_config.hh index 1c0aec379d..bd09a5f940 100644 --- a/cql3/cql_config.hh +++ b/cql3/cql_config.hh @@ -29,6 +29,7 @@ struct cql_config { utils::updateable_value enable_parallelized_aggregation; utils::updateable_value batch_size_warn_threshold_in_kb; utils::updateable_value batch_size_fail_threshold_in_kb; + utils::updateable_value restrict_future_timestamp; explicit cql_config(const db::config& cfg) : restrictions(cfg) @@ -39,6 +40,7 @@ struct cql_config { , enable_parallelized_aggregation(cfg.enable_parallelized_aggregation) , batch_size_warn_threshold_in_kb(cfg.batch_size_warn_threshold_in_kb) , batch_size_fail_threshold_in_kb(cfg.batch_size_fail_threshold_in_kb) + , restrict_future_timestamp(cfg.restrict_future_timestamp) {} struct default_tag{}; cql_config(default_tag) @@ -50,6 +52,7 @@ struct cql_config { , enable_parallelized_aggregation(true) , batch_size_warn_threshold_in_kb(128) , batch_size_fail_threshold_in_kb(1024) + , restrict_future_timestamp(true) {} }; diff --git a/cql3/statements/batch_statement.cc b/cql3/statements/batch_statement.cc index 88184d97c0..7d0976e211 100644 --- a/cql3/statements/batch_statement.cc +++ b/cql3/statements/batch_statement.cc @@ -10,7 +10,6 @@ #include "batch_statement.hh" #include "cql3/util.hh" #include "raw/batch_statement.hh" -#include "db/config.hh" #include "cql3/cql_config.hh" #include "db/consistency_level_validations.hh" #include "data_dictionary/data_dictionary.hh" @@ -243,7 +242,7 @@ future> batch_statement::exe future> batch_statement::execute_without_checking_exception_message( query_processor& qp, service::query_state& state, const query_options& options, std::optional guard) const { - cql3::util::validate_timestamp(qp.db().get_config(), options, _attrs); + cql3::util::validate_timestamp(qp.get_cql_config(), options, _attrs); return batch_stage(this, seastar::ref(qp), seastar::ref(state), seastar::cref(options), false, options.get_timestamp(state)); } diff --git a/cql3/statements/modification_statement.cc b/cql3/statements/modification_statement.cc index 80478685ec..1c6cd4a28a 100644 --- a/cql3/statements/modification_statement.cc +++ b/cql3/statements/modification_statement.cc @@ -256,7 +256,7 @@ modification_statement::execute(query_processor& qp, service::query_state& qs, c future<::shared_ptr> modification_statement::execute_without_checking_exception_message(query_processor& qp, service::query_state& qs, const query_options& options, std::optional guard) const { - cql3::util::validate_timestamp(qp.db().get_config(), options, attrs); + cql3::util::validate_timestamp(qp.get_cql_config(), options, attrs); return modify_stage(this, seastar::ref(qp), seastar::ref(qs), seastar::cref(options)); } diff --git a/cql3/util.cc b/cql3/util.cc index 487f03413a..3257ecb690 100644 --- a/cql3/util.cc +++ b/cql3/util.cc @@ -6,8 +6,9 @@ #include "utils/assert.hh" #include "util.hh" +#include "cql_config.hh" #include "cql3/expr/expr-utils.hh" -#include "db/config.hh" +#include "db_clock.hh" #ifdef DEBUG @@ -117,8 +118,8 @@ void do_with_parser_impl(const std::string_view& cql, dialect d, noncopyable_fun #endif -void validate_timestamp(const db::config& config, const query_options& options, const std::unique_ptr& attrs) { - if (attrs->is_timestamp_set() && config.restrict_future_timestamp()) { +void validate_timestamp(const cql_config& cql_cfg, const query_options& options, const std::unique_ptr& attrs) { + if (attrs->is_timestamp_set() && cql_cfg.restrict_future_timestamp()) { static constexpr int64_t MAX_DIFFERENCE = std::chrono::duration_cast(std::chrono::days(3)).count(); auto now = std::chrono::duration_cast(db_clock::now().time_since_epoch()).count(); diff --git a/cql3/util.hh b/cql3/util.hh index bf46beaf43..84bac9f4c5 100644 --- a/cql3/util.hh +++ b/cql3/util.hh @@ -88,7 +88,7 @@ sstring single_quote(const std::string_view s); // Check whether timestamp is not too far in the future as this probably // indicates its incorrectness (for example using other units than microseconds). -void validate_timestamp(const db::config& config, const query_options& options, const std::unique_ptr& attrs); +void validate_timestamp(const cql_config& cql_cfg, const query_options& options, const std::unique_ptr& attrs); template std::vector to_vector(const std::vector& values) {