-
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
CONCAT negative decimal value is chopping last digit in TiDB #29417
Comments
TIDB mysql> select concat(f1),f1 from t1;
Field 1: `concat(f1)`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: utf8mb4_bin (46)
Length: 28
Max_length: 7
Decimals: 31
Flags:
Field 2: `f1`
Catalog: `def`
Database: `test`
Table: `t1`
Org_table: `t1`
Type: NEWDECIMAL
Collation: binary (63)
Length: 7
Max_length: 8
Decimals: 5
Flags: NUM
+------------+----------+
| concat(f1) | f1 |
+------------+----------+
| -0.1234 | -0.12345 |
+------------+----------+
1 row in set, 1 warning (0.00 sec)
mysql> select concat(cast(f1 as char)) from t1;
Field 1: `concat(cast(f1 as char))`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: MEDIUM_BLOB
Collation: utf8mb4_bin (46)
Length: 67108860
Max_length: 8
Decimals: 31
Flags:
+--------------------------+
| concat(cast(f1 as char)) |
+--------------------------+
| -0.12345 |
+--------------------------+
1 row in set (0.00 sec)
Mysql 8.0.26 mysql> select concat(f1),f1 from t1;select concat(f1),f1 from t1;
Field 1: `concat(f1)`
Catalog: `def`
Database: ``
Table: ``
Org_table: ``
Type: VAR_STRING
Collation: utf8mb4_general_ci (45)
Length: 28
Max_length: 8
Decimals: 31
Flags:
Field 2: `f1`
Catalog: `def`
Database: `hchwang`
Table: `t1`
Org_table: `t1`
Type: NEWDECIMAL
Collation: binary (63)
Length: 7
Max_length: 8
Decimals: 5
Flags: NUM
+------------+----------+
| concat(f1) | f1 |
+------------+----------+
| -0.12345 | -0.12345 |
+------------+----------+
1 row in set (0.04 sec) |
I think this is critical? Decimal is precison math, and the scenario is not unexpected for user-supplied queries. |
yes, and it affects all versions. |
Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label. |
k is decimal(8,8) |
THX. So according to the definition of |
Bug Report
1. Minimal reproduce step (Required)
2. What did you expect to see? (Required)
3. What did you see instead (Required)
4. What is your TiDB version? (Required)
The text was updated successfully, but these errors were encountered: