From 03bbcf55c23988981e0031dfdaa8e6a4e185027d Mon Sep 17 00:00:00 2001 From: Avi Kivity Date: Wed, 1 Apr 2015 20:17:10 +0300 Subject: [PATCH] cql3: fix max() function Registration was done with a null shared_ptr<> instead of make_shared(), and as a result the max template wasn't even instantiated, so it did not even build. --- cql3/functions/aggregate_fcts.hh | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cql3/functions/aggregate_fcts.hh b/cql3/functions/aggregate_fcts.hh index 4e066a68bd..6e76c88681 100644 --- a/cql3/functions/aggregate_fcts.hh +++ b/cql3/functions/aggregate_fcts.hh @@ -142,20 +142,20 @@ public: virtual void reset() override { _max = {}; } - virtual opt_bytes compute() override { + virtual opt_bytes compute(int protocol_version) override { if (!_max) { return {}; } - return data_type_for().decompose(*_max); + return data_type_for()->decompose(*_max); } virtual void add_input(int protocol_version, const std::vector& values) override { if (!values[0]) { return; } + auto val = boost::any_cast(data_type_for()->compose(*values[0])); if (!_max) { - _max = values[0]; + _max = val; } else { - auto val = boost::any_cast(data_type_for().compose(*values[0])); _max = std::max(*_max, val); } } @@ -179,7 +179,7 @@ public: template shared_ptr make_max_function() { - return shared_ptr>(); + return make_shared>(); } template