From 316bd953f485d9406e5ff8157cb0a50216ff273a Mon Sep 17 00:00:00 2001 From: vaclavt Date: Tue, 31 May 2022 19:28:56 +0200 Subject: [PATCH] fix for crash (weak strict ordering) --- usql/row.h | 2 +- usql/usql_dml.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/usql/row.h b/usql/row.h index b4edf66..4ffb9cf 100644 --- a/usql/row.h +++ b/usql/row.h @@ -171,7 +171,7 @@ public: case 5: return (ColValue &) *std::get_if(&m_columns[i]); default: - throw Exception("should not happen"); + throw Exception("ColValue &operator[](int i), type index invalid :" + std::to_string(type_index)); } } diff --git a/usql/usql_dml.cpp b/usql/usql_dml.cpp index eeca189..ed3dc6b 100644 --- a/usql/usql_dml.cpp +++ b/usql/usql_dml.cpp @@ -155,8 +155,7 @@ void USql::setup_order_columns(std::vector &node, Table *table) { void USql::execute_distinct(SelectFromTableNode &node, Table *result) { if (!node.distinct) return; - auto compare_rows = [](const Row &a, const Row &b) { return a.compare(b) >= 0; }; - std::sort(result->m_rows.begin(), result->m_rows.end(), compare_rows); + std::sort(result->m_rows.begin(), result->m_rows.end(), [](const Row &a, const Row &b) { return a.compare(b) > 0; }); result->m_rows.erase(std::unique(result->m_rows.begin(), result->m_rows.end()), result->m_rows.end()); }