pingcap / mysql-tester

A Golang implementation of MySQL Test Framework
Apache License 2.0
61 stars 62 forks source link

fix comparison between NULL and empty string "" #108

Closed tiancaiamao closed 11 months ago

tiancaiamao commented 11 months ago
create table t (a int, b datetime, c varchar(255)) partition by range columns (a,b,c)(partition p1 values less than (-2147483648,'0000-00-00',""),partition p2 values less than (10,'2022-01-01',"Wow"),partition p3 values less than (11,'2022-01-01',MAXVALUE),partition p4 values less than (MAXVALUE,'2022-01-01',"Wow"));

set @@sql_mode = '';

insert into t values (-2147483648,'0000-00-00',null);
insert into t values (-2147483648,'0000-00-00',"");

--sorted_result
select * from t where a < 2;

The result is unstable even with --sorted_result, caused by a bug.

For NULL and empty string "", we compare them using bytes.Compare() and get result 0, that's incorrect.

Defined2014 commented 11 months ago

/cc @bb7133