mirror of
https://github.com/scylladb/scylladb.git
synced 2026-06-02 04:56:58 +00:00
transport::server: read cqlv2 batch options correctly
Fixes #563. Refs #584 CQLv2 encodes batch query_options in v1 format, not v2+. CQLv1 otoh has no batch support at all. Make read_options use explicit version format if needed. v2: Ensure we preserve cql protocol version in query_opts Message-Id: <1454514510-21706-1-git-send-email-calle@scylladb.com>
This commit is contained in:
committed by
Tomasz Grabiec
parent
b4b560e0fc
commit
a00ff015f4
@@ -770,7 +770,8 @@ cql_server::connection::process_batch(uint16_t stream, bytes_view buf, service::
|
||||
|
||||
auto q_state = std::make_unique<cql_query_state>(client_state);
|
||||
auto& query_state = q_state->query_state;
|
||||
q_state->options = std::make_unique<cql3::query_options>(std::move(*read_options(buf)), std::move(values));
|
||||
// #563. CQL v2 encodes query_options in v1 format for batch requests.
|
||||
q_state->options = std::make_unique<cql3::query_options>(std::move(*read_options(buf, _version < 3 ? 1 : _version)), std::move(values));
|
||||
auto& options = *q_state->options;
|
||||
|
||||
auto batch = ::make_shared<cql3::statements::batch_statement>(-1, cql3::statements::batch_statement::type(type), std::move(modifications), cql3::attributes::none());
|
||||
@@ -1150,14 +1151,19 @@ using options_flag_enum = super_enum<options_flag,
|
||||
>;
|
||||
|
||||
std::unique_ptr<cql3::query_options> cql_server::connection::read_options(bytes_view& buf)
|
||||
{
|
||||
return read_options(buf, _version);
|
||||
}
|
||||
|
||||
std::unique_ptr<cql3::query_options> cql_server::connection::read_options(bytes_view& buf, uint8_t version)
|
||||
{
|
||||
auto consistency = read_consistency(buf);
|
||||
if (_version == 1) {
|
||||
if (version == 1) {
|
||||
return std::make_unique<cql3::query_options>(consistency, std::experimental::nullopt, std::vector<bytes_view_opt>{},
|
||||
false, cql3::query_options::specific_options::DEFAULT, 1, _serialization_format);
|
||||
false, cql3::query_options::specific_options::DEFAULT, _version, _serialization_format);
|
||||
}
|
||||
|
||||
assert(_version >= 2);
|
||||
assert(version >= 2);
|
||||
|
||||
auto flags = enum_set<options_flag_enum>::from_mask(read_byte(buf));
|
||||
std::vector<bytes_view_opt> values;
|
||||
|
||||
@@ -192,6 +192,7 @@ private:
|
||||
db::consistency_level read_consistency(bytes_view& buf);
|
||||
std::unordered_map<sstring, sstring> read_string_map(bytes_view& buf);
|
||||
std::unique_ptr<cql3::query_options> read_options(bytes_view& buf);
|
||||
std::unique_ptr<cql3::query_options> read_options(bytes_view& buf, uint8_t);
|
||||
|
||||
void init_serialization_format();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user