validation: validate_cql_key(): make key parameter a partition_key_view
This is more general than the previous `const partition_key&` and allows for passing keys obtained from the likes of `frozen_mutation` that only have a view of the key. While at it also change the schema parameter from schema_ptr to const schema&. No need to pass a shared pointer.
This commit is contained in:
@@ -266,7 +266,7 @@ dht::partition_range_vector
|
||||
modification_statement::build_partition_keys(const query_options& options, const json_cache_opt& json_cache) const {
|
||||
auto keys = _restrictions->get_partition_key_restrictions()->bounds_ranges(options);
|
||||
for (auto const& k : keys) {
|
||||
validation::validate_cql_key(s, *k.start()->value().key());
|
||||
validation::validate_cql_key(*s, *k.start()->value().key());
|
||||
}
|
||||
return keys;
|
||||
}
|
||||
|
||||
@@ -50,10 +50,10 @@ namespace validation {
|
||||
* Based on org.apache.cassandra.thrift.ThriftValidation#validate_key()
|
||||
*/
|
||||
void
|
||||
validate_cql_key(schema_ptr schema, const partition_key& key) {
|
||||
validate_cql_key(const schema& schema, partition_key_view key) {
|
||||
// C* validates here that the thrift key is not empty.
|
||||
// It can only be empty if it is not composite and its only component in CQL form is empty.
|
||||
if (schema->partition_key_size() == 1 && key.begin(*schema)->empty()) {
|
||||
if (schema.partition_key_size() == 1 && key.begin(schema)->empty()) {
|
||||
throw exceptions::invalid_request_exception("Key may not be empty");
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ validate_cql_key(schema_ptr schema, const partition_key& key) {
|
||||
}
|
||||
|
||||
try {
|
||||
key.validate(*schema);
|
||||
key.validate(schema);
|
||||
} catch (const marshal_exception& e) {
|
||||
throw exceptions::invalid_request_exception(e.what());
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace validation {
|
||||
|
||||
constexpr size_t max_key_size = std::numeric_limits<uint16_t>::max();
|
||||
|
||||
void validate_cql_key(schema_ptr schema, const partition_key& key);
|
||||
void validate_cql_key(const schema& schema, partition_key_view key);
|
||||
schema_ptr validate_column_family(database& db, const sstring& keyspace_name, const sstring& cf_name);
|
||||
schema_ptr validate_column_family(const sstring& keyspace_name, const sstring& cf_name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user