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

Casting integer with display width to string results in truncation #56462

Closed
dveeden opened this issue Oct 7, 2024 · 1 comment · Fixed by #56463
Closed

Casting integer with display width to string results in truncation #56462

dveeden opened this issue Oct 7, 2024 · 1 comment · Fixed by #56463
Labels
compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) severity/moderate type/bug The issue is confirmed as a bug. type/compatibility

Comments

@dveeden
Copy link
Contributor

dveeden commented Oct 7, 2024

Bug Report

1. Minimal reproduce step (Required)

DROP TABLE IF EXISTS test.t;
CREATE TABLE test.t (id bigint(11) UNSIGNED PRIMARY KEY);
INSERT INTO test.t VALUES (1234567890123456);
SELECT IFNULL(id, 'abcdef') FROM test.t;

2. What did you expect to see? (Required)

MySQL:

mysql-9.0.1> DROP TABLE IF EXISTS test.t;
Query OK, 0 rows affected (0.02 sec)

mysql-9.0.1> CREATE TABLE test.t (id bigint(11) UNSIGNED PRIMARY KEY);
Query OK, 0 rows affected, 1 warning (0.02 sec)

mysql-9.0.1> INSERT INTO test.t VALUES (1234567890123456);
Query OK, 1 row affected (0.00 sec)

mysql-9.0.1> SELECT IFNULL(id, 'abcdef') FROM test.t;
+----------------------+
| IFNULL(id, 'abcdef') |
+----------------------+
| 1234567890123456     |
+----------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

TiDB:

mysql-8.0.11-TiDB-v8.3.0> DROP TABLE IF EXISTS test.t;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql-8.0.11-TiDB-v8.3.0> CREATE TABLE test.t (id bigint(11) UNSIGNED PRIMARY KEY);
Query OK, 0 rows affected (0.05 sec)

mysql-8.0.11-TiDB-v8.3.0> INSERT INTO test.t VALUES (1234567890123456);
Query OK, 1 row affected (0.00 sec)

mysql-8.0.11-TiDB-v8.3.0> SELECT IFNULL(id, 'abcdef') FROM test.t;
+----------------------+
| IFNULL(id, 'abcdef') |
+----------------------+
| 12345678901          |
+----------------------+
1 row in set, 1 warning (0.00 sec)

mysql-8.0.11-TiDB-v8.3.0> SHOW WARNINGS;
+---------+------+------------------------------------------+
| Level   | Code | Message                                  |
+---------+------+------------------------------------------+
| Warning | 1406 | Data Too Long, field len 11, data len 16 |
+---------+------+------------------------------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

  • v8.3.0
  • v7.5.1

Related

This is similar to #44213 but for a different set of types.

This is related to #44786

@dveeden dveeden added type/bug The issue is confirmed as a bug. type/compatibility compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) labels Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compatibility-mysql8 This is a compatibility issue with MySQL 8.0(but NOT 5.7) severity/moderate type/bug The issue is confirmed as a bug. type/compatibility
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants