-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
core: Fix confusing behaviors of FROM_BASE64 function in WHERE clause #28229
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
MySQL 5.7 and MySQL 8.0 behave differently here: mysql [localhost:5731] {msandbox} (test) > select * from t where from_base64('');
Empty set (0.00 sec)
mysql [localhost:5731] {msandbox} (test) > update t set a = 'def' where from_base64('');
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql [localhost:5731] {msandbox} (test) > select * from t where from_base64('invalidbase64');
Empty set (0.00 sec)
mysql [localhost:5731] {msandbox} (test) > update t set a = 'hig' where from_base64('invalidbase64');
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql [localhost:5731] {msandbox} (test) > select * from t where from_base64('test');
Empty set (0.00 sec)
mysql [localhost:5731] {msandbox} (test) > update t set a = 'xyz' where from_base64('test');
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql [localhost:5731] {msandbox} (test) > select * from t;
+------+
| a |
+------+
| abc |
+------+
1 row in set (0.01 sec) Versus: mysql [localhost:8024] {root} (test) > insert into t values('abc');
Query OK, 1 row affected (0.00 sec)
mysql [localhost:8024] {root} (test) > select * from t where from_base64('');
Empty set (0.00 sec)
mysql [localhost:8024] {root} (test) > update t set a = 'def' where from_base64('');
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql [localhost:8024] {root} (test) > select * from t where from_base64('invalidbase64');
Empty set (0.00 sec)
mysql [localhost:8024] {root} (test) > update t set a = 'hig' where from_base64('invalidbase64');
Query OK, 0 rows affected (0.00 sec)
Rows matched: 0 Changed: 0 Warnings: 0
mysql [localhost:8024] {root} (test) > select * from t where from_base64('test');
Empty set, 1 warning (0.00 sec) <-- the warning is a truncated value
mysql [localhost:8024] {root} (test) > update t set a = 'xyz' where from_base64('test');
ERROR 1292 (22007): Truncated incorrect DOUBLE value: '\xB5\xEB-'
mysql [localhost:8024] {root} (test) > select * from t;
+------+
| a |
+------+
| abc |
+------+
1 row in set (0.00 sec) |
I tried in mysql 8.0.21,following: mysql> select * from t where from_base64(''); mysql> update t set a = 'def' where from_base64(''); mysql> select * from t where from_base64('invalidbase64'); mysql> update t set a = 'hig' where from_base64('invalidbase64'); mysql> select * from t where from_base64('test'); mysql> update t set a = 'xyz' where from_base64('test'); mysql> select * from t; mysql> select @@Version; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, I've updated the release note
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
This pull request has been accepted and is ready to merge. Commit hash: 85a9953
|
@@ -987,7 +987,10 @@ func (b *PlanBuilder) buildSelection(ctx context.Context, p LogicalPlan, where a | |||
for _, item := range cnfItems { | |||
if con, ok := item.(*expression.Constant); ok && con.DeferredExpr == nil && con.ParamMarker == nil { | |||
ret, _, err := expression.EvalBool(b.ctx, expression.CNFExprs{con}, chunk.Row{}) | |||
if err != nil || ret { | |||
if err != nil { | |||
return nil, errors.Trace(err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return error here may cause problems
update t set a = 'b' where ' ';
in tidb, it returns error, in MySQL it is ok.
ref #27954
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@zhaoxugang PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO the main question is that when convert err is present we should return err or return empty set?if return err maybe effect the user of tidb if return empty will confuse with actual return empty set.I need some advices
@xiongjiwei @yuqi1129 @morgo
What problem does this PR solve?
Issue Number: close #28154
Problem Summary:
What is changed and how it works?
Proposal: xxx
What's Changed:
How it Works:
Check List
Tests
Side effects
Documentation
Release note