From 804fe50b7fb5057e7566c486dc153a2af8a97d0d Mon Sep 17 00:00:00 2001 From: Tomasz Grabiec Date: Thu, 15 Sep 2016 18:25:14 +0200 Subject: [PATCH] types: fix uuid_type_impl::less timeuuid_type_impl::compare_bytes is a "trichotomic" comparator (-1, 0, 1) while less() is a "less" comparator (false, true). The code incorrectly returns c1 instead of c1 < 0 which breaks the ordering. Fixes #1196. Message-Id: <1473956716-5209-1-git-send-email-tgrabiec@scylladb.com> --- types.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/types.cc b/types.cc index 1c2f136ba9..846afe8c93 100644 --- a/types.cc +++ b/types.cc @@ -773,11 +773,9 @@ struct uuid_type_impl : concrete_type { } if (v1 == 1) { - auto c1 = timeuuid_type_impl::compare_bytes(b1, b2); - auto c2 = timeuuid_type_impl::compare_bytes(b2, b1); - // Require strict ordering - if (c1 != c2) { - return c1; + auto c = timeuuid_type_impl::compare_bytes(b1, b2); + if (c) { + return c < 0; } } return less_unsigned(b1, b2);