Skip to content

Commit

Permalink
fix(core): rm incorrect boundary check on rough check with between #1344
Browse files Browse the repository at this point in the history


[summary]
1. change file(tianmu_attr_exeq_rs.cpp) format from dos 2 unix

2. rm incorrect between check, actually the v1 or v2 equal to boundary is illegal and it will cause empty result when condition
like `where col = PLUS_INF_64`, `where col = PLUS_INF_DBL`, `where col = MINUS_INF_DBL`:

```
common::RoughSetValue TianmuAttr::RoughCheckBetween(int pack, int64_t v1, int64_
                                                                // and then consider negation
   bool is_float = Type().IsFloat();
   auto const &dpn(get_dpn(pack));
-  if (!is_float && (v1 == common::PLUS_INF_64 || v2 == common::MINUS_INF_64)) {
-    res = common::RoughSetValue::RS_NONE;
-  } else if (is_float && (v1 == *(int64_t *)&common::PLUS_INF_DBL || v2 == *(int64_t *)&common::MINUS_INF_DBL)) {
-    res = common::RoughSetValue::RS_NONE;
-  } else if (!is_float && (v1 > dpn.max_i || v2 < dpn.min_i)) {
+  if (!is_float && (v1 > dpn.max_i || v2 < dpn.min_i)) {
```
  • Loading branch information
hustjieke authored and mergify[bot] committed Mar 8, 2023
1 parent a094688 commit 478e705
Show file tree
Hide file tree
Showing 3 changed files with 1,146 additions and 1,069 deletions.
46 changes: 46 additions & 0 deletions mysql-test/suite/tianmu/r/signed_boundary.result
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# Test signed boundary
#
DROP DATABASE IF EXISTS signed_boundary;
CREATE DATABASE signed_boundary;
USE signed_boundary;
CREATE TABLE int32_(c_max int, c_min int) engine = tianmu;
INSERT INTO int32_ values(-2147483647, 2147483647);
INSERT INTO int32_ values(-2147483648, 2147483647);
Expand All @@ -16,3 +18,47 @@ ERROR 22003: Out of range[-9223372036854775807, 9223372036854775807] for column
INSERT INTO int64_ values(-9223372036854775806, 9223372036854775808);
ERROR 22003: Out of range value for column 'c_min' at row 1
DROP TABLE int64_;
create table t1 (
value64 bigint not null,
value32 integer not null
);
insert into t1 values(9223372036854775806, 1);
insert into t1 values(9223372036854775807, 2);
insert into t1 values(-9223372036854775806, 2);
select * from t1;
value64 value32
9223372036854775806 1
9223372036854775807 2
-9223372036854775806 2
select * from t1 where value64= 9223372036854775807;
value64 value32
9223372036854775807 2
select * from t1 where value64= -9223372036854775806;
value64 value32
-9223372036854775806 2
select * from t1 where value64 between 9223372036854775806 and 9223372036854775807;
value64 value32
9223372036854775806 1
9223372036854775807 2
drop table t1;
create table txxx(a double);
insert into txxx values(1.79769313486231570814527423731704357e+308);
insert into txxx values(-1.79769313486231570814527423731704357e+308);
select * from txxx;
a
1.7976931348623157e308
-1.7976931348623157e308
select * from txxx where a = -1.7976931348623157e308;
a
-1.7976931348623157e308
select * from txxx where a = 1.7976931348623157e308;
a
1.7976931348623157e308
select * from txxx where a between 1.7976931348623157e308 and 1.7976931348623157e308;
a
1.7976931348623157e308
select * from txxx where a between -1.7976931348623157e308 and -1.7976931348623157e308;
a
-1.7976931348623157e308
drop table txxx;
DROP DATABASE signed_boundary;
29 changes: 29 additions & 0 deletions mysql-test/suite/tianmu/t/signed_boundary.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
DROP DATABASE IF EXISTS signed_boundary;
--enable_warnings

CREATE DATABASE signed_boundary;
USE signed_boundary;
# int32 limit
CREATE TABLE int32_(c_max int, c_min int) engine = tianmu;
INSERT INTO int32_ values(-2147483647, 2147483647);
Expand All @@ -25,3 +27,30 @@ INSERT INTO int64_ values(-9223372036854775807, 9223372036854775807);
--error 1264
INSERT INTO int64_ values(-9223372036854775806, 9223372036854775808);
DROP TABLE int64_;

# fix issue #1344, select * from t where col = 9223372036854775807,1.797693134862315708e+308, -1.797693134862315708e+308
create table t1 (
value64 bigint not null,
value32 integer not null
);

insert into t1 values(9223372036854775806, 1);
insert into t1 values(9223372036854775807, 2);
insert into t1 values(-9223372036854775806, 2);
select * from t1;
select * from t1 where value64= 9223372036854775807;
select * from t1 where value64= -9223372036854775806;
select * from t1 where value64 between 9223372036854775806 and 9223372036854775807;
drop table t1;

create table txxx(a double);
insert into txxx values(1.79769313486231570814527423731704357e+308);
insert into txxx values(-1.79769313486231570814527423731704357e+308);
select * from txxx;
select * from txxx where a = -1.7976931348623157e308;
select * from txxx where a = 1.7976931348623157e308;
select * from txxx where a between 1.7976931348623157e308 and 1.7976931348623157e308;
select * from txxx where a between -1.7976931348623157e308 and -1.7976931348623157e308;
drop table txxx;

DROP DATABASE signed_boundary;
Loading

0 comments on commit 478e705

Please sign in to comment.