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 length error in union clause #29513

Closed
aytrack opened this issue Nov 5, 2021 · 2 comments · Fixed by #29563
Closed

cast length error in union clause #29513

aytrack opened this issue Nov 5, 2021 · 2 comments · Fixed by #29563
Assignees
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@aytrack
Copy link
Contributor

aytrack commented Nov 5, 2021

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

 select '123' union select cast(45678 as char);
 select '123' union select cast(45678 as char(5));
 select '123' union select cast(45678 as char(2));

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

mysql> select '123' union select cast(45678 as char);
Field   1:  `123`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8mb4_general_ci (45)
Length:     24
Max_length: 5
Decimals:   0
Flags:


+-------+
| 123   |
+-------+
| 123   |
| 45678 |
+-------+
2 rows in set (0.07 sec)

3. What did you see instead (Required)

mysql>  select '123' union select cast(45678 as char);
Field   1:  `123`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8mb4_bin (46)
Length:     12
Max_length: 3
Decimals:   31
Flags:


+------+
| 123  |
+------+
| 456  |
| 123  |
+------+
2 rows in set, 1 warning (0.00 sec)

MySQL > show warnings;
+---------+------+----------------------------------------+
| Level   | Code | Message                                |
+---------+------+----------------------------------------+
| Warning | 1406 | Data Too Long, field len 3, data len 5 |
+---------+------+----------------------------------------+

mysql>  select '123' union select cast(45678 as char(5));
Field   1:  `123`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  utf8mb4_bin (46)
Length:     20
Max_length: 5
Decimals:   31
Flags:


+-------+
| 123   |
+-------+
| 123   |
| 45678 |
+-------+
2 rows in set (0.00 sec)

4. What is your TiDB version? (Required)

release-4.0, release-5.0, release-5.1, release-5.2, release-5.3, master

@aytrack aytrack added type/bug The issue is confirmed as a bug. sig/execution SIG execution severity/critical affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. labels Nov 5, 2021
@fuzhe1989
Copy link
Contributor

/assign @wshwsh12

@github-actions
Copy link

Please check whether the issue should be labeled with 'affects-x.y' or 'fixes-x.y.z', and then remove 'needs-more-info' label.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-4.0 This bug affects 4.0.x versions. affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. severity/major sig/execution SIG execution type/bug The issue is confirmed as a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants