expression: fix enum and set type expression in where clause#22785
Merged
ti-srebot merged 5 commits intopingcap:masterfrom Feb 19, 2021
Merged
expression: fix enum and set type expression in where clause#22785ti-srebot merged 5 commits intopingcap:masterfrom
ti-srebot merged 5 commits intopingcap:masterfrom
Conversation
Signed-off-by: lzmhhh123 <lzmhhh123@gmail.com>
Signed-off-by: lzmhhh123 <lzmhhh123@gmail.com>
Contributor
Author
|
/build |
XuHuaiyu
reviewed
Feb 18, 2021
expression/expression.go
Outdated
| case mysql.TypeEnum, mysql.TypeSet: | ||
| fVal = float64(len(sVal)) | ||
| // Enum and Set type value to bool is always true. | ||
| fVal = 1 |
Contributor
There was a problem hiding this comment.
Any reference in the mysql manual?
Contributor
There was a problem hiding this comment.
mysql> create table t(a enum("a", "b", "c"));
Query OK, 0 rows affected (0.02 sec)
mysql> insert into t values('a'),('b');
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> set @@sql_mode='';
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> insert into t values("");
Query OK, 1 row affected, 1 warning (0.00 sec)
mysql> select * from t;
+------+
| a |
+------+
| a |
| b |
| |
+------+
3 rows in set (0.00 sec)
mysql> select * from t where a;
+------+
| a |
+------+
| a |
| b |
+------+
2 rows in set (0.00 sec)
Closed
XuHuaiyu
reviewed
Feb 19, 2021
expression/expression.go
Outdated
| case mysql.TypeSet, mysql.TypeEnum: | ||
| fVal = float64(len(sVal)) | ||
| if fVal == 0 { | ||
| // Check whether "" in set type. |
Contributor
There was a problem hiding this comment.
change this comment to:
The elements listed in the column specification are assigned index numbers, beginning with 1. The index value of the empty string error value (distinguish from a “normal” empty string) is 0. Thus we need to check whether it's an empty string error value when `fVal==0`
Signed-off-by: lzmhhh123 <lzmhhh123@gmail.com>
ti-srebot
approved these changes
Feb 19, 2021
Contributor
Author
|
/merge |
Contributor
|
Your auto merge job has been accepted, waiting for:
|
Contributor
|
/run-all-tests |
ti-srebot
pushed a commit
to ti-srebot/tidb
that referenced
this pull request
Feb 19, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
Contributor
|
cherry pick to release-4.0 in PR #22814 |
ti-srebot
pushed a commit
to ti-srebot/tidb
that referenced
this pull request
Feb 19, 2021
Signed-off-by: ti-srebot <ti-srebot@pingcap.com>
Contributor
|
cherry pick to release-5.0-rc in PR #22815 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Signed-off-by: lzmhhh123 lzmhhh123@gmail.com
What problem does this PR solve?
Issue Number: close #22717
What is changed and how it works?
How it Works:
Related changes
Check List
Tests
Release note