diff --git a/transport/server.cc b/transport/server.cc index dcdda7e7bc..bfd70e9dbe 100644 --- a/transport/server.cc +++ b/transport/server.cc @@ -770,7 +770,8 @@ cql_server::connection::process_batch(uint16_t stream, bytes_view buf, service:: auto q_state = std::make_unique(client_state); auto& query_state = q_state->query_state; - q_state->options = std::make_unique(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(std::move(*read_options(buf, _version < 3 ? 1 : _version)), std::move(values)); auto& options = *q_state->options; auto batch = ::make_shared(-1, cql3::statements::batch_statement::type(type), std::move(modifications), cql3::attributes::none()); @@ -1150,14 +1151,19 @@ using options_flag_enum = super_enum; std::unique_ptr cql_server::connection::read_options(bytes_view& buf) +{ + return read_options(buf, _version); +} + +std::unique_ptr 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(consistency, std::experimental::nullopt, std::vector{}, - 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::from_mask(read_byte(buf)); std::vector values; diff --git a/transport/server.hh b/transport/server.hh index c14d40af4d..d96da90876 100644 --- a/transport/server.hh +++ b/transport/server.hh @@ -192,6 +192,7 @@ private: db::consistency_level read_consistency(bytes_view& buf); std::unordered_map read_string_map(bytes_view& buf); std::unique_ptr read_options(bytes_view& buf); + std::unique_ptr read_options(bytes_view& buf, uint8_t); void init_serialization_format();