-
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
expression: fix different types compare error #21338
expression: fix different types compare error #21338
Conversation
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
…field's type is typebit
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
Please follow PR Title Format:
Or if the count of mainly changed packages are more than 3, use
|
/run-all-tests |
/run-all-tests |
/rebuild |
/run-all-tests |
1 similar comment
/run-all-tests |
PTAL @wshwsh12 |
expression/builtin.go
Outdated
if fun, ok := res.(*ScalarFunction); (ok && fun.FuncName.L == ast.Cast) || res.GetType().Tp == mysql.TypeBit { | ||
if evalType == types.ETInt || evalType == types.ETReal { | ||
lfg, rfg := args[0].GetType().Flag, args[1].GetType().Flag | ||
// set signedFlag to 0 when bit convert explicitly or implicitly to int or real |
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.
I can't understand the logic. In the case, all evalType.flag don't contain UnsignedFlag, I think. Could you provide an example?
drop table if exists t;
create table t(a bit(64), b double);
insert into t values(-21172, -11623);
select * from t where a < b;
I have a try, only add builtin_cast.goL487 and builtin_cast_vec.goL111, it also works. Is there any negligence in what I thought?
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.
I removed builtin.goL173,it not work,for this case i see the step:
1.Invoke GetAccurateCmpType() output ETReal
2.Invoke newBaseBuiltinFuncWithTp()
in this method the param a will produce the scalarFunction named cast,retFlag=160,arg's retFlag=32 by WrapWithCastAsReal()
so in builtin_cast_vec.goL111 the unsignedArgs0=true,the a will change to uint.
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.
Why the flag for column a is 32..? It doesn't has the unsigned flag when creating table.
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.
If cast a as double explicitly, it works...
[tidb]> select * from t where cast(a as double) < b;
+----------+--------+
| a | b |
+----------+--------+
| �������L | -11623 |
+----------+--------+
1 row in set (5.925 sec)
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.
in ddl_api.goL537 invoke col.Flag |= mysql.UnsignedFlag when create table,
you mean i should't change retFlag in generateRetFlag, but cast bit to double?
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.
I have a try in mysql8.0.22.. So the behavior in tidb is right? It maybe a bug in mysql8.0.21 and the previous version?
MySQL [test]> select version();
+-----------+
| version() |
+-----------+
| 8.0.22 |
+-----------+
1 row in set (0.000 sec)
MySQL [test]> drop table if exists t;
Query OK, 0 rows affected (0.006 sec)
MySQL [test]> create table t(a bit(64), b double);
Query OK, 0 rows affected (0.009 sec)
MySQL [test]> insert into t values(-21172, -11623);
Query OK, 1 row affected (0.002 sec)
MySQL [test]> select * from t where a < b;
Empty set (0.000 sec)
But in mysql8.0.21,
MySQL [test]> select version();
+-----------+
| version() |
+-----------+
| 8.0.21 |
+-----------+
1 row in set (0.000 sec)
MySQL [test]> drop table if exists t;
Query OK, 0 rows affected (0.007 sec)
MySQL [test]> create table t(a bit(64), b double);
Query OK, 0 rows affected (0.008 sec)
MySQL [test]> insert into t values(-21172, -11623);
Query OK, 1 row affected (0.001 sec)
MySQL [test]> select * from t where a < b;
+----------+--------+
| a | b |
+----------+--------+
| �������L | -11623 |
+----------+--------+
1 row in set (0.000 sec)
/run-all-test |
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.
Rest LGTM
Please resolve conflicts. |
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
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.
Please resolve conflicts.
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 |
/run-all-tests |
What problem does this PR solve?
Issue Number: close #20128
Problem Summary:
What is changed and how it works?
What's Changed:
fix different types compare error
How it Works:
Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Release note