Skip to content

Nested cast() clause outputs zero length #34901

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

Closed
Willendless opened this issue May 23, 2022 · 2 comments · Fixed by #61254
Closed

Nested cast() clause outputs zero length #34901

Willendless opened this issue May 23, 2022 · 2 comments · Fixed by #61254
Labels
severity/minor sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@Willendless
Copy link
Contributor

Bug Report

1. Minimal reproduce step (Required)

First open a mysql client with option --column-type-info, such as mysql --comments --column-type-info --host 127.0.0.1 --port 3306 -u root -p.

Then by executing a statement with nested CAST(), such as select cast(cast(1 as binary) as binary);, it can be found that the length field is wrong.

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

mysql> select cast(cast(1 as binary) as binary);
Field   1:  `cast(cast(1 as binary) as binary)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  binary (63)
Length:     2
Max_length: 1
Decimals:   31
Flags:      BINARY


+----------------------------------------------------------------------+
| cast(cast(1 as binary) as binary)                                    |
+----------------------------------------------------------------------+
| 0x31                                                                 |
+----------------------------------------------------------------------+
1 row in set (0.00 sec)

3. What did you see instead (Required)

mysql> select cast(cast(1 as binary) as binary);
Field   1:  `cast(cast(1 as binary) as binary)`
Catalog:    `def`
Database:   ``
Table:      ``
Org_table:  ``
Type:       VAR_STRING
Collation:  binary (63)
Length:     0
Max_length: 1
Decimals:   31
Flags:      NOT_NULL BINARY


+----------------------------------------------------------------------+
| cast(cast(1 as binary) as binary)                                    |
+----------------------------------------------------------------------+
| 0x31                                                                 |
+----------------------------------------------------------------------+
1 row in set (0.00 sec)

4. What is your TiDB version? (Required)

| Release Version: v6.1.0-alpha-490-g9d0d45981
Edition: Community
Git Commit Hash: 9d0d459816705e60205d074f3183c8773086e2b0
Git Branch: master
UTC Build Time: 2022-05-23 14:59:53
GoVersion: go1.18.2
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false |
@Willendless Willendless added the type/bug The issue is confirmed as a bug. label May 23, 2022
@Willendless Willendless changed the title Nested cast clause outputs zero length Nested cast() clause outputs zero length May 23, 2022
@zanmato1984
Copy link
Contributor

Does this bug has anything to do with this one #34823 ?

@Willendless
Copy link
Contributor Author

Does this bug has anything to do with this one #34823 ?

Oh, this is a separate one and is not relevant to #34823.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
severity/minor 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.

3 participants