From b26120e0ee2c73faff9560981ad886489d085678 Mon Sep 17 00:00:00 2001 From: Ti Chi Robot Date: Wed, 19 Oct 2022 10:41:53 +0800 Subject: [PATCH] fix inconsistent result before deleting some rows (#6133) (#6141) close pingcap/tiflash#6127 --- dbms/src/Functions/FunctionsLogical.h | 6 ++--- dbms/src/Functions/tests/gtest_logical.cpp | 28 ++++++++++++++++------ 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/dbms/src/Functions/FunctionsLogical.h b/dbms/src/Functions/FunctionsLogical.h index 7f1813dd219..54f619cb935 100644 --- a/dbms/src/Functions/FunctionsLogical.h +++ b/dbms/src/Functions/FunctionsLogical.h @@ -137,7 +137,7 @@ struct NotImpl { using ResultType = UInt8; - static inline UInt8 apply(A a) + static inline bool apply(A a) { return !a; } @@ -180,7 +180,7 @@ struct AssociativeOperationImpl {} /// Returns a combination of values in the i-th row of all columns stored in the constructor. - inline UInt8 apply(size_t i) const + inline bool apply(size_t i) const { if (Op::isSaturable()) { @@ -224,7 +224,7 @@ struct AssociativeOperationImpl : vec(in[in.size() - 1]->getData()) {} - inline UInt8 apply(size_t i) const + inline bool apply(size_t i) const { return vec[i]; } diff --git a/dbms/src/Functions/tests/gtest_logical.cpp b/dbms/src/Functions/tests/gtest_logical.cpp index 1b30e83cf5b..e21e7a52737 100644 --- a/dbms/src/Functions/tests/gtest_logical.cpp +++ b/dbms/src/Functions/tests/gtest_logical.cpp @@ -44,6 +44,20 @@ try func_name, createOnlyNullColumnConst(2), createColumn>({1, 0}))); + // issue 6127 + ASSERT_COLUMN_EQ( + createColumn({0, 1, 0, 0}), + executeFunction( + func_name, + createColumn({0, 123, 0, 41}), + createColumn({0, 11, 221, 0}))); + // issue 6127, position of UInt8 column may affect the result + ASSERT_COLUMN_EQ( + createColumn({0, 1, 0, 0}), + executeFunction( + func_name, + createColumn({0, 123, 0, 41}), + createColumn({0, 11, 221, 0}))); } CATCH @@ -59,13 +73,6 @@ try func_name, createColumn>({0, 1, 0, 1, {}, 0}), createColumn>({0, 1, 1, 0, 1, {}}))); - // issue 5849 - ASSERT_COLUMN_EQ( - createColumn({0, 1, 1, 1}), - executeFunction( - func_name, - createColumn({0, 123, 0, 41}), - createColumn({0, 11, 221, 0}))); // column, const ASSERT_COLUMN_EQ( createColumn>({1, 1}), @@ -87,6 +94,13 @@ try func_name, createOnlyNullColumnConst(2), createColumn>({1, 0}))); + // issue 5849 + ASSERT_COLUMN_EQ( + createColumn({0, 1, 1, 1}), + executeFunction( + func_name, + createColumn({0, 123, 0, 41}), + createColumn({0, 11, 221, 0}))); } CATCH