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

cast string as real has different behaivor between tiflash and tikv/tidb. #3475

Closed
LittleFall opened this issue Nov 18, 2021 · 1 comment · Fixed by #3681
Closed

cast string as real has different behaivor between tiflash and tikv/tidb. #3475

LittleFall opened this issue Nov 18, 2021 · 1 comment · Fixed by #3681

Comments

@LittleFall
Copy link
Contributor

LittleFall commented Nov 18, 2021

create table t(a char(5));
alter table t set tiflash replica 1;
insert into t values ('0x01');

tiflash

set tidb_enforce_mpp=1;  -- let calculation push down to tiflash.
select cast(a as real) from t;
+-----------------+
| cast(a as real) |
+-----------------+
|               1 |
+-----------------+
1 row in set (0.01 sec)

tidb

set tidb_enforce_mpp=0;
select cast(a as real) from t;
+-----------------+
| cast(a as real) |
+-----------------+
|               0 |
+-----------------+
1 row in set, 1 warning (0.01 sec)
show warnings;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: '0x01' |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

tikv

mysql> select /*+ read_from_storage(tikv[t]) */ * from t where cast(a as real) = 0;
+------+
| a    |
+------+
| 0x01 |
+------+
1 row in set, 1 warning (0.00 sec)

mysql> show warnings;
+---------+------+--------------------------------------------------------------+
| Level   | Code | Message                                                      |
+---------+------+--------------------------------------------------------------+
| Warning | 1292 | evaluation failed: Truncated incorrect INTEGER value: '0x01' |
+---------+------+--------------------------------------------------------------+
1 row in set (0.00 sec)

version: v5.3.0

@LittleFall
Copy link
Contributor Author

by the way, cast string as int doesn't have this issue.

set tidb_enforce_mpp=1;
select cast(a as unsigned) from t;
+---------------------+
| cast(a as unsigned) |
+---------------------+
|                   0 |
+---------------------+
1 row in set (0.01 sec)

@fuzhe1989 fuzhe1989 added type/bug The issue is confirmed as a bug. severity/major labels Nov 18, 2021
ti-chi-bot added a commit that referenced this issue Apr 15, 2022
ti-chi-bot added a commit that referenced this issue Jun 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants