Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix comparison between NULL and empty string "" #108

Merged
merged 1 commit into from
Oct 8, 2023

Conversation

tiancaiamao
Copy link
Contributor

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.

Copy link
Member

@YangKeao YangKeao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@Defined2014
Copy link
Contributor

/cc @bb7133

Copy link
Member

@bb7133 bb7133 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bb7133 bb7133 merged commit f3b5548 into pingcap:master Oct 8, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants