From a4355fe7e7bcede343425f1ebbd4d489f41ec0c9 Mon Sep 17 00:00:00 2001 From: Duarte Nunes Date: Wed, 15 Aug 2018 00:46:05 +0100 Subject: [PATCH] cql3/query_options: Use _value_views in prepare() _value_views is the authoritative data structure for the client-specified values. Indeed, the ctor called transport::request::read_options() leaves _values completely empty. In query_options::prepare() we were, however, using _values to associated values to the client-specified column names, and not _value_views. Fix this by using _value_views instead. As for the reasons we didn't see this bug earlier, I assume it's because very few drivers set the 0x04 query options flag, which means column names are omitted. This is the right thing to do since most drivers have enough information to correctly position the values. Fixes #3688 Signed-off-by: Duarte Nunes Message-Id: <20180814234605.14775-1-duarte@scylladb.com> --- cql3/query_options.cc | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/cql3/query_options.cc b/cql3/query_options.cc index e6e318c597..a328b2d970 100644 --- a/cql3/query_options.cc +++ b/cql3/query_options.cc @@ -170,19 +170,18 @@ void query_options::prepare(const std::vector<::shared_ptr } auto& names = *_names; - std::vector ordered_values; + std::vector ordered_values; ordered_values.reserve(specs.size()); for (auto&& spec : specs) { auto& spec_name = spec->name->text(); for (size_t j = 0; j < names.size(); j++) { if (names[j] == spec_name) { - ordered_values.emplace_back(_values[j]); + ordered_values.emplace_back(_value_views[j]); break; } } } - _values = std::move(ordered_values); - fill_value_views(); + _value_views = std::move(ordered_values); } void query_options::fill_value_views()