From 3ddea31815af7a5f930902ca31f097db123e895c Mon Sep 17 00:00:00 2001 From: hustjieke Date: Fri, 17 Mar 2023 11:18:10 +0000 Subject: [PATCH] fix(core): mv test from select_from to issue1332 and replace empty_flag --> (pv2 < local_min) #1332 --- mysql-test/suite/tianmu/r/issue1332.result | 697 +++++++++++++++++++ mysql-test/suite/tianmu/r/select_from.result | 538 -------------- mysql-test/suite/tianmu/t/issue1332.test | 176 +++++ mysql-test/suite/tianmu/t/select_from.test | 133 ---- storage/tianmu/core/tianmu_attr_exqp.cpp | 15 +- 5 files changed, 880 insertions(+), 679 deletions(-) create mode 100644 mysql-test/suite/tianmu/r/issue1332.result create mode 100644 mysql-test/suite/tianmu/t/issue1332.test diff --git a/mysql-test/suite/tianmu/r/issue1332.result b/mysql-test/suite/tianmu/r/issue1332.result new file mode 100644 index 000000000..d1ae432be --- /dev/null +++ b/mysql-test/suite/tianmu/r/issue1332.result @@ -0,0 +1,697 @@ +DROP DATABASE IF EXISTS issue1332; +CREATE DATABASE issue1332; +USE issue1332; +drop table if exists tb; +create table tb(a bigint, b int, c DATETIME) engine=tianmu; +insert into tb values(-9223372036854775806, 2147483647, '1111-11-11 11:11:11'), +(-922337203685477580, -2147483647, '1111-11-11 11:11:11'), +(-55, -55, '1111-11-11 11:11:11'), +(-22, 22, '1111-11-11 11:11:11'), +(-10, 33, '1111-11-11 11:11:11'), +(-4, 44, '1111-11-11 11:11:11'), +(0, 0, '1111-11-11 11:11:11'), +(2, 2, '1111-11-11 11:11:11'), +(6, 6, '1111-11-11 11:11:11'), +(9223372036854775807, 8, '1111-11-11 11:11:11'); +select * from tb; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a < -10; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +select * from tb where a > 4567890123456789; +a b c +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a > 0; +a b c +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a between -9223372036854775806 and 0; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +select * from tb where a between -9223372036854775807 and 0; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +select * from tb where a between -9223372036854775808 and 9223372036854775807; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a between -22 and 7; +a b c +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +select * from tb where a not in (3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a not in (-3,3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a not in (-3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a in (-3); +a b c +select * from tb where a in (-3, 3); +a b c +select * from tb where a in (select sum(b) from tb where b < 6); +a b c +select * from tb where a is null; +a b c +select * from tb where a is not null; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a in (not null); +a b c +select * from tb where a not in (null); +a b c +select * from tb where b < -10; +a b c +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +select * from tb where b < 2147483647; +a b c +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where b > -2147483647; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where b > 0; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where b between -2147483647 and 0; +a b c +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +select * from tb where b between -22 and 7; +a b c +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +select * from tb where b not in (3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where b not in (-3,3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where b not in (-3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where b in (-3); +a b c +select * from tb where b in (-3, 3); +a b c +select * from tb where b is null; +a b c +select * from tb where b is not null; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where b in (not null); +a b c +select * from tb where b not in (null); +a b c +SELECT * FROM tb WHERE c BETWEEN '111-11-10' AND '1111-11-12'; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +insert into tb values(null, null, null), (null, null, null); +select * from tb; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +NULL NULL NULL +NULL NULL NULL +select * from tb where a < -10; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +select * from tb where a > 4567890123456789; +a b c +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a > 0; +a b c +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a between -9223372036854775806 and 0; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +select * from tb where a between -22 and 7; +a b c +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +select * from tb where a not in (3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a not in (-3,3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a not in (-3); +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a in (-3); +a b c +select * from tb where a in (-3, 3); +a b c +select * from tb where a is null; +a b c +NULL NULL NULL +NULL NULL NULL +select * from tb where a is not null; +a b c +-9223372036854775806 2147483647 1111-11-11 11:11:11 +-922337203685477580 -2147483647 1111-11-11 11:11:11 +-55 -55 1111-11-11 11:11:11 +-22 22 1111-11-11 11:11:11 +-10 33 1111-11-11 11:11:11 +-4 44 1111-11-11 11:11:11 +0 0 1111-11-11 11:11:11 +2 2 1111-11-11 11:11:11 +6 6 1111-11-11 11:11:11 +9223372036854775807 8 1111-11-11 11:11:11 +select * from tb where a in (not null); +a b c +select * from tb where a not in (null); +a b c +drop table tb; +create table tb(a bigint) engine=tianmu; +insert into tb values(-55), (-22), (-10), (-4), (0), (2), (6); +select * from tb; +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a < -55; +a +select * from tb where a < 0; +a +-55 +-22 +-10 +-4 +select * from tb where a > 6; +a +select * from tb where a > 0; +a +2 +6 +select * from tb where a between -9223372036854775806 and 0; +a +-55 +-22 +-10 +-4 +0 +select * from tb where a between -22 and 7; +a +-22 +-10 +-4 +0 +2 +6 +select * from tb where a between 22 and 33; +a +select * from tb where a between -555 and -56; +a +select * from tb where a not in (3333); +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a not in (-3,3333); +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a not in (-33333); +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a in (-3); +a +select * from tb where a in (-3, 3); +a +select * from tb where a is null; +a +select * from tb where a is not null; +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a in (not null); +a +select * from tb where a not in (null); +a +insert into tb values(null), (null); +select * from tb; +a +-55 +-22 +-10 +-4 +0 +2 +6 +NULL +NULL +select * from tb where a < -55; +a +select * from tb where a < 0; +a +-55 +-22 +-10 +-4 +select * from tb where a > 6; +a +select * from tb where a > 0; +a +2 +6 +select * from tb where a between -9223372036854775806 and 0; +a +-55 +-22 +-10 +-4 +0 +select * from tb where a between -9223372036854775807 and 0; +a +-55 +-22 +-10 +-4 +0 +select * from tb where a between -22 and 7; +a +-22 +-10 +-4 +0 +2 +6 +select * from tb where a between 22 and 33; +a +select * from tb where a between -555 and -56; +a +select * from tb where a not in (3333); +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a not in (-3,3333); +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a not in (-33333); +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a in (-3); +a +select * from tb where a in (-3, 3); +a +select * from tb where a is null; +a +NULL +NULL +select * from tb where a is not null; +a +-55 +-22 +-10 +-4 +0 +2 +6 +select * from tb where a in (not null); +a +select * from tb where a not in (null); +a +drop table tb; +create table tb(a bigint) engine=tianmu; +insert into tb values(0), (0), (0); +select * from tb; +a +0 +0 +0 +select * from tb where a < -55; +a +select * from tb where a > 0; +a +select * from tb where a > -1; +a +0 +0 +0 +select * from tb where a between -3 and -1; +a +select * from tb where a between 1 and 3; +a +select * from tb where a between 0 and 0; +a +0 +0 +0 +select * from tb where a between -1 and 3; +a +0 +0 +0 +select * from tb where a between -1 and 0; +a +0 +0 +0 +select * from tb where a between 0 and 3; +a +0 +0 +0 +select * from tb where a not in (3); +a +0 +0 +0 +select * from tb where a not in (-3,3); +a +0 +0 +0 +select * from tb where a not in (-125); +a +0 +0 +0 +select * from tb where a in (-3); +a +select * from tb where a in (-3, 3); +a +select * from tb where a is null; +a +select * from tb where a is not null; +a +0 +0 +0 +select * from tb where a in (not null); +a +select * from tb where a not in (null); +a +insert into tb values(null), (null); +select * from tb; +a +0 +0 +0 +NULL +NULL +select * from tb where a < -55; +a +select * from tb where a > 0; +a +select * from tb where a > -1; +a +0 +0 +0 +select * from tb where a between -3 and -1; +a +select * from tb where a between 1 and 3; +a +select * from tb where a between 0 and 0; +a +0 +0 +0 +select * from tb where a between -1 and 3; +a +0 +0 +0 +select * from tb where a between -1 and 0; +a +0 +0 +0 +select * from tb where a between 0 and 3; +a +0 +0 +0 +select * from tb where a not in (3); +a +0 +0 +0 +select * from tb where a not in (-3,3); +a +0 +0 +0 +select * from tb where a not in (-125); +a +0 +0 +0 +select * from tb where a in (-3); +a +select * from tb where a in (-3, 3); +a +select * from tb where a is null; +a +NULL +NULL +select * from tb where a is not null; +a +0 +0 +0 +select * from tb where a in (not null); +a +select * from tb where a not in (null); +a +drop table tb; +DROP DATABASE issue1332; diff --git a/mysql-test/suite/tianmu/r/select_from.result b/mysql-test/suite/tianmu/r/select_from.result index 3685d505f..f63b23323 100644 --- a/mysql-test/suite/tianmu/r/select_from.result +++ b/mysql-test/suite/tianmu/r/select_from.result @@ -208,542 +208,4 @@ q10 9 q10 10 drop table t2_test; drop table t1_test; -create table tb(a bigint) engine=tianmu; -insert into tb values(-9223372036854775806), (-922337203685477580), (-55), (-22), (-10), (-4), (0), (2), (6), (9223372036854775807); -select * from tb; -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a < -10; -a --9223372036854775806 --922337203685477580 --55 --22 -select * from tb where a > 4567890123456789; -a -9223372036854775807 -select * from tb where a > 0; -a -2 -6 -9223372036854775807 -select * from tb where a between -9223372036854775806 and 0; -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -select * from tb where a between -22 and 7; -a --22 --10 --4 -0 -2 -6 -select * from tb where a not in (3); -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a not in (-3,3); -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a not in (-3); -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a in (-3); -a -select * from tb where a in (-3, 3); -a -select * from tb where a is null; -a -select * from tb where a is not null; -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a in (not null); -a -select * from tb where a not in (null); -a -insert into tb values(null), (null); -select * from tb; -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -NULL -NULL -select * from tb where a < -10; -a --9223372036854775806 --922337203685477580 --55 --22 -select * from tb where a > 4567890123456789; -a -9223372036854775807 -select * from tb where a > 0; -a -2 -6 -9223372036854775807 -select * from tb where a between -9223372036854775806 and 0; -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -select * from tb where a between -22 and 7; -a --22 --10 --4 -0 -2 -6 -select * from tb where a not in (3); -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a not in (-3,3); -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a not in (-3); -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a in (-3); -a -select * from tb where a in (-3, 3); -a -select * from tb where a is null; -a -NULL -NULL -select * from tb where a is not null; -a --9223372036854775806 --922337203685477580 --55 --22 --10 --4 -0 -2 -6 -9223372036854775807 -select * from tb where a in (not null); -a -select * from tb where a not in (null); -a -drop table tb; -create table tb(a bigint) engine=tianmu; -insert into tb values(-55), (-22), (-10), (-4), (0), (2), (6); -select * from tb; -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a < -55; -a -select * from tb where a < 0; -a --55 --22 --10 --4 -select * from tb where a > 6; -a -select * from tb where a > 0; -a -2 -6 -select * from tb where a between -9223372036854775806 and 0; -a --55 --22 --10 --4 -0 -select * from tb where a between -22 and 7; -a --22 --10 --4 -0 -2 -6 -select * from tb where a between 22 and 33; -a -select * from tb where a between -555 and -56; -a -select * from tb where a not in (3333); -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a not in (-3,3333); -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a not in (-33333); -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a in (-3); -a -select * from tb where a in (-3, 3); -a -select * from tb where a is null; -a -select * from tb where a is not null; -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a in (not null); -a -select * from tb where a not in (null); -a -insert into tb values(null), (null); -select * from tb; -a --55 --22 --10 --4 -0 -2 -6 -NULL -NULL -select * from tb where a < -55; -a -select * from tb where a < 0; -a --55 --22 --10 --4 -select * from tb where a > 6; -a -select * from tb where a > 0; -a -2 -6 -select * from tb where a between -9223372036854775806 and 0; -a --55 --22 --10 --4 -0 -select * from tb where a between -22 and 7; -a --22 --10 --4 -0 -2 -6 -select * from tb where a between 22 and 33; -a -select * from tb where a between -555 and -56; -a -select * from tb where a not in (3333); -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a not in (-3,3333); -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a not in (-33333); -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a in (-3); -a -select * from tb where a in (-3, 3); -a -select * from tb where a is null; -a -NULL -NULL -select * from tb where a is not null; -a --55 --22 --10 --4 -0 -2 -6 -select * from tb where a in (not null); -a -select * from tb where a not in (null); -a -drop table tb; -create table tb(a bigint) engine=tianmu; -insert into tb values(0), (0), (0); -select * from tb; -a -0 -0 -0 -select * from tb where a < -55; -a -select * from tb where a > 0; -a -select * from tb where a > -1; -a -0 -0 -0 -select * from tb where a between -3 and -1; -a -select * from tb where a between 1 and 3; -a -select * from tb where a between 0 and 0; -a -0 -0 -0 -select * from tb where a between -1 and 3; -a -0 -0 -0 -select * from tb where a between -1 and 0; -a -0 -0 -0 -select * from tb where a between 0 and 3; -a -0 -0 -0 -select * from tb where a not in (3); -a -0 -0 -0 -select * from tb where a not in (-3,3); -a -0 -0 -0 -select * from tb where a not in (-125); -a -0 -0 -0 -select * from tb where a in (-3); -a -select * from tb where a in (-3, 3); -a -select * from tb where a is null; -a -select * from tb where a is not null; -a -0 -0 -0 -select * from tb where a in (not null); -a -select * from tb where a not in (null); -a -insert into tb values(null), (null); -select * from tb; -a -0 -0 -0 -NULL -NULL -select * from tb where a < -55; -a -select * from tb where a > 0; -a -select * from tb where a > -1; -a -0 -0 -0 -select * from tb where a between -3 and -1; -a -select * from tb where a between 1 and 3; -a -select * from tb where a between 0 and 0; -a -0 -0 -0 -select * from tb where a between -1 and 3; -a -0 -0 -0 -select * from tb where a between -1 and 0; -a -0 -0 -0 -select * from tb where a between 0 and 3; -a -0 -0 -0 -select * from tb where a not in (3); -a -0 -0 -0 -select * from tb where a not in (-3,3); -a -0 -0 -0 -select * from tb where a not in (-125); -a -0 -0 -0 -select * from tb where a in (-3); -a -select * from tb where a in (-3, 3); -a -select * from tb where a is null; -a -NULL -NULL -select * from tb where a is not null; -a -0 -0 -0 -select * from tb where a in (not null); -a -select * from tb where a not in (null); -a -drop table tb; DROP DATABASE select_from_test; diff --git a/mysql-test/suite/tianmu/t/issue1332.test b/mysql-test/suite/tianmu/t/issue1332.test new file mode 100644 index 000000000..ed25c5ac0 --- /dev/null +++ b/mysql-test/suite/tianmu/t/issue1332.test @@ -0,0 +1,176 @@ +--source include/have_tianmu.inc + +--disable_warnings +DROP DATABASE IF EXISTS issue1332; +--enable_warnings +CREATE DATABASE issue1332; +USE issue1332; + +--disable_warnings +drop table if exists tb; +--enable_warnings + + +# fix between ... and ... : https://github.com/stoneatom/stonedb/issues/1332 +# test values with boundary, with not null, tinyint~mediumint never be overflow, decimal cond has been tested in where_conditions.test. +create table tb(a bigint, b int, c DATETIME) engine=tianmu; +insert into tb values(-9223372036854775806, 2147483647, '1111-11-11 11:11:11'), + (-922337203685477580, -2147483647, '1111-11-11 11:11:11'), + (-55, -55, '1111-11-11 11:11:11'), + (-22, 22, '1111-11-11 11:11:11'), + (-10, 33, '1111-11-11 11:11:11'), + (-4, 44, '1111-11-11 11:11:11'), + (0, 0, '1111-11-11 11:11:11'), + (2, 2, '1111-11-11 11:11:11'), + (6, 6, '1111-11-11 11:11:11'), + (9223372036854775807, 8, '1111-11-11 11:11:11'); +select * from tb; +select * from tb where a < -10; +select * from tb where a > 4567890123456789; +select * from tb where a > 0; +select * from tb where a between -9223372036854775806 and 0; +select * from tb where a between -9223372036854775807 and 0; # NULL_VALUE +select * from tb where a between -9223372036854775808 and 9223372036854775807; # min~max +select * from tb where a between -22 and 7; +select * from tb where a not in (3); +select * from tb where a not in (-3,3); +select * from tb where a not in (-3); +select * from tb where a in (-3); +select * from tb where a in (-3, 3); +select * from tb where a in (select sum(b) from tb where b < 6); +select * from tb where a is null; # emtpy +select * from tb where a is not null; # emtpy +select * from tb where a in (not null); # emtpy +select * from tb where a not in (null); # emtpy + +select * from tb where b < -10; +select * from tb where b < 2147483647; +select * from tb where b > -2147483647; +select * from tb where b > 0; +select * from tb where b between -2147483647 and 0; +select * from tb where b between -22 and 7; +select * from tb where b not in (3); +select * from tb where b not in (-3,3); +select * from tb where b not in (-3); +select * from tb where b in (-3); +select * from tb where b in (-3, 3); +select * from tb where b is null; # emtpy +select * from tb where b is not null; # emtpy +select * from tb where b in (not null); # emtpy +select * from tb where b not in (null); # emtpy +SELECT * FROM tb WHERE c BETWEEN '111-11-10' AND '1111-11-12'; + +# test with null +insert into tb values(null, null, null), (null, null, null); +select * from tb; +select * from tb where a < -10; +select * from tb where a > 4567890123456789; +select * from tb where a > 0; +select * from tb where a between -9223372036854775806 and 0; +select * from tb where a between -22 and 7; +select * from tb where a not in (3); +select * from tb where a not in (-3,3); +select * from tb where a not in (-3); +select * from tb where a in (-3); +select * from tb where a in (-3, 3); +select * from tb where a is null; # emtpy +select * from tb where a is not null; # emtpy +select * from tb where a in (not null); # emtpy +select * from tb where a not in (null); # emtpy + +drop table tb; + +# test normal values, with not null +create table tb(a bigint) engine=tianmu; +insert into tb values(-55), (-22), (-10), (-4), (0), (2), (6); +select * from tb; +select * from tb where a < -55; +select * from tb where a < 0; +select * from tb where a > 6; +select * from tb where a > 0; +select * from tb where a between -9223372036854775806 and 0; +select * from tb where a between -22 and 7; +select * from tb where a between 22 and 33; +select * from tb where a between -555 and -56; +select * from tb where a not in (3333); +select * from tb where a not in (-3,3333); +select * from tb where a not in (-33333); +select * from tb where a in (-3); +select * from tb where a in (-3, 3); +select * from tb where a is null; # emtpy +select * from tb where a is not null; # emtpy +select * from tb where a in (not null); # emtpy +select * from tb where a not in (null); # emtpy + +# test with null +insert into tb values(null), (null); +select * from tb; +select * from tb where a < -55; +select * from tb where a < 0; +select * from tb where a > 6; +select * from tb where a > 0; +select * from tb where a between -9223372036854775806 and 0; +select * from tb where a between -9223372036854775807 and 0; +select * from tb where a between -22 and 7; +select * from tb where a between 22 and 33; +select * from tb where a between -555 and -56; +select * from tb where a not in (3333); +select * from tb where a not in (-3,3333); +select * from tb where a not in (-33333); +select * from tb where a in (-3); +select * from tb where a in (-3, 3); +select * from tb where a is null; # emtpy +select * from tb where a is not null; # emtpy +select * from tb where a in (not null); # emtpy +select * from tb where a not in (null); # emtpy + +drop table tb; + +# test max=min, with not null +create table tb(a bigint) engine=tianmu; +insert into tb values(0), (0), (0); +select * from tb; +select * from tb where a < -55; +select * from tb where a > 0; +select * from tb where a > -1; +select * from tb where a between -3 and -1; +select * from tb where a between 1 and 3; +select * from tb where a between 0 and 0; +select * from tb where a between -1 and 3; +select * from tb where a between -1 and 0; +select * from tb where a between 0 and 3; +select * from tb where a not in (3); +select * from tb where a not in (-3,3); +select * from tb where a not in (-125); +select * from tb where a in (-3); +select * from tb where a in (-3, 3); +select * from tb where a is null; # emtpy +select * from tb where a is not null; # emtpy +select * from tb where a in (not null); # emtpy +select * from tb where a not in (null); # emtpy + +# test with null +insert into tb values(null), (null); +select * from tb; +select * from tb where a < -55; +select * from tb where a > 0; +select * from tb where a > -1; +select * from tb where a between -3 and -1; +select * from tb where a between 1 and 3; +select * from tb where a between 0 and 0; +select * from tb where a between -1 and 3; +select * from tb where a between -1 and 0; +select * from tb where a between 0 and 3; +select * from tb where a not in (3); +select * from tb where a not in (-3,3); +select * from tb where a not in (-125); +select * from tb where a in (-3); +select * from tb where a in (-3, 3); +select * from tb where a is null; # emtpy +select * from tb where a is not null; # emtpy +select * from tb where a in (not null); # emtpy +select * from tb where a not in (null); # emtpy + +drop table tb; + +DROP DATABASE issue1332; diff --git a/mysql-test/suite/tianmu/t/select_from.test b/mysql-test/suite/tianmu/t/select_from.test index 9a9bcf182..6d11433cc 100644 --- a/mysql-test/suite/tianmu/t/select_from.test +++ b/mysql-test/suite/tianmu/t/select_from.test @@ -116,137 +116,4 @@ vc1 = 9 or bi2 = 4; drop table t2_test; drop table t1_test; -# fix between ... and ... : https://github.com/stoneatom/stonedb/issues/1332 -# test values with boundary, with not null -create table tb(a bigint) engine=tianmu; -insert into tb values(-9223372036854775806), (-922337203685477580), (-55), (-22), (-10), (-4), (0), (2), (6), (9223372036854775807); -select * from tb; -select * from tb where a < -10; -select * from tb where a > 4567890123456789; -select * from tb where a > 0; -select * from tb where a between -9223372036854775806 and 0; -select * from tb where a between -22 and 7; -select * from tb where a not in (3); -select * from tb where a not in (-3,3); -select * from tb where a not in (-3); -select * from tb where a in (-3); -select * from tb where a in (-3, 3); -select * from tb where a is null; # emtpy -select * from tb where a is not null; # emtpy -select * from tb where a in (not null); # emtpy -select * from tb where a not in (null); # emtpy - -# test with null -insert into tb values(null), (null); -select * from tb; -select * from tb where a < -10; -select * from tb where a > 4567890123456789; -select * from tb where a > 0; -select * from tb where a between -9223372036854775806 and 0; -select * from tb where a between -22 and 7; -select * from tb where a not in (3); -select * from tb where a not in (-3,3); -select * from tb where a not in (-3); -select * from tb where a in (-3); -select * from tb where a in (-3, 3); -select * from tb where a is null; # emtpy -select * from tb where a is not null; # emtpy -select * from tb where a in (not null); # emtpy -select * from tb where a not in (null); # emtpy - -drop table tb; - -# test normal values, with not null -create table tb(a bigint) engine=tianmu; -insert into tb values(-55), (-22), (-10), (-4), (0), (2), (6); -select * from tb; -select * from tb where a < -55; -select * from tb where a < 0; -select * from tb where a > 6; -select * from tb where a > 0; -select * from tb where a between -9223372036854775806 and 0; -select * from tb where a between -22 and 7; -select * from tb where a between 22 and 33; -select * from tb where a between -555 and -56; -select * from tb where a not in (3333); -select * from tb where a not in (-3,3333); -select * from tb where a not in (-33333); -select * from tb where a in (-3); -select * from tb where a in (-3, 3); -select * from tb where a is null; # emtpy -select * from tb where a is not null; # emtpy -select * from tb where a in (not null); # emtpy -select * from tb where a not in (null); # emtpy - -# test with null -insert into tb values(null), (null); -select * from tb; -select * from tb where a < -55; -select * from tb where a < 0; -select * from tb where a > 6; -select * from tb where a > 0; -select * from tb where a between -9223372036854775806 and 0; -select * from tb where a between -22 and 7; -select * from tb where a between 22 and 33; -select * from tb where a between -555 and -56; -select * from tb where a not in (3333); -select * from tb where a not in (-3,3333); -select * from tb where a not in (-33333); -select * from tb where a in (-3); -select * from tb where a in (-3, 3); -select * from tb where a is null; # emtpy -select * from tb where a is not null; # emtpy -select * from tb where a in (not null); # emtpy -select * from tb where a not in (null); # emtpy - -drop table tb; - -# test max=min, with not null -create table tb(a bigint) engine=tianmu; -insert into tb values(0), (0), (0); -select * from tb; -select * from tb where a < -55; -select * from tb where a > 0; -select * from tb where a > -1; -select * from tb where a between -3 and -1; -select * from tb where a between 1 and 3; -select * from tb where a between 0 and 0; -select * from tb where a between -1 and 3; -select * from tb where a between -1 and 0; -select * from tb where a between 0 and 3; -select * from tb where a not in (3); -select * from tb where a not in (-3,3); -select * from tb where a not in (-125); -select * from tb where a in (-3); -select * from tb where a in (-3, 3); -select * from tb where a is null; # emtpy -select * from tb where a is not null; # emtpy -select * from tb where a in (not null); # emtpy -select * from tb where a not in (null); # emtpy - -# test with null -insert into tb values(null), (null); -select * from tb; -select * from tb where a < -55; -select * from tb where a > 0; -select * from tb where a > -1; -select * from tb where a between -3 and -1; -select * from tb where a between 1 and 3; -select * from tb where a between 0 and 0; -select * from tb where a between -1 and 3; -select * from tb where a between -1 and 0; -select * from tb where a between 0 and 3; -select * from tb where a not in (3); -select * from tb where a not in (-3,3); -select * from tb where a not in (-125); -select * from tb where a in (-3); -select * from tb where a in (-3, 3); -select * from tb where a is null; # emtpy -select * from tb where a is not null; # emtpy -select * from tb where a in (not null); # emtpy -select * from tb where a not in (null); # emtpy - -drop table tb; - - DROP DATABASE select_from_test; diff --git a/storage/tianmu/core/tianmu_attr_exqp.cpp b/storage/tianmu/core/tianmu_attr_exqp.cpp index 4627c5e8c..16d5031d5 100644 --- a/storage/tianmu/core/tianmu_attr_exqp.cpp +++ b/storage/tianmu/core/tianmu_attr_exqp.cpp @@ -878,10 +878,10 @@ void TianmuAttr::EvaluatePack_BetweenInt(MIUpdatingIterator &mit, int dim, Descr int64_t pv1 = d.val1.vc->GetValueInt64(mit); // e.g.: between pv1 and pv2 int64_t pv2 = d.val2.vc->GetValueInt64(mit); // e.g.: between pv1 and pv2 uint64_t upv1, upv2; // used uint64_t to store level 2 encode, ranges from [0, uint64_max] - // Only used when rough check = RS_ALL(no numeric data matchs), but table has null, rough check will be reset RS_SOME, + // special case(pv2 < local_min): table has both numerics and null values,for between pv1 and pv2, if pv1GetValInt(n); - if (empty_flag || v < upv1 || v > upv2) + if ((pv2 < local_min) || v < upv1 || v > upv2) filter->Reset(pack, n); } } else { @@ -919,7 +918,7 @@ void TianmuAttr::EvaluatePack_BetweenInt(MIUpdatingIterator &mit, int dim, Descr filter->Reset(pack, n); else { uint64_t v = p->GetValInt(n); - bool res = empty_flag ? false : (upv1 <= v && v <= upv2); + bool res = (pv2 < local_min) ? false : (upv1 <= v && v <= upv2); if (d.op == common::Operator::O_NOT_BETWEEN) res = !res; if (!res) @@ -933,7 +932,7 @@ void TianmuAttr::EvaluatePack_BetweenInt(MIUpdatingIterator &mit, int dim, Descr // easy and fast case - no "if"s do { uint64_t v = p->GetValInt(mit.GetCurInpack(dim)); - if (empty_flag || v < upv1 || v > upv2) + if ((pv2 < local_min) || v < upv1 || v > upv2) mit.ResetCurrent(); ++mit; } while (mit.IsValid() && !mit.PackrowStarted()); @@ -945,7 +944,7 @@ void TianmuAttr::EvaluatePack_BetweenInt(MIUpdatingIterator &mit, int dim, Descr mit.ResetCurrent(); else { uint64_t v = p->GetValInt(inpack); - bool res = (empty_flag ? false : upv1 <= v && v <= upv2); + bool res = ((pv2 < local_min) ? false : upv1 <= v && v <= upv2); if (d.op == common::Operator::O_NOT_BETWEEN) res = !res; if (!res)