cql3, related: switch to data_dictionary
Stop using database (and including database.hh) for schema related purposes and use data_dictionary instead. data_dictionary::database::real_database() is called from several places, for these reasons: - calling yet-to-be-converted code - callers with a legitimate need to access data (e.g. system_keyspace) but with the ::database accessor removed from query_processor. We'll need to find another way to supply system_keyspace with data access. - to gain access to the wasm engine for testing whether used defined functions compile. We'll have to find another way to do this as well. The change is a straightforward replacement. One case in modification_statement had to change a capture, but everything else was just a search-and-replace. Some files that lost "database.hh" gained "mutation.hh", which they previously had access to through "database.hh".
This commit is contained in:
@@ -64,7 +64,7 @@ static future<> create_metadata_table_if_missing_impl(
|
||||
static auto ignore_existing = [] (seastar::noncopyable_function<future<>()> func) {
|
||||
return futurize_invoke(std::move(func)).handle_exception_type([] (exceptions::already_exists_exception& ignored) { });
|
||||
};
|
||||
auto& db = qp.db();
|
||||
auto db = qp.db();
|
||||
auto parsed_statement = cql3::query_processor::parse_statement(cql);
|
||||
auto& parsed_cf_statement = static_cast<cql3::statements::raw::cf_statement&>(*parsed_statement);
|
||||
|
||||
|
||||
@@ -159,7 +159,7 @@ future<> default_authorizer::start() {
|
||||
_migration_manager).then([this] {
|
||||
_finished = do_after_system_ready(_as, [this] {
|
||||
return async([this] {
|
||||
wait_for_schema_agreement(_migration_manager, _qp.db(), _as).get0();
|
||||
wait_for_schema_agreement(_migration_manager, _qp.db().real_database(), _as).get0();
|
||||
|
||||
if (legacy_metadata_exists()) {
|
||||
if (!any_granted().get0()) {
|
||||
|
||||
@@ -160,7 +160,7 @@ future<> password_authenticator::start() {
|
||||
|
||||
_stopped = do_after_system_ready(_as, [this] {
|
||||
return async([this] {
|
||||
wait_for_schema_agreement(_migration_manager, _qp.db(), _as).get0();
|
||||
wait_for_schema_agreement(_migration_manager, _qp.db().real_database(), _as).get0();
|
||||
|
||||
if (any_nondefault_role_row_satisfies(_qp, &has_salted_hash).get0()) {
|
||||
if (legacy_metadata_exists()) {
|
||||
|
||||
@@ -141,7 +141,7 @@ service::service(
|
||||
}
|
||||
|
||||
future<> service::create_keyspace_if_missing(::service::migration_manager& mm) const {
|
||||
auto& db = _qp.db();
|
||||
auto db = _qp.db();
|
||||
|
||||
if (!db.has_keyspace(meta::AUTH_KS)) {
|
||||
locator::replication_strategy_config_options opts{{"replication_factor", "1"}};
|
||||
|
||||
@@ -243,7 +243,7 @@ future<> standard_role_manager::start() {
|
||||
return this->create_metadata_tables_if_missing().then([this] {
|
||||
_stopped = auth::do_after_system_ready(_as, [this] {
|
||||
return seastar::async([this] {
|
||||
wait_for_schema_agreement(_migration_manager, _qp.db(), _as).get0();
|
||||
wait_for_schema_agreement(_migration_manager, _qp.db().real_database(), _as).get0();
|
||||
|
||||
if (any_nondefault_role_row_satisfies(_qp, &has_can_login).get0()) {
|
||||
if (this->legacy_metadata_exists()) {
|
||||
|
||||
@@ -42,11 +42,10 @@
|
||||
#pragma once
|
||||
|
||||
#include "column_specification.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
class database;
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
class assignment_testable {
|
||||
@@ -70,7 +69,7 @@ public:
|
||||
// Test all elements of toTest for assignment. If all are exact match, return exact match. If any is not assignable,
|
||||
// return not assignable. Otherwise, return weakly assignable.
|
||||
template <typename AssignmentTestablePtrRange>
|
||||
static test_result test_all(database& db, const sstring& keyspace, const column_specification& receiver,
|
||||
static test_result test_all(data_dictionary::database db, const sstring& keyspace, const column_specification& receiver,
|
||||
AssignmentTestablePtrRange&& to_test) {
|
||||
test_result res = test_result::EXACT_MATCH;
|
||||
for (auto&& rt : to_test) {
|
||||
@@ -99,7 +98,7 @@ public:
|
||||
* Most caller should just call the isAssignable() method on the result, though functions have a use for
|
||||
* testing "strong" equality to decide the most precise overload to pick when multiple could match.
|
||||
*/
|
||||
virtual test_result test_assignment(database& db, const sstring& keyspace, const column_specification& receiver) const = 0;
|
||||
virtual test_result test_assignment(data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) const = 0;
|
||||
|
||||
// for error reporting
|
||||
virtual sstring assignment_testable_source_context() const = 0;
|
||||
|
||||
@@ -150,7 +150,7 @@ void attributes::fill_prepare_context(prepare_context& ctx) {
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<attributes> attributes::raw::prepare(database& db, const sstring& ks_name, const sstring& cf_name) const {
|
||||
std::unique_ptr<attributes> attributes::raw::prepare(data_dictionary::database db, const sstring& ks_name, const sstring& cf_name) const {
|
||||
std::optional<expr::expression> ts, ttl, to;
|
||||
|
||||
if (timestamp.has_value()) {
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
std::optional<cql3::expr::expression> time_to_live;
|
||||
std::optional<cql3::expr::expression> timeout;
|
||||
|
||||
std::unique_ptr<attributes> prepare(database& db, const sstring& ks_name, const sstring& cf_name) const;
|
||||
std::unique_ptr<attributes> prepare(data_dictionary::database db, const sstring& ks_name, const sstring& cf_name) const;
|
||||
private:
|
||||
lw_shared_ptr<column_specification> timestamp_receiver(const sstring& ks_name, const sstring& cf_name) const;
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ bool column_condition::applies_to(const data_value* cell_value, const query_opti
|
||||
}
|
||||
|
||||
lw_shared_ptr<column_condition>
|
||||
column_condition::raw::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
column_condition::raw::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
if (receiver.type->is_counter()) {
|
||||
throw exceptions::invalid_request_exception("Conditions on counters are not supported");
|
||||
}
|
||||
|
||||
@@ -163,7 +163,7 @@ public:
|
||||
std::move(collection_element), expr::oper_t::IN);
|
||||
}
|
||||
|
||||
lw_shared_ptr<column_condition> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const;
|
||||
lw_shared_ptr<column_condition> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -26,8 +26,9 @@
|
||||
#include "cql3_type.hh"
|
||||
#include "cql3/util.hh"
|
||||
#include "ut_name.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "data_dictionary/user_types_metadata.hh"
|
||||
#include "data_dictionary/keyspace_metadata.hh"
|
||||
#include "types/map.hh"
|
||||
#include "types/set.hh"
|
||||
#include "types/list.hh"
|
||||
@@ -69,11 +70,11 @@ cql3_type::kind_enum_set::prepared cql3_type::get_kind() const {
|
||||
return kind_enum_set::prepare(get_cql3_kind(*_type));
|
||||
}
|
||||
|
||||
cql3_type cql3_type::raw::prepare(database& db, const sstring& keyspace) {
|
||||
cql3_type cql3_type::raw::prepare(data_dictionary::database db, const sstring& keyspace) {
|
||||
try {
|
||||
auto&& ks = db.find_keyspace(keyspace);
|
||||
return prepare_internal(keyspace, ks.metadata()->user_types());
|
||||
} catch (no_such_keyspace& nsk) {
|
||||
} catch (data_dictionary::no_such_keyspace& nsk) {
|
||||
throw exceptions::invalid_request_exception("Unknown keyspace " + keyspace);
|
||||
}
|
||||
}
|
||||
@@ -98,10 +99,10 @@ public:
|
||||
: _type{type}
|
||||
{ }
|
||||
public:
|
||||
virtual cql3_type prepare(database& db, const sstring& keyspace) override {
|
||||
virtual cql3_type prepare(data_dictionary::database db, const sstring& keyspace) override {
|
||||
return _type;
|
||||
}
|
||||
cql3_type prepare_internal(const sstring&, const user_types_metadata&) override {
|
||||
cql3_type prepare_internal(const sstring&, const data_dictionary::user_types_metadata&) override {
|
||||
return _type;
|
||||
}
|
||||
|
||||
@@ -158,7 +159,7 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual cql3_type prepare_internal(const sstring& keyspace, const user_types_metadata& user_types) override {
|
||||
virtual cql3_type prepare_internal(const sstring& keyspace, const data_dictionary::user_types_metadata& user_types) override {
|
||||
assert(_values); // "Got null values type for a collection";
|
||||
|
||||
if (!is_frozen() && _values->supports_freezing() && !_values->is_frozen()) {
|
||||
@@ -225,7 +226,7 @@ public:
|
||||
_frozen = true;
|
||||
}
|
||||
|
||||
virtual cql3_type prepare_internal(const sstring& keyspace, const user_types_metadata& user_types) override {
|
||||
virtual cql3_type prepare_internal(const sstring& keyspace, const data_dictionary::user_types_metadata& user_types) override {
|
||||
if (_name.has_keyspace()) {
|
||||
// The provided keyspace is the one of the current statement this is part of. If it's different from the keyspace of
|
||||
// the UTName, we reject since we want to limit user types to their own keyspace (see #6643)
|
||||
@@ -284,7 +285,7 @@ public:
|
||||
}
|
||||
_frozen = true;
|
||||
}
|
||||
virtual cql3_type prepare_internal(const sstring& keyspace, const user_types_metadata& user_types) override {
|
||||
virtual cql3_type prepare_internal(const sstring& keyspace, const data_dictionary::user_types_metadata& user_types) override {
|
||||
if (!is_frozen()) {
|
||||
freeze();
|
||||
}
|
||||
|
||||
@@ -42,13 +42,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "types.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "exceptions/exceptions.hh"
|
||||
#include <iosfwd>
|
||||
#include "enum_set.hh"
|
||||
|
||||
class database;
|
||||
|
||||
namespace data_dictionary {
|
||||
class database;
|
||||
class user_types_metadata;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
virtual std::optional<sstring> keyspace() const;
|
||||
virtual void freeze();
|
||||
virtual cql3_type prepare_internal(const sstring& keyspace, const data_dictionary::user_types_metadata&) = 0;
|
||||
virtual cql3_type prepare(database& db, const sstring& keyspace);
|
||||
virtual cql3_type prepare(data_dictionary::database db, const sstring& keyspace);
|
||||
static shared_ptr<raw> from(cql3_type type);
|
||||
static shared_ptr<raw> user_type(ut_name name);
|
||||
static shared_ptr<raw> map(shared_ptr<raw> t1, shared_ptr<raw> t2);
|
||||
|
||||
@@ -34,13 +34,14 @@
|
||||
#include "cql3/assignment_testable.hh"
|
||||
#include "cql3/cql3_type.hh"
|
||||
#include "cql3/functions/function_name.hh"
|
||||
#include "database_fwd.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "gc_clock.hh"
|
||||
#include "range.hh"
|
||||
#include "seastarx.hh"
|
||||
#include "utils/overloaded_functor.hh"
|
||||
#include "utils/variant_element.hh"
|
||||
#include "cql3/values.hh"
|
||||
#include "database_fwd.hh"
|
||||
|
||||
class row;
|
||||
|
||||
@@ -580,8 +581,8 @@ extern expression replace_token(const expression&, const column_definition*);
|
||||
extern expression search_and_replace(const expression& e,
|
||||
const noncopyable_function<std::optional<expression> (const expression& candidate)>& replace_candidate);
|
||||
|
||||
extern expression prepare_expression(const expression& expr, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver);
|
||||
extern expression prepare_expression_multi_column(const expression& expr, database& db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers);
|
||||
extern expression prepare_expression(const expression& expr, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver);
|
||||
extern expression prepare_expression_multi_column(const expression& expr, data_dictionary::database db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers);
|
||||
|
||||
|
||||
/**
|
||||
@@ -593,11 +594,11 @@ extern expression prepare_expression_multi_column(const expression& expr, databa
|
||||
* Most caller should just call the is_assignable() method on the result, though functions have a use for
|
||||
* testing "strong" equality to decide the most precise overload to pick when multiple could match.
|
||||
*/
|
||||
extern assignment_testable::test_result test_assignment(const expression& expr, database& db, const sstring& keyspace, const column_specification& receiver);
|
||||
extern assignment_testable::test_result test_assignment(const expression& expr, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver);
|
||||
|
||||
// Test all elements of exprs for assignment. If all are exact match, return exact match. If any is not assignable,
|
||||
// return not assignable. Otherwise, return weakly assignable.
|
||||
extern assignment_testable::test_result test_assignment_all(const std::vector<expression>& exprs, database& db, const sstring& keyspace, const column_specification& receiver);
|
||||
extern assignment_testable::test_result test_assignment_all(const std::vector<expression>& exprs, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver);
|
||||
|
||||
extern shared_ptr<assignment_testable> as_assignment_testable(expression e);
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ usertype_field_spec_of(const column_specification& column, size_t field) {
|
||||
|
||||
static
|
||||
void
|
||||
usertype_constructor_validate_assignable_to(const usertype_constructor& u, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
usertype_constructor_validate_assignable_to(const usertype_constructor& u, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
if (!receiver.type->is_user_type()) {
|
||||
throw exceptions::invalid_request_exception(format("Invalid user type literal for {} of type {}", receiver.name, receiver.type->as_cql3_type()));
|
||||
}
|
||||
@@ -72,7 +72,7 @@ usertype_constructor_validate_assignable_to(const usertype_constructor& u, datab
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
usertype_constructor_test_assignment(const usertype_constructor& u, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
usertype_constructor_test_assignment(const usertype_constructor& u, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
try {
|
||||
usertype_constructor_validate_assignable_to(u, db, keyspace, receiver);
|
||||
return assignment_testable::test_result::WEAKLY_ASSIGNABLE;
|
||||
@@ -83,7 +83,7 @@ usertype_constructor_test_assignment(const usertype_constructor& u, database& db
|
||||
|
||||
static
|
||||
expression
|
||||
usertype_constructor_prepare_expression(const usertype_constructor& u, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
usertype_constructor_prepare_expression(const usertype_constructor& u, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
usertype_constructor_validate_assignable_to(u, db, keyspace, *receiver);
|
||||
auto&& ut = static_pointer_cast<const user_type_impl>(receiver->type);
|
||||
bool all_terminal = true;
|
||||
@@ -150,7 +150,7 @@ map_value_spec_of(const column_specification& column) {
|
||||
|
||||
static
|
||||
void
|
||||
map_validate_assignable_to(const collection_constructor& c, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
map_validate_assignable_to(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
if (!receiver.type->without_reversed().is_map()) {
|
||||
throw exceptions::invalid_request_exception(format("Invalid map literal for {} of type {}", *receiver.name, receiver.type->as_cql3_type()));
|
||||
}
|
||||
@@ -172,7 +172,7 @@ map_validate_assignable_to(const collection_constructor& c, database& db, const
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
map_test_assignment(const collection_constructor& c, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
map_test_assignment(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
if (!dynamic_pointer_cast<const map_type_impl>(receiver.type)) {
|
||||
return assignment_testable::test_result::NOT_ASSIGNABLE;
|
||||
}
|
||||
@@ -201,7 +201,7 @@ map_test_assignment(const collection_constructor& c, database& db, const sstring
|
||||
|
||||
static
|
||||
expression
|
||||
map_prepare_expression(const collection_constructor& c, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
map_prepare_expression(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
map_validate_assignable_to(c, db, keyspace, *receiver);
|
||||
|
||||
auto key_spec = maps::key_spec_of(*receiver);
|
||||
@@ -254,7 +254,7 @@ set_value_spec_of(const column_specification& column) {
|
||||
|
||||
static
|
||||
void
|
||||
set_validate_assignable_to(const collection_constructor& c, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
set_validate_assignable_to(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
if (!receiver.type->without_reversed().is_set()) {
|
||||
// We've parsed empty maps as a set literal to break the ambiguity so
|
||||
// handle that case now
|
||||
@@ -275,7 +275,7 @@ set_validate_assignable_to(const collection_constructor& c, database& db, const
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
set_test_assignment(const collection_constructor& c, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
set_test_assignment(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
if (!receiver.type->without_reversed().is_set()) {
|
||||
// We've parsed empty maps as a set literal to break the ambiguity so handle that case now
|
||||
if (dynamic_pointer_cast<const map_type_impl>(receiver.type) && c.elements.empty()) {
|
||||
@@ -296,7 +296,7 @@ set_test_assignment(const collection_constructor& c, database& db, const sstring
|
||||
|
||||
static
|
||||
expression
|
||||
set_prepare_expression(const collection_constructor& c, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
set_prepare_expression(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
set_validate_assignable_to(c, db, keyspace, *receiver);
|
||||
|
||||
if (c.elements.empty()) {
|
||||
@@ -363,7 +363,7 @@ list_value_spec_of(const column_specification& column) {
|
||||
|
||||
static
|
||||
void
|
||||
list_validate_assignable_to(const collection_constructor& c, database& db, const sstring keyspace, const column_specification& receiver) {
|
||||
list_validate_assignable_to(const collection_constructor& c, data_dictionary::database db, const sstring keyspace, const column_specification& receiver) {
|
||||
if (!receiver.type->without_reversed().is_list()) {
|
||||
throw exceptions::invalid_request_exception(format("Invalid list literal for {} of type {}",
|
||||
*receiver.name, receiver.type->as_cql3_type()));
|
||||
@@ -379,7 +379,7 @@ list_validate_assignable_to(const collection_constructor& c, database& db, const
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
list_test_assignment(const collection_constructor& c, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
list_test_assignment(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
if (!dynamic_pointer_cast<const list_type_impl>(receiver.type)) {
|
||||
return assignment_testable::test_result::NOT_ASSIGNABLE;
|
||||
}
|
||||
@@ -396,7 +396,7 @@ list_test_assignment(const collection_constructor& c, database& db, const sstrin
|
||||
|
||||
static
|
||||
expression
|
||||
list_prepare_expression(const collection_constructor& c, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
list_prepare_expression(const collection_constructor& c, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
list_validate_assignable_to(c, db, keyspace, *receiver);
|
||||
|
||||
// In Cassandra, an empty (unfrozen) map/set/list is equivalent to the column being null. In
|
||||
@@ -446,7 +446,7 @@ component_spec_of(const column_specification& column, size_t component) {
|
||||
|
||||
static
|
||||
void
|
||||
tuple_constructor_validate_assignable_to(const tuple_constructor& tc, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
tuple_constructor_validate_assignable_to(const tuple_constructor& tc, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
auto tt = dynamic_pointer_cast<const tuple_type_impl>(receiver.type->underlying_type());
|
||||
if (!tt) {
|
||||
throw exceptions::invalid_request_exception(format("Invalid tuple type literal for {} of type {}", receiver.name, receiver.type->as_cql3_type()));
|
||||
@@ -467,7 +467,7 @@ tuple_constructor_validate_assignable_to(const tuple_constructor& tc, database&
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
tuple_constructor_test_assignment(const tuple_constructor& tc, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
tuple_constructor_test_assignment(const tuple_constructor& tc, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
try {
|
||||
tuple_constructor_validate_assignable_to(tc, db, keyspace, receiver);
|
||||
return assignment_testable::test_result::WEAKLY_ASSIGNABLE;
|
||||
@@ -478,7 +478,7 @@ tuple_constructor_test_assignment(const tuple_constructor& tc, database& db, con
|
||||
|
||||
static
|
||||
expression
|
||||
tuple_constructor_prepare_nontuple(const tuple_constructor& tc, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
tuple_constructor_prepare_nontuple(const tuple_constructor& tc, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
tuple_constructor_validate_assignable_to(tc, db, keyspace, *receiver);
|
||||
std::vector<expression> values;
|
||||
bool all_terminal = true;
|
||||
@@ -502,7 +502,7 @@ tuple_constructor_prepare_nontuple(const tuple_constructor& tc, database& db, co
|
||||
|
||||
static
|
||||
expression
|
||||
tuple_constructor_prepare_tuple(const tuple_constructor& tc, database& db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers) {
|
||||
tuple_constructor_prepare_tuple(const tuple_constructor& tc, data_dictionary::database db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers) {
|
||||
if (tc.elements.size() != receivers.size()) {
|
||||
throw exceptions::invalid_request_exception(format("Expected {:d} elements in value tuple, but got {:d}: {}", receivers.size(), tc.elements.size(), tc));
|
||||
}
|
||||
@@ -566,7 +566,7 @@ untyped_constant_parsed_value(const untyped_constant uc, data_type validator)
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
untyped_constant_test_assignment(const untyped_constant& uc, database& db, const sstring& keyspace, const column_specification& receiver)
|
||||
untyped_constant_test_assignment(const untyped_constant& uc, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver)
|
||||
{
|
||||
auto receiver_type = receiver.type->as_cql3_type();
|
||||
if (receiver_type.is_collection() || receiver_type.is_user_type()) {
|
||||
@@ -640,7 +640,7 @@ untyped_constant_test_assignment(const untyped_constant& uc, database& db, const
|
||||
|
||||
static
|
||||
constant
|
||||
untyped_constant_prepare_expression(const untyped_constant& uc, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver)
|
||||
untyped_constant_prepare_expression(const untyped_constant& uc, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver)
|
||||
{
|
||||
if (!is_assignable(untyped_constant_test_assignment(uc, db, keyspace, *receiver))) {
|
||||
throw exceptions::invalid_request_exception(format("Invalid {} constant ({}) for \"{}\" of type {}",
|
||||
@@ -652,13 +652,13 @@ untyped_constant_prepare_expression(const untyped_constant& uc, database& db, co
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
bind_variable_test_assignment(const bind_variable& bv, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
bind_variable_test_assignment(const bind_variable& bv, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
return assignment_testable::test_result::WEAKLY_ASSIGNABLE;
|
||||
}
|
||||
|
||||
static
|
||||
bind_variable
|
||||
bind_variable_scalar_prepare_expression(const bind_variable& bv, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver)
|
||||
bind_variable_scalar_prepare_expression(const bind_variable& bv, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver)
|
||||
{
|
||||
return bind_variable {
|
||||
.shape = bind_variable::shape_type::scalar,
|
||||
@@ -676,7 +676,7 @@ bind_variable_scalar_in_make_receiver(const column_specification& receiver) {
|
||||
|
||||
static
|
||||
bind_variable
|
||||
bind_variable_scalar_in_prepare_expression(const bind_variable& bv, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
bind_variable_scalar_in_prepare_expression(const bind_variable& bv, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
return bind_variable {
|
||||
.shape = bind_variable::shape_type::scalar,
|
||||
.bind_index = bv.bind_index,
|
||||
@@ -706,7 +706,7 @@ bind_variable_tuple_make_receiver(const std::vector<lw_shared_ptr<column_specifi
|
||||
|
||||
static
|
||||
bind_variable
|
||||
bind_variable_tuple_prepare_expression(const bind_variable& bv, database& db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers) {
|
||||
bind_variable_tuple_prepare_expression(const bind_variable& bv, data_dictionary::database db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers) {
|
||||
return bind_variable {
|
||||
.shape = bind_variable::shape_type::tuple,
|
||||
.bind_index = bv.bind_index,
|
||||
@@ -741,7 +741,7 @@ bind_variable_tuple_in_make_receiver(const std::vector<lw_shared_ptr<column_spec
|
||||
|
||||
static
|
||||
bind_variable
|
||||
bind_variable_tuple_in_prepare_expression(const bind_variable& bv, database& db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers) {
|
||||
bind_variable_tuple_in_prepare_expression(const bind_variable& bv, data_dictionary::database db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers) {
|
||||
return bind_variable {
|
||||
.shape = bind_variable::shape_type::tuple_in,
|
||||
.bind_index = bv.bind_index,
|
||||
@@ -751,7 +751,7 @@ bind_variable_tuple_in_prepare_expression(const bind_variable& bv, database& db,
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
null_test_assignment(database& db,
|
||||
null_test_assignment(data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
const column_specification& receiver) {
|
||||
return receiver.type->is_counter()
|
||||
@@ -761,7 +761,7 @@ null_test_assignment(database& db,
|
||||
|
||||
static
|
||||
constant
|
||||
null_prepare_expression(database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
null_prepare_expression(data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
if (!is_assignable(null_test_assignment(db, keyspace, *receiver))) {
|
||||
throw exceptions::invalid_request_exception("Invalid null value for counter increment/decrement");
|
||||
}
|
||||
@@ -776,7 +776,7 @@ cast_display_name(const cast& c) {
|
||||
|
||||
static
|
||||
lw_shared_ptr<column_specification>
|
||||
casted_spec_of(const cast& c, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
casted_spec_of(const cast& c, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
auto& type = std::get<shared_ptr<cql3_type::raw>>(c.type);
|
||||
return make_lw_shared<column_specification>(receiver.ks_name, receiver.cf_name,
|
||||
::make_shared<column_identifier>(cast_display_name(c), true), type->prepare(db, keyspace).get_type());
|
||||
@@ -784,7 +784,7 @@ casted_spec_of(const cast& c, database& db, const sstring& keyspace, const colum
|
||||
|
||||
static
|
||||
assignment_testable::test_result
|
||||
cast_test_assignment(const cast& c, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
cast_test_assignment(const cast& c, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
auto type = std::get<shared_ptr<cql3_type::raw>>(c.type);
|
||||
try {
|
||||
auto&& casted_type = type->prepare(db, keyspace).get_type();
|
||||
@@ -802,7 +802,7 @@ cast_test_assignment(const cast& c, database& db, const sstring& keyspace, const
|
||||
|
||||
static
|
||||
expression
|
||||
cast_prepare_expression(const cast& c, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
cast_prepare_expression(const cast& c, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
auto type = std::get<shared_ptr<cql3_type::raw>>(c.type);
|
||||
if (!is_assignable(test_assignment(c.arg, db, keyspace, *casted_spec_of(c, db, keyspace, *receiver)))) {
|
||||
throw exceptions::invalid_request_exception(format("Cannot cast value {} to type {}", c.arg, type));
|
||||
@@ -814,7 +814,7 @@ cast_prepare_expression(const cast& c, database& db, const sstring& keyspace, lw
|
||||
}
|
||||
|
||||
expr::expression
|
||||
prepare_function_call(const expr::function_call& fc, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
prepare_function_call(const expr::function_call& fc, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
auto&& fun = std::visit(overloaded_functor{
|
||||
[] (const shared_ptr<functions::function>& func) {
|
||||
return func;
|
||||
@@ -875,7 +875,7 @@ prepare_function_call(const expr::function_call& fc, database& db, const sstring
|
||||
}
|
||||
|
||||
assignment_testable::test_result
|
||||
test_assignment_function_call(const cql3::expr::function_call& fc, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
test_assignment_function_call(const cql3::expr::function_call& fc, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
// Note: Functions.get() will return null if the function doesn't exist, or throw is no function matching
|
||||
// the arguments can be found. We may get one of those if an undefined/wrong function is used as argument
|
||||
// of another, existing, function. In that case, we return true here because we'll throw a proper exception
|
||||
@@ -903,7 +903,7 @@ test_assignment_function_call(const cql3::expr::function_call& fc, database& db,
|
||||
}
|
||||
|
||||
expression
|
||||
prepare_expression(const expression& expr, database& db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
prepare_expression(const expression& expr, data_dictionary::database db, const sstring& keyspace, lw_shared_ptr<column_specification> receiver) {
|
||||
return expr::visit(overloaded_functor{
|
||||
[] (const constant&) -> expression {
|
||||
on_internal_error(expr_logger, "Can't prepare constant_value, it should not appear in parser output");
|
||||
@@ -968,7 +968,7 @@ prepare_expression(const expression& expr, database& db, const sstring& keyspace
|
||||
}
|
||||
|
||||
expression
|
||||
prepare_expression_multi_column(const expression& expr, database& db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers) {
|
||||
prepare_expression_multi_column(const expression& expr, data_dictionary::database db, const sstring& keyspace, const std::vector<lw_shared_ptr<column_specification>>& receivers) {
|
||||
return expr::visit(overloaded_functor{
|
||||
[&] (const bind_variable& bv) -> expression {
|
||||
switch (bv.shape) {
|
||||
@@ -989,7 +989,7 @@ prepare_expression_multi_column(const expression& expr, database& db, const sstr
|
||||
}
|
||||
|
||||
assignment_testable::test_result
|
||||
test_assignment(const expression& expr, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
test_assignment(const expression& expr, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
using test_result = assignment_testable::test_result;
|
||||
return expr::visit(overloaded_functor{
|
||||
[&] (const constant&) -> test_result {
|
||||
@@ -1051,7 +1051,7 @@ test_assignment(const expression& expr, database& db, const sstring& keyspace, c
|
||||
}
|
||||
|
||||
assignment_testable::test_result
|
||||
test_assignment_all(const std::vector<expression>& to_test, database& db, const sstring& keyspace, const column_specification& receiver) {
|
||||
test_assignment_all(const std::vector<expression>& to_test, data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) {
|
||||
using test_result = assignment_testable::test_result;
|
||||
test_result res = test_result::EXACT_MATCH;
|
||||
for (auto&& e : to_test) {
|
||||
@@ -1070,7 +1070,7 @@ class assignment_testable_expression : public assignment_testable {
|
||||
expression _e;
|
||||
public:
|
||||
explicit assignment_testable_expression(expression e) : _e(std::move(e)) {}
|
||||
virtual test_result test_assignment(database& db, const sstring& keyspace, const column_specification& receiver) const override {
|
||||
virtual test_result test_assignment(data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) const override {
|
||||
return expr::test_assignment(_e, db, keyspace, receiver);
|
||||
}
|
||||
virtual sstring assignment_testable_source_context() const override {
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "cql3/constants.hh"
|
||||
#include "cql3/user_types.hh"
|
||||
#include "cql3/type_json.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "types/map.hh"
|
||||
#include "types/set.hh"
|
||||
#include "types/list.hh"
|
||||
@@ -191,7 +191,7 @@ make_to_json_function(data_type t) {
|
||||
|
||||
inline
|
||||
shared_ptr<function>
|
||||
make_from_json_function(database& db, const sstring& keyspace, data_type t) {
|
||||
make_from_json_function(data_dictionary::database db, const sstring& keyspace, data_type t) {
|
||||
return make_native_scalar_function<true>("fromjson", t, {utf8_type},
|
||||
[&db, keyspace, t](cql_serialization_format sf, const std::vector<bytes_opt>& parameters) -> bytes_opt {
|
||||
try {
|
||||
@@ -209,7 +209,7 @@ make_from_json_function(database& db, const sstring& keyspace, data_type t) {
|
||||
}
|
||||
|
||||
shared_ptr<function>
|
||||
functions::get(database& db,
|
||||
functions::get(data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
const function_name& name,
|
||||
const std::vector<shared_ptr<assignment_testable>>& provided_args,
|
||||
@@ -376,7 +376,7 @@ functions::find(const function_name& name, const std::vector<data_type>& arg_typ
|
||||
// This method and matchArguments are somewhat duplicate, but this method allows us to provide more precise errors in the common
|
||||
// case where there is no override for a given function. This is thus probably worth the minor code duplication.
|
||||
void
|
||||
functions::validate_types(database& db,
|
||||
functions::validate_types(data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
shared_ptr<function> fun,
|
||||
const std::vector<shared_ptr<assignment_testable>>& provided_args,
|
||||
@@ -407,7 +407,7 @@ functions::validate_types(database& db,
|
||||
}
|
||||
|
||||
assignment_testable::test_result
|
||||
functions::match_arguments(database& db, const sstring& keyspace,
|
||||
functions::match_arguments(data_dictionary::database db, const sstring& keyspace,
|
||||
shared_ptr<function> fun,
|
||||
const std::vector<shared_ptr<assignment_testable>>& provided_args,
|
||||
const sstring& receiver_ks,
|
||||
|
||||
@@ -70,7 +70,7 @@ public:
|
||||
static lw_shared_ptr<column_specification> make_arg_spec(const sstring& receiver_ks, const sstring& receiver_cf,
|
||||
const function& fun, size_t i);
|
||||
public:
|
||||
static shared_ptr<function> get(database& db,
|
||||
static shared_ptr<function> get(data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
const function_name& name,
|
||||
const std::vector<shared_ptr<assignment_testable>>& provided_args,
|
||||
@@ -78,7 +78,7 @@ public:
|
||||
const sstring& receiver_cf,
|
||||
const column_specification* receiver = nullptr);
|
||||
template <typename AssignmentTestablePtrRange>
|
||||
static shared_ptr<function> get(database& db,
|
||||
static shared_ptr<function> get(data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
const function_name& name,
|
||||
AssignmentTestablePtrRange&& provided_args,
|
||||
@@ -102,13 +102,13 @@ private:
|
||||
|
||||
// This method and matchArguments are somewhat duplicate, but this method allows us to provide more precise errors in the common
|
||||
// case where there is no override for a given function. This is thus probably worth the minor code duplication.
|
||||
static void validate_types(database& db,
|
||||
static void validate_types(data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
shared_ptr<function> fun,
|
||||
const std::vector<shared_ptr<assignment_testable>>& provided_args,
|
||||
const sstring& receiver_ks,
|
||||
const sstring& receiver_cf);
|
||||
static assignment_testable::test_result match_arguments(database& db, const sstring& keyspace,
|
||||
static assignment_testable::test_result match_arguments(data_dictionary::database db, const sstring& keyspace,
|
||||
shared_ptr<function> fun,
|
||||
const std::vector<shared_ptr<assignment_testable>>& provided_args,
|
||||
const sstring& receiver_ks,
|
||||
|
||||
@@ -149,7 +149,7 @@ public:
|
||||
virtual bool is_multi_column() const override { return true; }
|
||||
|
||||
protected:
|
||||
virtual shared_ptr<restrictions::restriction> new_EQ_restriction(database& db, schema_ptr schema,
|
||||
virtual shared_ptr<restrictions::restriction> new_EQ_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx) override {
|
||||
auto rs = receivers(db, *schema);
|
||||
std::vector<lw_shared_ptr<column_specification>> col_specs(rs.size());
|
||||
@@ -160,7 +160,7 @@ protected:
|
||||
return ::make_shared<restrictions::multi_column_restriction::EQ>(schema, rs, std::move(e));
|
||||
}
|
||||
|
||||
virtual shared_ptr<restrictions::restriction> new_IN_restriction(database& db, schema_ptr schema,
|
||||
virtual shared_ptr<restrictions::restriction> new_IN_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx) override {
|
||||
auto rs = receivers(db, *schema);
|
||||
std::vector<lw_shared_ptr<column_specification>> col_specs(rs.size());
|
||||
@@ -183,7 +183,7 @@ protected:
|
||||
}
|
||||
}
|
||||
|
||||
virtual shared_ptr<restrictions::restriction> new_slice_restriction(database& db, schema_ptr schema,
|
||||
virtual shared_ptr<restrictions::restriction> new_slice_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx,
|
||||
statements::bound bound, bool inclusive) override {
|
||||
auto rs = receivers(db, *schema);
|
||||
@@ -195,13 +195,13 @@ protected:
|
||||
return ::make_shared<restrictions::multi_column_restriction::slice>(schema, rs, bound, inclusive, std::move(e), _mode);
|
||||
}
|
||||
|
||||
virtual shared_ptr<restrictions::restriction> new_contains_restriction(database& db, schema_ptr schema,
|
||||
virtual shared_ptr<restrictions::restriction> new_contains_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx, bool is_key) override {
|
||||
throw exceptions::invalid_request_exception(format("{} cannot be used for Multi-column relations", get_operator()));
|
||||
}
|
||||
|
||||
virtual ::shared_ptr<restrictions::restriction> new_LIKE_restriction(
|
||||
database& db, schema_ptr schema, prepare_context& ctx) override {
|
||||
data_dictionary::database db, schema_ptr schema, prepare_context& ctx) override {
|
||||
throw exceptions::invalid_request_exception("LIKE cannot be used for Multi-column relations");
|
||||
}
|
||||
|
||||
@@ -213,14 +213,14 @@ protected:
|
||||
}
|
||||
|
||||
virtual expr::expression to_expression(const std::vector<lw_shared_ptr<column_specification>>& receivers,
|
||||
const expr::expression& raw, database& db, const sstring& keyspace,
|
||||
const expr::expression& raw, data_dictionary::database db, const sstring& keyspace,
|
||||
prepare_context& ctx) const override {
|
||||
auto e = prepare_expression_multi_column(raw, db, keyspace, receivers);
|
||||
expr::fill_prepare_context(e, ctx);
|
||||
return e;
|
||||
}
|
||||
|
||||
std::vector<const column_definition*> receivers(database& db, const schema& schema) {
|
||||
std::vector<const column_definition*> receivers(data_dictionary::database db, const schema& schema) {
|
||||
using namespace statements::request_validations;
|
||||
|
||||
int previous_position = -1;
|
||||
|
||||
@@ -58,7 +58,7 @@ operation::set_element::to_string(const column_definition& receiver) const {
|
||||
}
|
||||
|
||||
shared_ptr<operation>
|
||||
operation::set_element::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::set_element::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
using exceptions::invalid_request_exception;
|
||||
auto rtype = dynamic_pointer_cast<const collection_type_impl>(receiver.type);
|
||||
if (!rtype) {
|
||||
@@ -99,7 +99,7 @@ operation::set_field::to_string(const column_definition& receiver) const {
|
||||
}
|
||||
|
||||
shared_ptr<operation>
|
||||
operation::set_field::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::set_field::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
if (!receiver.type->is_user_type()) {
|
||||
throw exceptions::invalid_request_exception(
|
||||
format("Invalid operation ({}) for non-UDT column {}", to_string(receiver), receiver.name_as_text()));
|
||||
@@ -135,7 +135,7 @@ operation::field_deletion::affected_column() const {
|
||||
}
|
||||
|
||||
shared_ptr<operation>
|
||||
operation::field_deletion::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::field_deletion::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
if (!receiver.type->is_user_type()) {
|
||||
throw exceptions::invalid_request_exception(
|
||||
format("Invalid deletion operation for non-UDT column {}", receiver.name_as_text()));
|
||||
@@ -160,7 +160,7 @@ operation::addition::to_string(const column_definition& receiver) const {
|
||||
}
|
||||
|
||||
shared_ptr<operation>
|
||||
operation::addition::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::addition::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
auto v = prepare_expression(_value, db, keyspace, receiver.column_specification);
|
||||
|
||||
auto ctype = dynamic_pointer_cast<const collection_type_impl>(receiver.type);
|
||||
@@ -195,7 +195,7 @@ operation::subtraction::to_string(const column_definition& receiver) const {
|
||||
}
|
||||
|
||||
shared_ptr<operation>
|
||||
operation::subtraction::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::subtraction::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
auto ctype = dynamic_pointer_cast<const collection_type_impl>(receiver.type);
|
||||
if (!ctype) {
|
||||
if (!receiver.is_counter()) {
|
||||
@@ -237,7 +237,7 @@ operation::prepend::to_string(const column_definition& receiver) const {
|
||||
}
|
||||
|
||||
shared_ptr<operation>
|
||||
operation::prepend::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::prepend::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
auto v = prepare_expression(_value, db, keyspace, receiver.column_specification);
|
||||
|
||||
if (!dynamic_cast<const list_type_impl*>(receiver.type.get())) {
|
||||
@@ -256,7 +256,7 @@ operation::prepend::is_compatible_with(const std::unique_ptr<raw_update>& other)
|
||||
|
||||
|
||||
::shared_ptr <operation>
|
||||
operation::set_value::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::set_value::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
auto v = prepare_expression(_value, db, keyspace, receiver.column_specification);
|
||||
|
||||
if (receiver.type->is_counter()) {
|
||||
@@ -284,7 +284,7 @@ operation::set_value::prepare(database& db, const sstring& keyspace, const colum
|
||||
}
|
||||
|
||||
::shared_ptr <operation>
|
||||
operation::set_counter_value_from_tuple_list::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::set_counter_value_from_tuple_list::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
static thread_local const data_type counter_tuple_type = tuple_type_impl::get_instance({int32_type, uuid_type, long_type, long_type});
|
||||
static thread_local const data_type counter_tuple_list_type = list_type_impl::get_instance(counter_tuple_type, true);
|
||||
|
||||
@@ -372,7 +372,7 @@ operation::element_deletion::affected_column() const {
|
||||
}
|
||||
|
||||
shared_ptr<operation>
|
||||
operation::element_deletion::prepare(database& db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
operation::element_deletion::prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const {
|
||||
if (!receiver.type->is_collection()) {
|
||||
throw exceptions::invalid_request_exception(format("Invalid deletion operation for non collection column {}", receiver.name()));
|
||||
} else if (!receiver.type->is_multi_cell()) {
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
#include <seastar/core/shared_ptr.hh>
|
||||
#include "exceptions/exceptions.hh"
|
||||
#include "database_fwd.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "update_parameters.hh"
|
||||
#include "cql3/column_identifier.hh"
|
||||
#include "cql3/expr/expression.hh"
|
||||
@@ -143,7 +143,7 @@ public:
|
||||
* be a true column.
|
||||
* @return the prepared update operation.
|
||||
*/
|
||||
virtual ::shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const = 0;
|
||||
virtual ::shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const = 0;
|
||||
|
||||
/**
|
||||
* @return whether this operation can be applied alongside the {@code
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
* @param receiver the "column" this operation applies to.
|
||||
* @return the prepared delete operation.
|
||||
*/
|
||||
virtual ::shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const = 0;
|
||||
virtual ::shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const = 0;
|
||||
};
|
||||
|
||||
class set_value;
|
||||
@@ -197,7 +197,7 @@ public:
|
||||
: _selector(std::move(selector)), _value(std::move(value)), _by_uuid(by_uuid) {
|
||||
}
|
||||
|
||||
virtual shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
virtual shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
|
||||
virtual bool is_compatible_with(const std::unique_ptr<raw_update>& other) const override;
|
||||
};
|
||||
@@ -213,7 +213,7 @@ public:
|
||||
: _field(std::move(field)), _value(std::move(value)) {
|
||||
}
|
||||
|
||||
virtual shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
virtual shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
|
||||
virtual bool is_compatible_with(const std::unique_ptr<raw_update>& other) const override;
|
||||
};
|
||||
@@ -230,7 +230,7 @@ public:
|
||||
|
||||
virtual const column_identifier::raw& affected_column() const override;
|
||||
|
||||
virtual shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
virtual shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
};
|
||||
|
||||
class addition : public raw_update {
|
||||
@@ -242,7 +242,7 @@ public:
|
||||
: _value(std::move(value)) {
|
||||
}
|
||||
|
||||
virtual shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
virtual shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
|
||||
virtual bool is_compatible_with(const std::unique_ptr<raw_update>& other) const override;
|
||||
};
|
||||
@@ -256,7 +256,7 @@ public:
|
||||
: _value(std::move(value)) {
|
||||
}
|
||||
|
||||
virtual shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
virtual shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
|
||||
virtual bool is_compatible_with(const std::unique_ptr<raw_update>& other) const override;
|
||||
};
|
||||
@@ -270,7 +270,7 @@ public:
|
||||
: _value(std::move(value)) {
|
||||
}
|
||||
|
||||
virtual shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
virtual shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
|
||||
virtual bool is_compatible_with(const std::unique_ptr<raw_update>& other) const override;
|
||||
};
|
||||
@@ -285,7 +285,7 @@ public:
|
||||
: _id(std::move(id)), _element(std::move(element)) {
|
||||
}
|
||||
virtual const column_identifier::raw& affected_column() const override;
|
||||
virtual shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
virtual shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ protected:
|
||||
public:
|
||||
set_value(expr::expression value) : _value(std::move(value)) {}
|
||||
|
||||
virtual ::shared_ptr <operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
virtual ::shared_ptr <operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
|
||||
#if 0
|
||||
protected String toString(ColumnSpecification column)
|
||||
@@ -71,7 +71,7 @@ public:
|
||||
class operation::set_counter_value_from_tuple_list : public set_value {
|
||||
public:
|
||||
using set_value::set_value;
|
||||
::shared_ptr <operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
::shared_ptr <operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override;
|
||||
};
|
||||
|
||||
class operation::column_deletion : public raw_deletion {
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
return *_id;
|
||||
}
|
||||
|
||||
virtual ::shared_ptr<operation> prepare(database& db, const sstring& keyspace, const column_definition& receiver) const override {
|
||||
virtual ::shared_ptr<operation> prepare(data_dictionary::database db, const sstring& keyspace, const column_definition& receiver) const override {
|
||||
// No validation, deleting a column is always "well typed"
|
||||
return ::make_shared<constants::deleter>(receiver);
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#include "cql3/util.hh"
|
||||
#include "cql3/untyped_result_set.hh"
|
||||
#include "db/config.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "hashers.hh"
|
||||
|
||||
namespace cql3 {
|
||||
@@ -85,7 +85,7 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
query_processor::query_processor(service::storage_proxy& proxy, database& db, service::migration_notifier& mn, service::migration_manager& mm, query_processor::memory_config mcfg, cql_config& cql_cfg)
|
||||
query_processor::query_processor(service::storage_proxy& proxy, data_dictionary::database db, service::migration_notifier& mn, service::migration_manager& mm, query_processor::memory_config mcfg, cql_config& cql_cfg)
|
||||
: _migration_subscriber{std::make_unique<migration_subscriber>(this)}
|
||||
, _proxy(proxy)
|
||||
, _db(db)
|
||||
|
||||
@@ -119,7 +119,7 @@ public:
|
||||
private:
|
||||
std::unique_ptr<migration_subscriber> _migration_subscriber;
|
||||
service::storage_proxy& _proxy;
|
||||
database& _db;
|
||||
data_dictionary::database _db;
|
||||
service::migration_notifier& _mnotifier;
|
||||
service::migration_manager& _mm;
|
||||
const cql_config& _cql_config;
|
||||
@@ -157,11 +157,11 @@ public:
|
||||
static std::unique_ptr<statements::raw::parsed_statement> parse_statement(const std::string_view& query);
|
||||
static std::vector<std::unique_ptr<statements::raw::parsed_statement>> parse_statements(std::string_view queries);
|
||||
|
||||
query_processor(service::storage_proxy& proxy, database& db, service::migration_notifier& mn, service::migration_manager& mm, memory_config mcfg, cql_config& cql_cfg);
|
||||
query_processor(service::storage_proxy& proxy, data_dictionary::database db, service::migration_notifier& mn, service::migration_manager& mm, memory_config mcfg, cql_config& cql_cfg);
|
||||
|
||||
~query_processor();
|
||||
|
||||
database& db() {
|
||||
data_dictionary::database db() {
|
||||
return _db;
|
||||
}
|
||||
|
||||
|
||||
@@ -138,7 +138,7 @@ public:
|
||||
* @return the <code>Restriction</code> corresponding to this <code>Relation</code>
|
||||
* @throws InvalidRequestException if this <code>Relation</code> is not valid
|
||||
*/
|
||||
virtual ::shared_ptr<restrictions::restriction> to_restriction(database& db, schema_ptr schema, prepare_context& ctx) final {
|
||||
virtual ::shared_ptr<restrictions::restriction> to_restriction(data_dictionary::database db, schema_ptr schema, prepare_context& ctx) final {
|
||||
if (_relation_type == expr::oper_t::EQ) {
|
||||
return new_EQ_restriction(db, schema, ctx);
|
||||
} else if (_relation_type == expr::oper_t::LT) {
|
||||
@@ -180,7 +180,7 @@ public:
|
||||
* @return a new EQ restriction instance.
|
||||
* @throws InvalidRequestException if the relation cannot be converted into an EQ restriction.
|
||||
*/
|
||||
virtual ::shared_ptr<restrictions::restriction> new_EQ_restriction(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<restrictions::restriction> new_EQ_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx) = 0;
|
||||
|
||||
/**
|
||||
@@ -191,7 +191,7 @@ public:
|
||||
* @return a new IN restriction instance
|
||||
* @throws InvalidRequestException if the relation cannot be converted into an IN restriction.
|
||||
*/
|
||||
virtual ::shared_ptr<restrictions::restriction> new_IN_restriction(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<restrictions::restriction> new_IN_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx) = 0;
|
||||
|
||||
/**
|
||||
@@ -204,7 +204,7 @@ public:
|
||||
* @return a new slice restriction instance
|
||||
* @throws InvalidRequestException if the <code>Relation</code> is not valid
|
||||
*/
|
||||
virtual ::shared_ptr<restrictions::restriction> new_slice_restriction(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<restrictions::restriction> new_slice_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx,
|
||||
statements::bound bound,
|
||||
bool inclusive) = 0;
|
||||
@@ -218,13 +218,13 @@ public:
|
||||
* @return a new Contains <code>::shared_ptr<restrictions::restriction></code> instance
|
||||
* @throws InvalidRequestException if the <code>Relation</code> is not valid
|
||||
*/
|
||||
virtual ::shared_ptr<restrictions::restriction> new_contains_restriction(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<restrictions::restriction> new_contains_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx, bool isKey) = 0;
|
||||
|
||||
/**
|
||||
* Creates a new LIKE restriction instance.
|
||||
*/
|
||||
virtual ::shared_ptr<restrictions::restriction> new_LIKE_restriction(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<restrictions::restriction> new_LIKE_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx) = 0;
|
||||
|
||||
/**
|
||||
@@ -250,7 +250,7 @@ protected:
|
||||
*/
|
||||
virtual expr::expression to_expression(const std::vector<lw_shared_ptr<column_specification>>& receivers,
|
||||
const expr::expression& raw,
|
||||
database& db,
|
||||
data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
prepare_context& ctx) const = 0;
|
||||
|
||||
@@ -266,7 +266,7 @@ protected:
|
||||
*/
|
||||
std::vector<expr::expression> to_expressions(const std::vector<lw_shared_ptr<column_specification>>& receivers,
|
||||
const std::vector<expr::expression>& raws,
|
||||
database& db,
|
||||
data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
prepare_context& ctx) const {
|
||||
std::vector<expr::expression> expressions;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#include "statement_restrictions.hh"
|
||||
#include "multi_column_restriction.hh"
|
||||
#include "token_restriction.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "cartesian_product.hh"
|
||||
|
||||
#include "cql3/constants.hh"
|
||||
@@ -380,7 +380,7 @@ static std::vector<expr::expression> extract_clustering_prefix_restrictions(
|
||||
return prefix;
|
||||
}
|
||||
|
||||
statement_restrictions::statement_restrictions(database& db,
|
||||
statement_restrictions::statement_restrictions(data_dictionary::database db,
|
||||
schema_ptr schema,
|
||||
statements::statement_type type,
|
||||
const std::vector<::shared_ptr<relation>>& where_clause,
|
||||
@@ -446,7 +446,7 @@ statement_restrictions::statement_restrictions(database& db,
|
||||
_clustering_prefix_restrictions = extract_clustering_prefix_restrictions(*_where, _schema);
|
||||
_partition_range_restrictions = extract_partition_range(*_where, _schema);
|
||||
}
|
||||
auto& cf = db.find_column_family(schema);
|
||||
auto cf = db.find_column_family(schema);
|
||||
auto& sim = cf.get_index_manager();
|
||||
const expr::allow_local_index allow_local(
|
||||
!_partition_key_restrictions->has_unrestricted_components(*_schema)
|
||||
@@ -576,7 +576,7 @@ const single_column_restrictions::restrictions_map* get_individual_restrictions_
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
std::pair<std::optional<secondary_index::index>, ::shared_ptr<cql3::restrictions::restrictions>> statement_restrictions::find_idx(secondary_index::secondary_index_manager& sim) const {
|
||||
std::pair<std::optional<secondary_index::index>, ::shared_ptr<cql3::restrictions::restrictions>> statement_restrictions::find_idx(const secondary_index::secondary_index_manager& sim) const {
|
||||
std::optional<secondary_index::index> chosen_index;
|
||||
int chosen_index_score = 0;
|
||||
::shared_ptr<cql3::restrictions::restrictions> chosen_index_restrictions;
|
||||
@@ -606,7 +606,7 @@ bool statement_restrictions::has_eq_restriction_on_column(const column_definitio
|
||||
return expr::has_eq_restriction_on_column(column, *_where);
|
||||
}
|
||||
|
||||
std::vector<const column_definition*> statement_restrictions::get_column_defs_for_filtering(database& db) const {
|
||||
std::vector<const column_definition*> statement_restrictions::get_column_defs_for_filtering(data_dictionary::database db) const {
|
||||
std::vector<const column_definition*> column_defs_for_filtering;
|
||||
if (need_filtering()) {
|
||||
auto& sim = db.find_column_family(_schema).get_index_manager();
|
||||
@@ -1537,7 +1537,7 @@ bool statement_restrictions::need_filtering() const {
|
||||
if (_has_queriable_ck_index && _uses_secondary_indexing) {
|
||||
// In cases where we use an index, clustering column restrictions might cause the need for filtering.
|
||||
// TODO: This is overly conservative, there are some cases when this returns true but filtering
|
||||
// is not needed. Because of that the database will sometimes perform filtering when it's not actually needed.
|
||||
// is not needed. Because of that the data_dictionary::database will sometimes perform filtering when it's not actually needed.
|
||||
// Query performance shouldn't be affected much, at most we will filter rows that are all correct.
|
||||
// Here are some cases to consider:
|
||||
// On a table with primary key (p, c1, c2, c3) with an index on c3
|
||||
|
||||
@@ -150,7 +150,7 @@ public:
|
||||
*/
|
||||
statement_restrictions(schema_ptr schema, bool allow_filtering);
|
||||
|
||||
statement_restrictions(database& db,
|
||||
statement_restrictions(data_dictionary::database db,
|
||||
schema_ptr schema,
|
||||
statements::statement_type type,
|
||||
const std::vector<::shared_ptr<relation>>& where_clause,
|
||||
@@ -223,10 +223,10 @@ public:
|
||||
|
||||
/**
|
||||
* Builds a possibly empty collection of column definitions that will be used for filtering
|
||||
* @param db - the database context
|
||||
* @param db - the data_dictionary::database context
|
||||
* @return A list with the column definitions needed for filtering.
|
||||
*/
|
||||
std::vector<const column_definition*> get_column_defs_for_filtering(database& db) const;
|
||||
std::vector<const column_definition*> get_column_defs_for_filtering(data_dictionary::database db) const;
|
||||
|
||||
/**
|
||||
* Gives a score that the index has - index with the highest score will be chosen
|
||||
@@ -236,11 +236,11 @@ public:
|
||||
|
||||
/**
|
||||
* Determines the index to be used with the restriction.
|
||||
* @param db - the database context (for extracting index manager)
|
||||
* @param db - the data_dictionary::database context (for extracting index manager)
|
||||
* @return If an index can be used, an optional containing this index, otherwise an empty optional.
|
||||
* In case the index is returned, second parameter returns the index restriction it uses.
|
||||
*/
|
||||
std::pair<std::optional<secondary_index::index>, ::shared_ptr<cql3::restrictions::restrictions>> find_idx(secondary_index::secondary_index_manager& sim) const;
|
||||
std::pair<std::optional<secondary_index::index>, ::shared_ptr<cql3::restrictions::restrictions>> find_idx(const secondary_index::secondary_index_manager& sim) const;
|
||||
|
||||
/**
|
||||
* Checks if the partition key has some unrestricted components.
|
||||
|
||||
@@ -43,7 +43,7 @@ class selectable_column : public selectable {
|
||||
column_identifier _ci;
|
||||
public:
|
||||
explicit selectable_column(column_identifier ci) : _ci(std::move(ci)) {}
|
||||
virtual ::shared_ptr<selector::factory> new_selector_factory(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<selector::factory> new_selector_factory(data_dictionary::database db, schema_ptr schema,
|
||||
std::vector<const column_definition*>& defs) override;
|
||||
virtual sstring to_string() const override {
|
||||
return _ci.to_string();
|
||||
@@ -51,7 +51,7 @@ public:
|
||||
};
|
||||
|
||||
::shared_ptr<selector::factory>
|
||||
selectable_column::new_selector_factory(database& db, schema_ptr schema, std::vector<const column_definition*>& defs) {
|
||||
selectable_column::new_selector_factory(data_dictionary::database db, schema_ptr schema, std::vector<const column_definition*>& defs) {
|
||||
auto def = get_column_definition(*schema, _ci);
|
||||
if (!def) {
|
||||
throw exceptions::invalid_request_exception(format("Undefined name {} in selection clause", _ci.text()));
|
||||
@@ -65,7 +65,7 @@ selectable_column::new_selector_factory(database& db, schema_ptr schema, std::ve
|
||||
}
|
||||
|
||||
shared_ptr<selector::factory>
|
||||
selectable::writetime_or_ttl::new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
selectable::writetime_or_ttl::new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
auto&& def = s->get_column_definition(_id->name());
|
||||
if (!def || def->is_hidden_from_cql()) {
|
||||
throw exceptions::invalid_request_exception(format("Undefined name {} in selection clause", _id));
|
||||
@@ -90,7 +90,7 @@ selectable::writetime_or_ttl::to_string() const {
|
||||
}
|
||||
|
||||
shared_ptr<selector::factory>
|
||||
selectable::with_function::new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
selectable::with_function::new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
auto&& factories = selector_factories::create_factories_and_collect_column_definitions(_args, db, s, defs);
|
||||
|
||||
// resolve built-in functions before user defined functions
|
||||
@@ -118,7 +118,7 @@ make_count_rows_function_expression() {
|
||||
}
|
||||
|
||||
shared_ptr<selector::factory>
|
||||
selectable::with_anonymous_function::new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
selectable::with_anonymous_function::new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
auto&& factories = selector_factories::create_factories_and_collect_column_definitions(_args, db, s, defs);
|
||||
return abstract_function_selector::new_factory(_function, std::move(factories));
|
||||
}
|
||||
@@ -129,7 +129,7 @@ selectable::with_anonymous_function::to_string() const {
|
||||
}
|
||||
|
||||
shared_ptr<selector::factory>
|
||||
selectable::with_field_selection::new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
selectable::with_field_selection::new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
auto&& factory = _selected->new_selector_factory(db, s, defs);
|
||||
auto&& type = factory->new_instance()->get_type();
|
||||
if (!type->underlying_type()->is_user_type()) {
|
||||
@@ -153,7 +153,7 @@ selectable::with_field_selection::to_string() const {
|
||||
}
|
||||
|
||||
shared_ptr<selector::factory>
|
||||
selectable::with_cast::new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
selectable::with_cast::new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) {
|
||||
std::vector<shared_ptr<selectable>> args{_arg};
|
||||
auto&& factories = selector_factories::create_factories_and_collect_column_definitions(args, db, s, defs);
|
||||
auto&& fun = functions::castas_functions::get(_type.get_type(), factories->new_instances());
|
||||
|
||||
@@ -58,7 +58,7 @@ class selectable;
|
||||
class selectable {
|
||||
public:
|
||||
virtual ~selectable() {}
|
||||
virtual ::shared_ptr<selector::factory> new_selector_factory(database& db, schema_ptr schema, std::vector<const column_definition*>& defs) = 0;
|
||||
virtual ::shared_ptr<selector::factory> new_selector_factory(data_dictionary::database db, schema_ptr schema, std::vector<const column_definition*>& defs) = 0;
|
||||
virtual sstring to_string() const = 0;
|
||||
protected:
|
||||
static size_t add_and_get_index(const column_definition& def, std::vector<const column_definition*>& defs) {
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
|
||||
virtual sstring to_string() const override;
|
||||
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
};
|
||||
|
||||
class selectable::with_anonymous_function : public selectable {
|
||||
@@ -105,7 +105,7 @@ public:
|
||||
|
||||
virtual sstring to_string() const override;
|
||||
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
};
|
||||
|
||||
class selectable::with_cast : public selectable {
|
||||
@@ -118,7 +118,7 @@ public:
|
||||
|
||||
virtual sstring to_string() const override;
|
||||
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
virtual sstring to_string() const override;
|
||||
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -282,7 +282,7 @@ uint32_t selection::add_column_for_post_processing(const column_definition& c) {
|
||||
return _columns.size() - 1;
|
||||
}
|
||||
|
||||
::shared_ptr<selection> selection::from_selectors(database& db, schema_ptr schema, const std::vector<::shared_ptr<raw_selector>>& raw_selectors) {
|
||||
::shared_ptr<selection> selection::from_selectors(data_dictionary::database db, schema_ptr schema, const std::vector<::shared_ptr<raw_selector>>& raw_selectors) {
|
||||
std::vector<const column_definition*> defs;
|
||||
|
||||
::shared_ptr<selector_factories> factories =
|
||||
|
||||
@@ -156,7 +156,7 @@ private:
|
||||
static std::vector<lw_shared_ptr<column_specification>> collect_metadata(const schema& schema,
|
||||
const std::vector<::shared_ptr<raw_selector>>& raw_selectors, const selector_factories& factories);
|
||||
public:
|
||||
static ::shared_ptr<selection> from_selectors(database& db, schema_ptr schema, const std::vector<::shared_ptr<raw_selector>>& raw_selectors);
|
||||
static ::shared_ptr<selection> from_selectors(data_dictionary::database db, schema_ptr schema, const std::vector<::shared_ptr<raw_selector>>& raw_selectors);
|
||||
|
||||
virtual std::unique_ptr<selectors> new_selectors() const = 0;
|
||||
|
||||
|
||||
@@ -107,7 +107,7 @@ public:
|
||||
*/
|
||||
virtual void reset() = 0;
|
||||
|
||||
virtual assignment_testable::test_result test_assignment(database& db, const sstring& keyspace, const column_specification& receiver) const override {
|
||||
virtual assignment_testable::test_result test_assignment(data_dictionary::database db, const sstring& keyspace, const column_specification& receiver) const override {
|
||||
auto t1 = receiver.type->underlying_type();
|
||||
auto t2 = get_type()->underlying_type();
|
||||
// We want columns of `counter_type' to be served by underlying type's overloads
|
||||
|
||||
@@ -49,7 +49,7 @@ namespace cql3 {
|
||||
namespace selection {
|
||||
|
||||
selector_factories::selector_factories(std::vector<::shared_ptr<selectable>> selectables,
|
||||
database& db, schema_ptr schema,
|
||||
data_dictionary::database db, schema_ptr schema,
|
||||
std::vector<const column_definition*>& defs)
|
||||
: _contains_write_time_factory(false)
|
||||
, _contains_ttl_factory(false)
|
||||
|
||||
@@ -93,13 +93,13 @@ public:
|
||||
*/
|
||||
static ::shared_ptr<selector_factories> create_factories_and_collect_column_definitions(
|
||||
std::vector<::shared_ptr<selectable>> selectables,
|
||||
database& db, schema_ptr schema,
|
||||
data_dictionary::database db, schema_ptr schema,
|
||||
std::vector<const column_definition*>& defs) {
|
||||
return ::make_shared<selector_factories>(std::move(selectables), db, std::move(schema), defs);
|
||||
}
|
||||
|
||||
selector_factories(std::vector<::shared_ptr<selectable>> selectables,
|
||||
database& db, schema_ptr schema, std::vector<const column_definition*>& defs);
|
||||
data_dictionary::database db, schema_ptr schema, std::vector<const column_definition*>& defs);
|
||||
public:
|
||||
/**
|
||||
* Adds a new <code>Selector.Factory</code> for a column that is needed only for ORDER BY or post
|
||||
|
||||
@@ -60,7 +60,7 @@ public:
|
||||
|
||||
virtual sstring to_string() const override;
|
||||
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(database& db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
virtual shared_ptr<selector::factory> new_selector_factory(data_dictionary::database db, schema_ptr s, std::vector<const column_definition*>& defs) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace cql3 {
|
||||
expression
|
||||
single_column_relation::to_expression(const std::vector<lw_shared_ptr<column_specification>>& receivers,
|
||||
const expr::expression& raw,
|
||||
database& db,
|
||||
data_dictionary::database db,
|
||||
const sstring& keyspace,
|
||||
prepare_context& ctx) const {
|
||||
// TODO: optimize vector away, accept single column_specification
|
||||
@@ -68,7 +68,7 @@ single_column_relation::to_expression(const std::vector<lw_shared_ptr<column_spe
|
||||
}
|
||||
|
||||
::shared_ptr<restrictions::restriction>
|
||||
single_column_relation::new_EQ_restriction(database& db, schema_ptr schema, prepare_context& ctx) {
|
||||
single_column_relation::new_EQ_restriction(data_dictionary::database db, schema_ptr schema, prepare_context& ctx) {
|
||||
const column_definition& column_def = to_column_definition(*schema, *_entity);
|
||||
auto reset_processing_pk_column = defer([&ctx] () noexcept { ctx.set_processing_pk_restrictions(false); });
|
||||
if (column_def.is_partition_key()) {
|
||||
@@ -90,7 +90,7 @@ single_column_relation::new_EQ_restriction(database& db, schema_ptr schema, prep
|
||||
}
|
||||
|
||||
::shared_ptr<restrictions::restriction>
|
||||
single_column_relation::new_IN_restriction(database& db, schema_ptr schema, prepare_context& ctx) {
|
||||
single_column_relation::new_IN_restriction(data_dictionary::database db, schema_ptr schema, prepare_context& ctx) {
|
||||
using namespace restrictions;
|
||||
const column_definition& column_def = to_column_definition(*schema, *_entity);
|
||||
auto reset_processing_pk_column = defer([&ctx] () noexcept { ctx.set_processing_pk_restrictions(false); });
|
||||
@@ -127,7 +127,7 @@ single_column_relation::new_IN_restriction(database& db, schema_ptr schema, prep
|
||||
|
||||
::shared_ptr<restrictions::restriction>
|
||||
single_column_relation::new_LIKE_restriction(
|
||||
database& db, schema_ptr schema, prepare_context& ctx) {
|
||||
data_dictionary::database db, schema_ptr schema, prepare_context& ctx) {
|
||||
const column_definition& column_def = to_column_definition(*schema, *_entity);
|
||||
if (!column_def.type->is_string()) {
|
||||
throw exceptions::invalid_request_exception(
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
|
||||
protected:
|
||||
virtual expr::expression to_expression(const std::vector<lw_shared_ptr<column_specification>>& receivers,
|
||||
const expr::expression& raw, database& db, const sstring& keyspace,
|
||||
const expr::expression& raw, data_dictionary::database db, const sstring& keyspace,
|
||||
prepare_context& ctx) const override;
|
||||
|
||||
#if 0
|
||||
@@ -144,13 +144,13 @@ protected:
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual ::shared_ptr<restrictions::restriction> new_EQ_restriction(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<restrictions::restriction> new_EQ_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx) override;
|
||||
|
||||
virtual ::shared_ptr<restrictions::restriction> new_IN_restriction(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<restrictions::restriction> new_IN_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx) override;
|
||||
|
||||
virtual ::shared_ptr<restrictions::restriction> new_slice_restriction(database& db, schema_ptr schema,
|
||||
virtual ::shared_ptr<restrictions::restriction> new_slice_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx,
|
||||
statements::bound bound,
|
||||
bool inclusive) override {
|
||||
@@ -174,7 +174,7 @@ protected:
|
||||
return r;
|
||||
}
|
||||
|
||||
virtual shared_ptr<restrictions::restriction> new_contains_restriction(database& db, schema_ptr schema,
|
||||
virtual shared_ptr<restrictions::restriction> new_contains_restriction(data_dictionary::database db, schema_ptr schema,
|
||||
prepare_context& ctx,
|
||||
bool is_key) override {
|
||||
auto&& column_def = to_column_definition(*schema, *_entity);
|
||||
@@ -186,7 +186,7 @@ protected:
|
||||
}
|
||||
|
||||
virtual ::shared_ptr<restrictions::restriction> new_LIKE_restriction(
|
||||
database& db, schema_ptr schema, prepare_context& ctx) override;
|
||||
data_dictionary::database db, schema_ptr schema, prepare_context& ctx) override;
|
||||
|
||||
virtual ::shared_ptr<relation> maybe_rename_identifier(const column_identifier::raw& from, column_identifier::raw to) override {
|
||||
return *_entity == from
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "db/system_keyspace.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "data_dictionary/keyspace_metadata.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
#include "cql3/statements/ks_prop_defs.hh"
|
||||
#include "create_keyspace_statement.hh"
|
||||
@@ -93,7 +94,7 @@ future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<
|
||||
cql3::statements::alter_keyspace_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
try {
|
||||
service::storage_proxy& proxy = qp.proxy();
|
||||
auto old_ksm = proxy.get_db().local().find_keyspace(_name).metadata();
|
||||
auto old_ksm = proxy.data_dictionary().find_keyspace(_name).metadata();
|
||||
const auto& tm = *proxy.get_token_metadata_ptr();
|
||||
|
||||
auto m = qp.get_migration_manager().prepare_keyspace_update_announcement(_attrs->as_ks_metadata_update(old_ksm, tm));
|
||||
@@ -105,13 +106,13 @@ cql3::statements::alter_keyspace_statement::prepare_schema_mutations(query_proce
|
||||
keyspace());
|
||||
|
||||
return make_ready_future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>>(std::make_pair(std::move(ret), std::move(m)));
|
||||
} catch (no_such_keyspace& e) {
|
||||
} catch (data_dictionary::no_such_keyspace& e) {
|
||||
return make_exception_future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>>(exceptions::invalid_request_exception("Unknown keyspace " + _name));
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::alter_keyspace_statement::prepare(database& db, cql_stats& stats) {
|
||||
cql3::statements::alter_keyspace_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<alter_keyspace_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
future<> check_access(service::storage_proxy& proxy, const service::client_state& state) const override;
|
||||
void validate(service::storage_proxy& proxy, const service::client_state& state) const override;
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
virtual future<::shared_ptr<messages::result_message>> execute(query_processor& qp, service::query_state& state, const query_options& options) const override;
|
||||
};
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
, _options(std::move(options)) {
|
||||
}
|
||||
|
||||
std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
void validate(service::storage_proxy&, const service::client_state&) const override;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ alter_service_level_statement::alter_service_level_statement(sstring service_lev
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::alter_service_level_statement::prepare(
|
||||
database &db, cql_stats &stats) {
|
||||
data_dictionary::database db, cql_stats &stats) {
|
||||
return std::make_unique<prepared_statement>(::make_shared<alter_service_level_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ class alter_service_level_statement final : public service_level_statement {
|
||||
|
||||
public:
|
||||
alter_service_level_statement(sstring service_level, shared_ptr<sl_prop_defs> attrs);
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(database &db, cql_stats &stats) override;
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(data_dictionary::database db, cql_stats &stats) override;
|
||||
void validate(service::storage_proxy&, const service::client_state&) const override;
|
||||
virtual future<> check_access(service::storage_proxy& sp, const service::client_state&) const override;
|
||||
virtual future<::shared_ptr<cql_transport::messages::result_message>>
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include "cql3/util.hh"
|
||||
#include "view_info.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "db/view/view.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
#include "cdc/cdc_extension.hh"
|
||||
@@ -144,7 +144,7 @@ static data_type validate_alter(const schema& schema, const column_definition& d
|
||||
return type;
|
||||
}
|
||||
|
||||
static void validate_column_rename(database& db, const schema& schema, const column_identifier& from, const column_identifier& to)
|
||||
static void validate_column_rename(data_dictionary::database db, const schema& schema, const column_identifier& from, const column_identifier& to)
|
||||
{
|
||||
auto def = schema.get_column_definition(from.name());
|
||||
if (!def) {
|
||||
@@ -171,7 +171,7 @@ static void validate_column_rename(database& db, const schema& schema, const col
|
||||
}
|
||||
}
|
||||
|
||||
void alter_table_statement::add_column(const schema& schema, const table& cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const {
|
||||
void alter_table_statement::add_column(const schema& schema, data_dictionary::table cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const {
|
||||
if (is_static) {
|
||||
if (!schema.is_compound()) {
|
||||
throw exceptions::invalid_request_exception("Static columns are not allowed in COMPACT STORAGE tables");
|
||||
@@ -241,7 +241,7 @@ void alter_table_statement::add_column(const schema& schema, const table& cf, sc
|
||||
}
|
||||
}
|
||||
|
||||
void alter_table_statement::alter_column(const schema& schema, const table& cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const {
|
||||
void alter_table_statement::alter_column(const schema& schema, data_dictionary::table cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const {
|
||||
if (!def) {
|
||||
throw exceptions::invalid_request_exception(format("Column {} was not found in table {}", column_name, column_family()));
|
||||
}
|
||||
@@ -263,7 +263,7 @@ void alter_table_statement::alter_column(const schema& schema, const table& cf,
|
||||
}
|
||||
}
|
||||
|
||||
void alter_table_statement::drop_column(const schema& schema, const table& cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const {
|
||||
void alter_table_statement::drop_column(const schema& schema, data_dictionary::table cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const {
|
||||
if (!def) {
|
||||
throw exceptions::invalid_request_exception(format("Column {} was not found in table {}", column_name, column_family()));
|
||||
}
|
||||
@@ -294,8 +294,8 @@ void alter_table_statement::drop_column(const schema& schema, const table& cf, s
|
||||
}
|
||||
}
|
||||
|
||||
std::pair<schema_builder, std::vector<view_ptr>> alter_table_statement::prepare_schema_update(database& db) const {
|
||||
auto s = validation::validate_column_family(db, keyspace(), column_family());
|
||||
std::pair<schema_builder, std::vector<view_ptr>> alter_table_statement::prepare_schema_update(data_dictionary::database db) const {
|
||||
auto s = validation::validate_column_family(db.real_database(), keyspace(), column_family());
|
||||
if (s->is_view()) {
|
||||
throw exceptions::invalid_request_exception("Cannot use ALTER TABLE on Materialized View");
|
||||
}
|
||||
@@ -306,10 +306,10 @@ std::pair<schema_builder, std::vector<view_ptr>> alter_table_statement::prepare_
|
||||
throw exceptions::configuration_exception("Cannot alter table id.");
|
||||
}
|
||||
|
||||
auto& cf = db.find_column_family(s);
|
||||
auto cf = db.find_column_family(s);
|
||||
std::vector<view_ptr> view_updates;
|
||||
|
||||
using column_change_fn = std::function<void (const alter_table_statement*, const schema&, const table&, schema_builder&, std::vector<view_ptr>&, const column_identifier&, const data_type, const column_definition*, bool)>;
|
||||
using column_change_fn = std::function<void (const alter_table_statement*, const schema&, data_dictionary::table, schema_builder&, std::vector<view_ptr>&, const column_identifier&, const data_type, const column_definition*, bool)>;
|
||||
|
||||
auto invoke_column_change_fn = [&] (column_change_fn fn) {
|
||||
for (auto& [raw_name, raw_validator, is_static] : _column_changes) {
|
||||
@@ -414,7 +414,7 @@ std::pair<schema_builder, std::vector<view_ptr>> alter_table_statement::prepare_
|
||||
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>>
|
||||
alter_table_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
database& db = qp.db();
|
||||
data_dictionary::database db = qp.db();
|
||||
auto& mm = qp.get_migration_manager();
|
||||
auto [cfm, view_updates] = prepare_schema_update(db);
|
||||
auto m = co_await mm.prepare_column_family_update_announcement(cfm.build(), false, std::move(view_updates), std::nullopt);
|
||||
@@ -430,7 +430,7 @@ alter_table_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::alter_table_statement::prepare(database& db, cql_stats& stats) {
|
||||
cql3::statements::alter_table_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<alter_table_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "cql3/statements/cf_prop_defs.hh"
|
||||
#include "cql3/cql3_type.hh"
|
||||
#include "cql3/column_identifier.hh"
|
||||
#include "database_fwd.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
@@ -83,15 +83,15 @@ public:
|
||||
|
||||
virtual future<> check_access(service::storage_proxy& proxy, const service::client_state& state) const override;
|
||||
virtual void validate(service::storage_proxy& proxy, const service::client_state& state) const override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
virtual future<::shared_ptr<messages::result_message>> execute(query_processor& qp, service::query_state& state, const query_options& options) const override;
|
||||
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
private:
|
||||
void add_column(const schema& schema, const table& cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const;
|
||||
void alter_column(const schema& schema, const table& cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const;
|
||||
void drop_column(const schema& schema, const table& cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const;
|
||||
std::pair<schema_builder, std::vector<view_ptr>> prepare_schema_update(database& db) const;
|
||||
void add_column(const schema& schema, data_dictionary::table cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const;
|
||||
void alter_column(const schema& schema, data_dictionary::table cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const;
|
||||
void drop_column(const schema& schema, data_dictionary::table cf, schema_builder& cfm, std::vector<view_ptr>& view_updates, const column_identifier& column_name, const cql3_type validator, const column_definition* def, bool is_static) const;
|
||||
std::pair<schema_builder, std::vector<view_ptr>> prepare_schema_update(data_dictionary::database db) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -44,9 +44,11 @@
|
||||
#include "cql3/column_identifier.hh"
|
||||
#include "prepared_statement.hh"
|
||||
#include "schema_builder.hh"
|
||||
#include "mutation.hh"
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "data_dictionary/keyspace_metadata.hh"
|
||||
#include "boost/range/adaptor/map.hpp"
|
||||
#include "data_dictionary/user_types_metadata.hh"
|
||||
|
||||
@@ -82,7 +84,7 @@ const sstring& alter_type_statement::keyspace() const
|
||||
return _name.get_keyspace();
|
||||
}
|
||||
|
||||
future<std::vector<mutation>> alter_type_statement::prepare_announcement_mutations(database& db, service::migration_manager& mm) const {
|
||||
future<std::vector<mutation>> alter_type_statement::prepare_announcement_mutations(data_dictionary::database db, service::migration_manager& mm) const {
|
||||
std::vector<mutation> m;
|
||||
auto&& ks = db.find_keyspace(keyspace());
|
||||
auto&& all_types = ks.metadata()->user_types().get_all_types();
|
||||
@@ -145,7 +147,7 @@ alter_type_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
_name.get_string_type_name());
|
||||
|
||||
co_return std::make_pair(std::move(ret), std::move(m));
|
||||
} catch(no_such_keyspace& e) {
|
||||
} catch(data_dictionary::no_such_keyspace& e) {
|
||||
co_return coroutine::make_exception(exceptions::invalid_request_exception(format("Cannot alter type in unknown keyspace {}", keyspace())));
|
||||
}
|
||||
}
|
||||
@@ -158,7 +160,7 @@ alter_type_statement::add_or_alter::add_or_alter(const ut_name& name, bool is_ad
|
||||
{
|
||||
}
|
||||
|
||||
user_type alter_type_statement::add_or_alter::do_add(database& db, user_type to_update) const
|
||||
user_type alter_type_statement::add_or_alter::do_add(data_dictionary::database db, user_type to_update) const
|
||||
{
|
||||
if (to_update->idx_of_field(_field_name->name())) {
|
||||
throw exceptions::invalid_request_exception(format("Cannot add new field {} to type {}: a field of the same name already exists",
|
||||
@@ -181,7 +183,7 @@ user_type alter_type_statement::add_or_alter::do_add(database& db, user_type to_
|
||||
return user_type_impl::get_instance(to_update->_keyspace, to_update->_name, std::move(new_names), std::move(new_types), to_update->is_multi_cell());
|
||||
}
|
||||
|
||||
user_type alter_type_statement::add_or_alter::do_alter(database& db, user_type to_update) const
|
||||
user_type alter_type_statement::add_or_alter::do_alter(data_dictionary::database db, user_type to_update) const
|
||||
{
|
||||
auto idx = to_update->idx_of_field(_field_name->name());
|
||||
if (!idx) {
|
||||
@@ -200,7 +202,7 @@ user_type alter_type_statement::add_or_alter::do_alter(database& db, user_type t
|
||||
return user_type_impl::get_instance(to_update->_keyspace, to_update->_name, to_update->field_names(), std::move(new_types), to_update->is_multi_cell());
|
||||
}
|
||||
|
||||
user_type alter_type_statement::add_or_alter::make_updated_type(database& db, user_type to_update) const
|
||||
user_type alter_type_statement::add_or_alter::make_updated_type(data_dictionary::database db, user_type to_update) const
|
||||
{
|
||||
return _is_add ? do_add(db, to_update) : do_alter(db, to_update);
|
||||
}
|
||||
@@ -215,7 +217,7 @@ void alter_type_statement::renames::add_rename(shared_ptr<column_identifier> pre
|
||||
_renames.emplace_back(previous_name, new_name);
|
||||
}
|
||||
|
||||
user_type alter_type_statement::renames::make_updated_type(database& db, user_type to_update) const
|
||||
user_type alter_type_statement::renames::make_updated_type(data_dictionary::database db, user_type to_update) const
|
||||
{
|
||||
std::vector<bytes> new_names(to_update->field_names());
|
||||
for (auto&& rename : _renames) {
|
||||
@@ -232,12 +234,12 @@ user_type alter_type_statement::renames::make_updated_type(database& db, user_ty
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
alter_type_statement::add_or_alter::prepare(database& db, cql_stats& stats) {
|
||||
alter_type_statement::add_or_alter::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<alter_type_statement::add_or_alter>(*this));
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
alter_type_statement::renames::prepare(database& db, cql_stats& stats) {
|
||||
alter_type_statement::renames::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<alter_type_statement::renames>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@
|
||||
#include "cql3/statements/schema_altering_statement.hh"
|
||||
#include "cql3/cql3_type.hh"
|
||||
#include "cql3/ut_name.hh"
|
||||
#include "database_fwd.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "schema.hh"
|
||||
|
||||
namespace service {
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
class add_or_alter;
|
||||
class renames;
|
||||
protected:
|
||||
virtual user_type make_updated_type(database& db, user_type to_update) const = 0;
|
||||
virtual user_type make_updated_type(data_dictionary::database db, user_type to_update) const = 0;
|
||||
private:
|
||||
struct base_visitor {
|
||||
virtual future<> operator()(view_ptr view) = 0;
|
||||
@@ -85,7 +85,7 @@ private:
|
||||
virtual future<> operator()(schema_ptr cfm, bool from_thrift, std::vector<view_ptr>&& view_updates, std::optional<api::timestamp_type> ts_opt) = 0;
|
||||
};
|
||||
|
||||
future<std::vector<mutation>> prepare_announcement_mutations(database& db, service::migration_manager& mm) const;
|
||||
future<std::vector<mutation>> prepare_announcement_mutations(data_dictionary::database db, service::migration_manager& mm) const;
|
||||
};
|
||||
|
||||
class alter_type_statement::add_or_alter : public alter_type_statement {
|
||||
@@ -96,11 +96,11 @@ public:
|
||||
add_or_alter(const ut_name& name, bool is_add,
|
||||
const shared_ptr<column_identifier> field_name,
|
||||
const shared_ptr<cql3_type::raw> field_type);
|
||||
virtual user_type make_updated_type(database& db, user_type to_update) const override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual user_type make_updated_type(data_dictionary::database db, user_type to_update) const override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
private:
|
||||
user_type do_add(database& db, user_type to_update) const;
|
||||
user_type do_alter(database& db, user_type to_update) const;
|
||||
user_type do_add(data_dictionary::database db, user_type to_update) const;
|
||||
user_type do_alter(data_dictionary::database db, user_type to_update) const;
|
||||
};
|
||||
|
||||
|
||||
@@ -113,8 +113,8 @@ public:
|
||||
|
||||
void add_rename(shared_ptr<column_identifier> previous_name, shared_ptr<column_identifier> new_name);
|
||||
|
||||
virtual user_type make_updated_type(database& db, user_type to_update) const override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual user_type make_updated_type(data_dictionary::database db, user_type to_update) const override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@
|
||||
#include "validation.hh"
|
||||
#include "view_info.hh"
|
||||
#include "db/extensions.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
|
||||
namespace cql3 {
|
||||
@@ -63,12 +63,12 @@ alter_view_statement::alter_view_statement(cf_name view_name, std::optional<cf_p
|
||||
future<> alter_view_statement::check_access(service::storage_proxy& proxy, const service::client_state& state) const
|
||||
{
|
||||
try {
|
||||
const database& db = proxy.local_db();
|
||||
const data_dictionary::database db = proxy.data_dictionary();
|
||||
auto&& s = db.find_schema(keyspace(), column_family());
|
||||
if (s->is_view()) {
|
||||
return state.has_column_family_access(db, keyspace(), s->view_info()->base_name(), auth::permission::ALTER);
|
||||
return state.has_column_family_access(db.real_database(), keyspace(), s->view_info()->base_name(), auth::permission::ALTER);
|
||||
}
|
||||
} catch (const no_such_column_family& e) {
|
||||
} catch (const data_dictionary::no_such_column_family& e) {
|
||||
// Will be validated afterwards.
|
||||
}
|
||||
return make_ready_future<>();
|
||||
@@ -79,8 +79,8 @@ void alter_view_statement::validate(service::storage_proxy&, const service::clie
|
||||
// validated in prepare_schema_mutations()
|
||||
}
|
||||
|
||||
view_ptr alter_view_statement::prepare_view(database& db) const {
|
||||
schema_ptr schema = validation::validate_column_family(db, keyspace(), column_family());
|
||||
view_ptr alter_view_statement::prepare_view(data_dictionary::database db) const {
|
||||
schema_ptr schema = validation::validate_column_family(db.real_database(), keyspace(), column_family());
|
||||
if (!schema->is_view()) {
|
||||
throw exceptions::invalid_request_exception("Cannot use ALTER MATERIALIZED VIEW on Table");
|
||||
}
|
||||
@@ -126,7 +126,7 @@ future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
alter_view_statement::prepare(database& db, cql_stats& stats) {
|
||||
alter_view_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<alter_view_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,7 @@
|
||||
|
||||
#include <seastar/core/shared_ptr.hh>
|
||||
|
||||
#include "database_fwd.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "cql3/statements/cf_prop_defs.hh"
|
||||
#include "cql3/statements/schema_altering_statement.hh"
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace statements {
|
||||
class alter_view_statement : public schema_altering_statement {
|
||||
private:
|
||||
std::optional<cf_prop_defs> _properties;
|
||||
view_ptr prepare_view(database& db) const;
|
||||
view_ptr prepare_view(data_dictionary::database db) const;
|
||||
public:
|
||||
alter_view_statement(cf_name view_name, std::optional<cf_prop_defs> properties);
|
||||
|
||||
@@ -69,7 +69,7 @@ public:
|
||||
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ attach_service_level_statement::attach_service_level_statement(sstring service_l
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::attach_service_level_statement::prepare(
|
||||
database &db, cql_stats &stats) {
|
||||
data_dictionary::database db, cql_stats &stats) {
|
||||
return std::make_unique<prepared_statement>(::make_shared<attach_service_level_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class attach_service_level_statement final : public service_level_statement {
|
||||
|
||||
public:
|
||||
attach_service_level_statement(sstring service_level, sstring role_name);
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(database &db, cql_stats &stats) override;
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(data_dictionary::database db, cql_stats &stats) override;
|
||||
void validate(service::storage_proxy&, const service::client_state&) const override;
|
||||
virtual future<> check_access(service::storage_proxy& sp, const service::client_state&) const override;
|
||||
virtual future<::shared_ptr<cql_transport::messages::result_message>>
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "raw/batch_statement.hh"
|
||||
#include "db/config.hh"
|
||||
#include "db/consistency_level_validations.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include <seastar/core/execution_stage.hh>
|
||||
#include "cas_request.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
@@ -230,8 +230,8 @@ void batch_statement::verify_batch_size(service::storage_proxy& proxy, const std
|
||||
return; // We only warn for batch spanning multiple mutations
|
||||
}
|
||||
|
||||
size_t warn_threshold = proxy.get_db().local().get_config().batch_size_warn_threshold_in_kb() * 1024;
|
||||
size_t fail_threshold = proxy.get_db().local().get_config().batch_size_fail_threshold_in_kb() * 1024;
|
||||
size_t warn_threshold = proxy.data_dictionary().get_config().batch_size_warn_threshold_in_kb() * 1024;
|
||||
size_t fail_threshold = proxy.data_dictionary().get_config().batch_size_fail_threshold_in_kb() * 1024;
|
||||
|
||||
size_t size = 0;
|
||||
for (auto&m : mutations) {
|
||||
@@ -436,7 +436,7 @@ void batch_statement::build_cas_result_set_metadata() {
|
||||
namespace raw {
|
||||
|
||||
std::unique_ptr<prepared_statement>
|
||||
batch_statement::prepare(database& db, cql_stats& stats) {
|
||||
batch_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
auto&& meta = get_prepare_context();
|
||||
|
||||
std::optional<sstring> first_ks;
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
*/
|
||||
|
||||
#include "cql3/statements/cf_prop_defs.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "db/extensions.hh"
|
||||
#include "cdc/log.hh"
|
||||
#include "cdc/cdc_extension.hh"
|
||||
@@ -94,7 +94,7 @@ schema::extensions_map cf_prop_defs::make_schema_extensions(const db::extensions
|
||||
return er;
|
||||
}
|
||||
|
||||
void cf_prop_defs::validate(const database& db, const schema::extensions_map& schema_extensions) const {
|
||||
void cf_prop_defs::validate(const data_dictionary::database db, const schema::extensions_map& schema_extensions) const {
|
||||
// Skip validation if the comapction strategy class is already set as it means we've alreayd
|
||||
// prepared (and redoing it would set strategyClass back to null, which we don't want)
|
||||
if (_compaction_strategy_class) {
|
||||
|
||||
@@ -47,6 +47,10 @@
|
||||
#include "compaction/compaction_strategy.hh"
|
||||
#include "utils/UUID.hh"
|
||||
|
||||
namespace data_dictionary {
|
||||
class database;
|
||||
}
|
||||
|
||||
namespace db {
|
||||
class extensions;
|
||||
}
|
||||
@@ -97,7 +101,7 @@ public:
|
||||
std::optional<sstables::compaction_strategy_type> get_compaction_strategy_class() const;
|
||||
|
||||
schema::extensions_map make_schema_extensions(const db::extensions& exts) const;
|
||||
void validate(const database& db, const schema::extensions_map& schema_extensions) const;
|
||||
void validate(const data_dictionary::database db, const schema::extensions_map& schema_extensions) const;
|
||||
std::map<sstring, sstring> get_compaction_type_options() const;
|
||||
std::optional<std::map<sstring, sstring>> get_compression_options() const;
|
||||
const cdc::options* get_cdc_options(const schema::extensions_map&) const;
|
||||
|
||||
@@ -94,7 +94,7 @@ public:
|
||||
_defined_ordering.emplace_back(alias, reversed);
|
||||
}
|
||||
|
||||
void validate(const database& db, const schema::extensions_map& schema_extensions) const {
|
||||
void validate(const data_dictionary::database db, const schema::extensions_map& schema_extensions) const {
|
||||
_properties->validate(db, schema_extensions);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -26,7 +26,8 @@
|
||||
#include "prepared_statement.hh"
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "mutation.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
#include "gms/feature_service.hh"
|
||||
|
||||
@@ -43,7 +44,7 @@ shared_ptr<functions::function> create_aggregate_statement::create(service::stor
|
||||
}
|
||||
data_type state_type = prepare_type(proxy, *_stype);
|
||||
|
||||
auto&& db = proxy.get_db().local();
|
||||
auto&& db = proxy.data_dictionary();
|
||||
std::vector<data_type> acc_types{state_type};
|
||||
acc_types.insert(acc_types.end(), _arg_types.begin(), _arg_types.end());
|
||||
auto state_func = dynamic_pointer_cast<functions::scalar_function>(functions::functions::find(functions::function_name{_name.keyspace, _sfunc}, acc_types));
|
||||
@@ -64,7 +65,7 @@ shared_ptr<functions::function> create_aggregate_statement::create(service::stor
|
||||
return ::make_shared<functions::user_aggregate>(_name, initcond, std::move(state_func), std::move(final_func));
|
||||
}
|
||||
|
||||
std::unique_ptr<prepared_statement> create_aggregate_statement::prepare(database& db, cql_stats& stats) {
|
||||
std::unique_ptr<prepared_statement> create_aggregate_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<create_aggregate_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace functions {
|
||||
namespace statements {
|
||||
|
||||
class create_aggregate_statement final : public create_function_statement_base {
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
virtual shared_ptr<functions::function> create(service::storage_proxy& proxy, functions::function* old) const override;
|
||||
|
||||
@@ -27,7 +27,8 @@
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "lang/lua.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "database.hh" // for wasm
|
||||
#include "cql3/query_processor.hh"
|
||||
|
||||
namespace cql3 {
|
||||
@@ -47,7 +48,7 @@ shared_ptr<functions::function> create_function_statement::create(service::stora
|
||||
arg_names.push_back(arg_name->to_string());
|
||||
}
|
||||
|
||||
auto&& db = proxy.get_db().local();
|
||||
auto&& db = proxy.data_dictionary();
|
||||
if (_language == "lua") {
|
||||
auto cfg = lua::make_runtime_config(db.get_config());
|
||||
functions::user_function::context ctx = functions::user_function::lua_context {
|
||||
@@ -58,7 +59,8 @@ shared_ptr<functions::function> create_function_statement::create(service::stora
|
||||
return ::make_shared<functions::user_function>(_name, _arg_types, std::move(arg_names), _body, _language,
|
||||
std::move(return_type), _called_on_null_input, std::move(ctx));
|
||||
} else if (_language == "xwasm") {
|
||||
wasm::context ctx{db.wasm_engine(), _name.name};
|
||||
// FIXME: need better way to test wasm compilation without real_database()
|
||||
wasm::context ctx{db.real_database().wasm_engine(), _name.name};
|
||||
try {
|
||||
wasm::compile(ctx, arg_names, _body);
|
||||
return ::make_shared<functions::user_function>(_name, _arg_types, std::move(arg_names), _body, _language,
|
||||
@@ -70,7 +72,7 @@ shared_ptr<functions::function> create_function_statement::create(service::stora
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
std::unique_ptr<prepared_statement> create_function_statement::prepare(database& db, cql_stats& stats) {
|
||||
std::unique_ptr<prepared_statement> create_function_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<create_function_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace functions {
|
||||
namespace statements {
|
||||
|
||||
class create_function_statement final : public create_function_statement_base {
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
virtual shared_ptr<functions::function> create(service::storage_proxy& proxy, functions::function* old) const override;
|
||||
|
||||
@@ -48,12 +48,14 @@
|
||||
#include "schema.hh"
|
||||
#include "schema_builder.hh"
|
||||
#include "request_validations.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "index/target_parser.hh"
|
||||
#include "gms/feature_service.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
#include "cql3/index_name.hh"
|
||||
#include "cql3/statements/index_prop_defs.hh"
|
||||
#include "index/secondary_index_manager.hh"
|
||||
#include "mutation.hh"
|
||||
|
||||
#include <boost/range/adaptor/transformed.hpp>
|
||||
#include <boost/algorithm/string/join.hpp>
|
||||
@@ -91,8 +93,8 @@ create_index_statement::validate(service::storage_proxy& proxy, const service::c
|
||||
}
|
||||
|
||||
std::vector<::shared_ptr<index_target>> create_index_statement::validate_while_executing(service::storage_proxy& proxy) const {
|
||||
auto& db = proxy.get_db().local();
|
||||
auto schema = validation::validate_column_family(db, keyspace(), column_family());
|
||||
auto db = proxy.data_dictionary();
|
||||
auto schema = validation::validate_column_family(db.real_database(), keyspace(), column_family());
|
||||
|
||||
if (schema->is_counter()) {
|
||||
throw exceptions::invalid_request_exception("Secondary indexes are not supported on counter tables");
|
||||
@@ -279,7 +281,7 @@ void create_index_statement::validate_targets_for_multi_column_index(std::vector
|
||||
schema_ptr create_index_statement::build_index_schema(query_processor& qp) const {
|
||||
auto targets = validate_while_executing(qp.proxy());
|
||||
|
||||
database& db = qp.db();
|
||||
data_dictionary::database db = qp.db();
|
||||
auto schema = db.find_schema(keyspace(), column_family());
|
||||
|
||||
sstring accepted_name = _index_name;
|
||||
@@ -346,7 +348,7 @@ create_index_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
create_index_statement::prepare(database& db, cql_stats& stats) {
|
||||
create_index_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
_cql_stats = &stats;
|
||||
return std::make_unique<prepared_statement>(make_shared<create_index_statement>(*this));
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public:
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
private:
|
||||
void validate_for_local_index(const schema& schema) const;
|
||||
void validate_for_frozen_collection(const index_target& target) const;
|
||||
|
||||
@@ -43,7 +43,9 @@
|
||||
#include "cql3/statements/create_keyspace_statement.hh"
|
||||
#include "cql3/statements/ks_prop_defs.hh"
|
||||
#include "prepared_statement.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "data_dictionary/keyspace_metadata.hh"
|
||||
#include "mutation.hh"
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "transport/messages/result_message.hh"
|
||||
@@ -135,7 +137,7 @@ future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::create_keyspace_statement::prepare(database& db, cql_stats& stats) {
|
||||
cql3::statements::create_keyspace_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<create_keyspace_statement>(*this));
|
||||
}
|
||||
|
||||
@@ -172,7 +174,7 @@ std::optional<sstring> check_restricted_replication_strategy(
|
||||
// may have in the future - multiple racks or DCs. So depending on how
|
||||
// protective we are configured, let's prevent it or allow with a warning:
|
||||
if (replication_strategy == "org.apache.cassandra.locator.SimpleStrategy") {
|
||||
switch(proxy.local_db().get_config().restrict_replication_simplestrategy()) {
|
||||
switch(proxy.data_dictionary().get_config().restrict_replication_simplestrategy()) {
|
||||
case db::tri_mode_restriction_t::mode::TRUE:
|
||||
throw exceptions::configuration_exception(
|
||||
"SimpleStrategy replication class is not recommended, and "
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
virtual future<> grant_permissions_to_creator(const service::client_state&) const override;
|
||||
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
, _if_not_exists(if_not_exists) {
|
||||
}
|
||||
|
||||
std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
future<> grant_permissions_to_creator(const service::client_state&) const;
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ create_service_level_statement::create_service_level_statement(sstring service_l
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::create_service_level_statement::prepare(
|
||||
database &db, cql_stats &stats) {
|
||||
data_dictionary::database db, cql_stats &stats) {
|
||||
return std::make_unique<prepared_statement>(::make_shared<create_service_level_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ class create_service_level_statement final : public service_level_statement {
|
||||
|
||||
public:
|
||||
create_service_level_statement(sstring service_level, shared_ptr<sl_prop_defs> attrs, bool if_not_exists);
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(database &db, cql_stats &stats) override;
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(data_dictionary::database db, cql_stats &stats) override;
|
||||
void validate(service::storage_proxy&, const service::client_state&) const override;
|
||||
virtual future<> check_access(service::storage_proxy& sp, const service::client_state&) const override;
|
||||
virtual future<::shared_ptr<cql_transport::messages::result_message>>
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
#include "auth/service.hh"
|
||||
#include "schema_builder.hh"
|
||||
#include "db/extensions.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "types/user.hh"
|
||||
#include "gms/feature_service.hh"
|
||||
#include "service/migration_manager.hh"
|
||||
@@ -134,13 +134,13 @@ create_table_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
* @return a CFMetaData instance corresponding to the values parsed from this statement
|
||||
* @throws InvalidRequestException on failure to validate parsed parameters
|
||||
*/
|
||||
schema_ptr create_table_statement::get_cf_meta_data(const database& db) const {
|
||||
schema_ptr create_table_statement::get_cf_meta_data(const data_dictionary::database db) const {
|
||||
schema_builder builder{keyspace(), column_family(), _id};
|
||||
apply_properties_to(builder, db);
|
||||
return builder.build(_use_compact_storage ? schema_builder::compact_storage::yes : schema_builder::compact_storage::no);
|
||||
}
|
||||
|
||||
void create_table_statement::apply_properties_to(schema_builder& builder, const database& db) const {
|
||||
void create_table_statement::apply_properties_to(schema_builder& builder, const data_dictionary::database db) const {
|
||||
auto&& columns = get_columns();
|
||||
for (auto&& column : columns) {
|
||||
builder.with_column_ordered(column);
|
||||
@@ -170,7 +170,7 @@ void create_table_statement::add_column_metadata_from_aliases(schema_builder& bu
|
||||
}
|
||||
|
||||
std::unique_ptr<prepared_statement>
|
||||
create_table_statement::prepare(database& db, cql_stats& stats) {
|
||||
create_table_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
// Cannot happen; create_table_statement is never instantiated as a raw statement
|
||||
// (instead we instantiate create_table_statement::raw_statement)
|
||||
abort();
|
||||
@@ -192,7 +192,7 @@ create_table_statement::raw_statement::raw_statement(cf_name name, bool if_not_e
|
||||
, _if_not_exists{if_not_exists}
|
||||
{ }
|
||||
|
||||
std::unique_ptr<prepared_statement> create_table_statement::raw_statement::prepare(database& db, cql_stats& stats) {
|
||||
std::unique_ptr<prepared_statement> create_table_statement::raw_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
// Column family name
|
||||
const sstring& cf_name = _cf_name->get_column_family();
|
||||
std::regex name_regex("\\w+");
|
||||
@@ -463,7 +463,7 @@ std::optional<sstring> check_restricted_table_properties(
|
||||
// in prepare_schema_mutations(), in the middle of execute).
|
||||
auto strategy = cfprops.get_compaction_strategy_class();
|
||||
if (strategy && *strategy == sstables::compaction_strategy_type::date_tiered) {
|
||||
switch(proxy.local_db().get_config().restrict_dtcs()) {
|
||||
switch(proxy.data_dictionary().get_config().restrict_dtcs()) {
|
||||
case db::tri_mode_restriction_t::mode::TRUE:
|
||||
throw exceptions::configuration_exception(
|
||||
"DateTieredCompactionStrategy is deprecated, and "
|
||||
|
||||
@@ -106,14 +106,14 @@ public:
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
virtual future<> grant_permissions_to_creator(const service::client_state&) const override;
|
||||
|
||||
virtual future<::shared_ptr<messages::result_message>>
|
||||
execute(query_processor& qp, service::query_state& state, const query_options& options) const override;
|
||||
|
||||
schema_ptr get_cf_meta_data(const database&) const;
|
||||
schema_ptr get_cf_meta_data(const data_dictionary::database) const;
|
||||
|
||||
class raw_statement;
|
||||
|
||||
@@ -121,7 +121,7 @@ public:
|
||||
private:
|
||||
std::vector<column_definition> get_columns() const;
|
||||
|
||||
void apply_properties_to(schema_builder& builder, const database&) const;
|
||||
void apply_properties_to(schema_builder& builder, const data_dictionary::database) const;
|
||||
|
||||
void add_column_metadata_from_aliases(schema_builder& builder, std::vector<bytes> aliases, const std::vector<data_type>& types, column_kind kind) const;
|
||||
};
|
||||
@@ -144,7 +144,7 @@ private:
|
||||
public:
|
||||
raw_statement(cf_name name, bool if_not_exists);
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
cf_properties& properties() {
|
||||
return _properties;
|
||||
|
||||
@@ -40,12 +40,14 @@
|
||||
#include <seastar/core/coroutine.hh>
|
||||
#include "cql3/statements/create_type_statement.hh"
|
||||
#include "prepared_statement.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "data_dictionary/keyspace_metadata.hh"
|
||||
#include "data_dictionary/user_types_metadata.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
#include "cql3/column_identifier.hh"
|
||||
#include "mutation.hh"
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
@@ -75,7 +77,7 @@ future<> create_type_statement::check_access(service::storage_proxy& proxy, cons
|
||||
return state.has_keyspace_access(proxy.local_db(), keyspace(), auth::permission::CREATE);
|
||||
}
|
||||
|
||||
inline bool create_type_statement::type_exists_in(::keyspace& ks) const
|
||||
inline bool create_type_statement::type_exists_in(data_dictionary::keyspace ks) const
|
||||
{
|
||||
auto&& keyspace_types = ks.metadata()->user_types().get_all_types();
|
||||
return keyspace_types.contains(_name.get_user_type_name());
|
||||
@@ -115,7 +117,7 @@ const sstring& create_type_statement::keyspace() const
|
||||
return _name.get_keyspace();
|
||||
}
|
||||
|
||||
user_type create_type_statement::create_type(database& db) const
|
||||
user_type create_type_statement::create_type(data_dictionary::database db) const
|
||||
{
|
||||
std::vector<bytes> field_names;
|
||||
std::vector<data_type> field_types;
|
||||
@@ -134,7 +136,7 @@ user_type create_type_statement::create_type(database& db) const
|
||||
}
|
||||
|
||||
std::optional<user_type> create_type_statement::make_type(query_processor& qp) const {
|
||||
database& db = qp.db();
|
||||
data_dictionary::database db = qp.db();
|
||||
auto&& ks = db.find_keyspace(keyspace());
|
||||
|
||||
// Can happen with if_not_exists
|
||||
@@ -166,7 +168,7 @@ future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<
|
||||
co_return coroutine::make_exception(exceptions::invalid_request_exception(format("A user type of name {} already exists", _name.to_string())));
|
||||
}
|
||||
}
|
||||
} catch (no_such_keyspace& e) {
|
||||
} catch (data_dictionary::no_such_keyspace& e) {
|
||||
co_return coroutine::exception(std::current_exception());
|
||||
}
|
||||
|
||||
@@ -174,7 +176,7 @@ future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
create_type_statement::prepare(database& db, cql_stats& stats) {
|
||||
create_type_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<create_type_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include "cql3/statements/schema_altering_statement.hh"
|
||||
#include "cql3/cql3_type.hh"
|
||||
#include "cql3/ut_name.hh"
|
||||
#include "database_fwd.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
@@ -70,16 +70,16 @@ public:
|
||||
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
static void check_for_duplicate_names(user_type type);
|
||||
|
||||
private:
|
||||
bool type_exists_in(::keyspace& ks) const;
|
||||
bool type_exists_in(data_dictionary::keyspace ks) const;
|
||||
std::optional<user_type> make_type(query_processor& qp) const;
|
||||
|
||||
public:
|
||||
user_type create_type(database& db) const;
|
||||
user_type create_type(data_dictionary::database db) const;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "validation.hh"
|
||||
#include "db/extensions.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "gms/feature_service.hh"
|
||||
#include "db/view/view.hh"
|
||||
#include "service/migration_manager.hh"
|
||||
@@ -143,7 +143,7 @@ static bool validate_primary_key(
|
||||
return new_non_pk_column;
|
||||
}
|
||||
|
||||
view_ptr create_view_statement::prepare_view(database& db) const {
|
||||
view_ptr create_view_statement::prepare_view(data_dictionary::database db) const {
|
||||
// We need to make sure that:
|
||||
// - primary key includes all columns in base table's primary key
|
||||
// - make sure that the select statement does not have anything other than columns
|
||||
@@ -177,7 +177,7 @@ view_ptr create_view_statement::prepare_view(database& db) const {
|
||||
_base_name.get_keyspace(), keyspace()));
|
||||
}
|
||||
|
||||
schema_ptr schema = validation::validate_column_family(db, _base_name.get_keyspace(), _base_name.get_column_family());
|
||||
schema_ptr schema = validation::validate_column_family(db.real_database(), _base_name.get_keyspace(), _base_name.get_column_family());
|
||||
|
||||
if (schema->is_counter()) {
|
||||
throw exceptions::invalid_request_exception(format("Materialized views are not supported on counter tables"));
|
||||
@@ -187,7 +187,7 @@ view_ptr create_view_statement::prepare_view(database& db) const {
|
||||
throw exceptions::invalid_request_exception(format("Materialized views cannot be created against other materialized views"));
|
||||
}
|
||||
|
||||
if (cdc::get_base_table(db, *schema)) {
|
||||
if (db.get_cdc_base_table(*schema)) {
|
||||
throw exceptions::invalid_request_exception(format("Materialized views cannot be created on CDC Log tables"));
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ create_view_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
create_view_statement::prepare(database& db, cql_stats& stats) {
|
||||
create_view_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
if (!_prepare_ctx.get_variable_specifications().empty()) {
|
||||
throw exceptions::invalid_request_exception(format("Cannot use query parameters in CREATE MATERIALIZED VIEW statements"));
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ private:
|
||||
cf_properties _properties;
|
||||
bool _if_not_exists;
|
||||
|
||||
view_ptr prepare_view(database& db) const;
|
||||
view_ptr prepare_view(data_dictionary::database db) const;
|
||||
|
||||
public:
|
||||
create_view_statement(
|
||||
@@ -72,7 +72,7 @@ public:
|
||||
virtual void validate(service::storage_proxy&, const service::client_state& state) const override;
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
// FIXME: continue here. See create_table_statement.hh and CreateViewStatement.java
|
||||
};
|
||||
|
||||
@@ -42,10 +42,11 @@
|
||||
#include <boost/algorithm/cxx11/all_of.hpp>
|
||||
#include <boost/range/adaptors.hpp>
|
||||
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "delete_statement.hh"
|
||||
#include "raw/delete_statement.hh"
|
||||
#include "utils/overloaded_functor.hh"
|
||||
#include "mutation.hh"
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
@@ -84,7 +85,7 @@ void delete_statement::add_update_for_key(mutation& m, const query::clustering_r
|
||||
namespace raw {
|
||||
|
||||
::shared_ptr<cql3::statements::modification_statement>
|
||||
delete_statement::prepare_internal(database& db, schema_ptr schema, prepare_context& ctx,
|
||||
delete_statement::prepare_internal(data_dictionary::database db, schema_ptr schema, prepare_context& ctx,
|
||||
std::unique_ptr<attributes> attrs, cql_stats& stats) const {
|
||||
auto stmt = ::make_shared<cql3::statements::delete_statement>(statement_type::DELETE, ctx.bound_variables_size(), schema, std::move(attrs), stats);
|
||||
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "cql3/statements/modification_statement.hh"
|
||||
#include "database_fwd.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ detach_service_level_statement::detach_service_level_statement(sstring role_name
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::detach_service_level_statement::prepare(
|
||||
database &db, cql_stats &stats) {
|
||||
data_dictionary::database db, cql_stats &stats) {
|
||||
return std::make_unique<prepared_statement>(::make_shared<detach_service_level_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ class detach_service_level_statement final : public service_level_statement {
|
||||
sstring _role_name;
|
||||
public:
|
||||
detach_service_level_statement(sstring role_name);
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(database &db, cql_stats &stats) override;
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(data_dictionary::database db, cql_stats &stats) override;
|
||||
void validate(service::storage_proxy&, const service::client_state&) const override;
|
||||
virtual future<> check_access(service::storage_proxy& sp, const service::client_state&) const override;
|
||||
virtual future<::shared_ptr<cql_transport::messages::result_message>>
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace cql3 {
|
||||
|
||||
namespace statements {
|
||||
|
||||
std::unique_ptr<prepared_statement> drop_aggregate_statement::prepare(database& db, cql_stats& stats) {
|
||||
std::unique_ptr<prepared_statement> drop_aggregate_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<drop_aggregate_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace cql3 {
|
||||
class query_processor;
|
||||
namespace statements {
|
||||
class drop_aggregate_statement final : public drop_function_statement_base {
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
public:
|
||||
|
||||
@@ -32,7 +32,7 @@ namespace cql3 {
|
||||
|
||||
namespace statements {
|
||||
|
||||
std::unique_ptr<prepared_statement> drop_function_statement::prepare(database& db, cql_stats& stats) {
|
||||
std::unique_ptr<prepared_statement> drop_function_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<drop_function_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace cql3 {
|
||||
class query_processor;
|
||||
namespace statements {
|
||||
class drop_function_statement final : public drop_function_statement_base {
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
public:
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "schema_builder.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "mutation.hh"
|
||||
#include "gms/feature_service.hh"
|
||||
#include "cql3/query_processor.hh"
|
||||
#include "cql3/index_name.hh"
|
||||
@@ -81,7 +82,7 @@ void drop_index_statement::validate(service::storage_proxy& proxy, const service
|
||||
{
|
||||
// validated in lookup_indexed_table()
|
||||
|
||||
auto& db = proxy.get_db().local();
|
||||
auto db = proxy.data_dictionary();
|
||||
if (db.has_keyspace(keyspace())) {
|
||||
auto schema = db.find_indexed_table(keyspace(), _index_name);
|
||||
if (schema) {
|
||||
@@ -122,14 +123,14 @@ drop_index_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
drop_index_statement::prepare(database& db, cql_stats& stats) {
|
||||
drop_index_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
_cql_stats = &stats;
|
||||
return std::make_unique<prepared_statement>(make_shared<drop_index_statement>(*this));
|
||||
}
|
||||
|
||||
schema_ptr drop_index_statement::lookup_indexed_table(service::storage_proxy& proxy) const
|
||||
{
|
||||
auto& db = proxy.get_db().local();
|
||||
auto& db = proxy.data_dictionary();
|
||||
if (!db.has_keyspace(keyspace())) {
|
||||
throw exceptions::keyspace_not_defined_exception(format("Keyspace {} does not exist", keyspace()));
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public:
|
||||
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
private:
|
||||
schema_ptr lookup_indexed_table(service::storage_proxy& proxy) const;
|
||||
schema_ptr make_drop_idex_schema(query_processor& qp) const;
|
||||
|
||||
@@ -100,7 +100,7 @@ drop_keyspace_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
drop_keyspace_statement::prepare(database& db, cql_stats& stats) {
|
||||
drop_keyspace_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<drop_keyspace_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
drop_role_statement(const cql3::role_name& name, bool if_exists) : _role(name.to_string()), _if_exists(if_exists) {
|
||||
}
|
||||
|
||||
std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
virtual void validate(service::storage_proxy&, const service::client_state&) const override;
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ drop_service_level_statement::drop_service_level_statement(sstring service_level
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::drop_service_level_statement::prepare(
|
||||
database &db, cql_stats &stats) {
|
||||
data_dictionary::database db, cql_stats &stats) {
|
||||
return std::make_unique<prepared_statement>(::make_shared<drop_service_level_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class drop_service_level_statement final : public service_level_statement {
|
||||
bool _if_exists;
|
||||
public:
|
||||
drop_service_level_statement(sstring service_level, bool if_exists);
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(database &db, cql_stats &stats) override;
|
||||
std::unique_ptr<cql3::statements::prepared_statement> prepare(data_dictionary::database db, cql_stats &stats) override;
|
||||
void validate(service::storage_proxy&, const service::client_state&) const override;
|
||||
virtual future<> check_access(service::storage_proxy& sp, const service::client_state&) const override;
|
||||
virtual future<::shared_ptr<cql_transport::messages::result_message>>
|
||||
|
||||
@@ -99,7 +99,7 @@ drop_table_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
drop_table_statement::prepare(database& db, cql_stats& stats) {
|
||||
drop_table_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<drop_table_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -46,8 +46,10 @@
|
||||
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "data_dictionary/keyspace_metadata.hh"
|
||||
#include "data_dictionary/user_types_metadata.hh"
|
||||
#include "mutation.hh"
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
@@ -77,7 +79,7 @@ void drop_type_statement::validate(service::storage_proxy& proxy, const service:
|
||||
|
||||
void drop_type_statement::validate_while_executing(service::storage_proxy& proxy) const {
|
||||
try {
|
||||
auto&& ks = proxy.get_db().local().find_keyspace(keyspace());
|
||||
auto&& ks = proxy.data_dictionary().find_keyspace(keyspace());
|
||||
auto&& all_types = ks.metadata()->user_types().get_all_types();
|
||||
auto old = all_types.find(_name.get_user_type_name());
|
||||
if (old == all_types.end()) {
|
||||
@@ -138,7 +140,7 @@ void drop_type_statement::validate_while_executing(service::storage_proxy& proxy
|
||||
}
|
||||
}
|
||||
|
||||
} catch (no_such_keyspace& e) {
|
||||
} catch (data_dictionary::no_such_keyspace& e) {
|
||||
throw exceptions::invalid_request_exception(format("Cannot drop type in unknown keyspace {}", keyspace()));
|
||||
}
|
||||
}
|
||||
@@ -153,7 +155,7 @@ future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<
|
||||
drop_type_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
validate_while_executing(qp.proxy());
|
||||
|
||||
database& db = qp.db();
|
||||
data_dictionary::database db = qp.db();
|
||||
|
||||
// Keyspace exists or we wouldn't have validated otherwise
|
||||
auto&& ks = db.find_keyspace(keyspace());
|
||||
@@ -180,7 +182,7 @@ drop_type_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
drop_type_statement::prepare(database& db, cql_stats& stats) {
|
||||
drop_type_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<drop_type_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ public:
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
private:
|
||||
void validate_while_executing(service::storage_proxy&) const;
|
||||
};
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#include "service/migration_manager.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
#include "view_info.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
@@ -61,12 +61,12 @@ drop_view_statement::drop_view_statement(cf_name view_name, bool if_exists)
|
||||
future<> drop_view_statement::check_access(service::storage_proxy& proxy, const service::client_state& state) const
|
||||
{
|
||||
try {
|
||||
const database& db = proxy.local_db();
|
||||
const data_dictionary::database db = proxy.data_dictionary();
|
||||
auto&& s = db.find_schema(keyspace(), column_family());
|
||||
if (s->is_view()) {
|
||||
return state.has_column_family_access(db, keyspace(), s->view_info()->base_name(), auth::permission::ALTER);
|
||||
return state.has_column_family_access(db.real_database(), keyspace(), s->view_info()->base_name(), auth::permission::ALTER);
|
||||
}
|
||||
} catch (const no_such_column_family& e) {
|
||||
} catch (const data_dictionary::no_such_column_family& e) {
|
||||
// Will be validated afterwards.
|
||||
}
|
||||
return make_ready_future<>();
|
||||
@@ -101,7 +101,7 @@ drop_view_statement::prepare_schema_mutations(query_processor& qp) const {
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
drop_view_statement::prepare(database& db, cql_stats& stats) {
|
||||
drop_view_statement::prepare(data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(make_shared<drop_view_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
#include "cql3/statements/schema_altering_statement.hh"
|
||||
|
||||
#include "database_fwd.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
|
||||
namespace cql3 {
|
||||
|
||||
@@ -68,7 +68,7 @@ public:
|
||||
future<std::pair<::shared_ptr<cql_transport::event::schema_change>, std::vector<mutation>>> prepare_schema_mutations(query_processor& qp) const override;
|
||||
|
||||
|
||||
virtual std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
virtual std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "cql3/functions/functions.hh"
|
||||
#include "cql3/functions/user_function.hh"
|
||||
#include "db/config.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "gms/feature_service.hh"
|
||||
#include "service/storage_proxy.hh"
|
||||
|
||||
@@ -53,7 +53,7 @@ data_type function_statement::prepare_type(service::storage_proxy& proxy, cql3_t
|
||||
if (t.is_user_type() && t.is_frozen()) {
|
||||
throw exceptions::invalid_request_exception("User defined argument and return types should not be frozen");
|
||||
}
|
||||
auto&& db = proxy.get_db().local();
|
||||
auto&& db = proxy.data_dictionary();
|
||||
// At the CQL level the argument and return types should not have
|
||||
// the frozen keyword.
|
||||
// We and cassandra 3 support only frozen UDT arguments and
|
||||
|
||||
@@ -63,7 +63,7 @@ public:
|
||||
: _role(name.to_string()), _grantee(grantee.to_string()) {
|
||||
}
|
||||
|
||||
std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
virtual future<> check_access(service::storage_proxy& proxy, const service::client_state&) const override;
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#include "service/query_state.hh"
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement> cql3::statements::grant_statement::prepare(
|
||||
database& db, cql_stats& stats) {
|
||||
data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(::make_shared<grant_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class grant_statement : public permission_altering_statement {
|
||||
public:
|
||||
using permission_altering_statement::permission_altering_statement;
|
||||
|
||||
std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
future<::shared_ptr<cql_transport::messages::result_message>> execute(query_processor&
|
||||
, service::query_state&
|
||||
|
||||
@@ -40,7 +40,8 @@
|
||||
*/
|
||||
|
||||
#include "cql3/statements/ks_prop_defs.hh"
|
||||
#include "database.hh"
|
||||
#include "data_dictionary/data_dictionary.hh"
|
||||
#include "data_dictionary/keyspace_metadata.hh"
|
||||
#include "locator/token_metadata.hh"
|
||||
#include "locator/abstract_replication_strategy.hh"
|
||||
|
||||
@@ -127,13 +128,13 @@ std::optional<sstring> ks_prop_defs::get_replication_strategy_class() const {
|
||||
return _strategy_class;
|
||||
}
|
||||
|
||||
lw_shared_ptr<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) {
|
||||
auto sc = get_replication_strategy_class().value();
|
||||
return keyspace_metadata::new_keyspace(ks_name, sc,
|
||||
return data_dictionary::keyspace_metadata::new_keyspace(ks_name, sc,
|
||||
prepare_options(sc, tm, get_replication_options()), get_boolean(KW_DURABLE_WRITES, true));
|
||||
}
|
||||
|
||||
lw_shared_ptr<keyspace_metadata> ks_prop_defs::as_ks_metadata_update(lw_shared_ptr<keyspace_metadata> old, const locator::token_metadata& tm) {
|
||||
lw_shared_ptr<data_dictionary::keyspace_metadata> ks_prop_defs::as_ks_metadata_update(lw_shared_ptr<data_dictionary::keyspace_metadata> old, const locator::token_metadata& tm) {
|
||||
std::map<sstring, sstring> options;
|
||||
const auto& old_options = old->strategy_options();
|
||||
auto sc = get_replication_strategy_class();
|
||||
@@ -144,7 +145,7 @@ lw_shared_ptr<keyspace_metadata> ks_prop_defs::as_ks_metadata_update(lw_shared_p
|
||||
options = old_options;
|
||||
}
|
||||
|
||||
return keyspace_metadata::new_keyspace(old->name(), *sc, options, get_boolean(KW_DURABLE_WRITES, true));
|
||||
return data_dictionary::keyspace_metadata::new_keyspace(old->name(), *sc, options, get_boolean(KW_DURABLE_WRITES, true));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -60,7 +60,7 @@ cql3::statements::list_permissions_statement::list_permissions_statement(
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement> cql3::statements::list_permissions_statement::prepare(
|
||||
database& db, cql_stats& stats) {
|
||||
data_dictionary::database db, cql_stats& stats) {
|
||||
return std::make_unique<prepared_statement>(::make_shared<list_permissions_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ private:
|
||||
public:
|
||||
list_permissions_statement(auth::permission_set, std::optional<auth::resource>, std::optional<sstring>, bool);
|
||||
|
||||
std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
void validate(service::storage_proxy&, const service::client_state&) const override;
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ public:
|
||||
list_roles_statement(const std::optional<role_name>& grantee, bool recursive)
|
||||
: _grantee(grantee ? sstring(grantee->to_string()) : std::optional<sstring>()), _recursive(recursive) {}
|
||||
|
||||
std::unique_ptr<prepared_statement> prepare(database& db, cql_stats& stats) override;
|
||||
std::unique_ptr<prepared_statement> prepare(data_dictionary::database db, cql_stats& stats) override;
|
||||
|
||||
virtual future<> check_access(service::storage_proxy& proxy, const service::client_state&) const override;
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ list_service_level_attachments_statement::list_service_level_attachments_stateme
|
||||
|
||||
std::unique_ptr<cql3::statements::prepared_statement>
|
||||
cql3::statements::list_service_level_attachments_statement::prepare(
|
||||
database &db, cql_stats &stats) {
|
||||
data_dictionary::database db, cql_stats &stats) {
|
||||
return std::make_unique<prepared_statement>(::make_shared<list_service_level_attachments_statement>(*this));
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user