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

CastIntAsString did not work in some cases #44786

Closed
xhebox opened this issue Jun 19, 2023 · 0 comments · Fixed by #44787
Closed

CastIntAsString did not work in some cases #44786

xhebox opened this issue Jun 19, 2023 · 0 comments · Fixed by #44787

Comments

@xhebox
Copy link
Contributor

xhebox commented Jun 19, 2023

Bug Report

Please answer these questions before submitting your issue. Thanks!

图片

cast(int(1) as char) will set char.flen = 1, which may truncate integers. We set char.flen = 11 as mysql if we are casting integers.

1. Minimal reproduce step (Required)

CREATE TABLE `t` (
  `id` int(11) DEFAULT NULL,
   `var` int(1) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;
insert into t values(1,-1);
select id, var, cast(var as char) from t;

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

id | var | cast(var as char)
-- | -- | --
1 | -1 | -1

3. What did you see instead (Required)

id | var | cast(var as char)
-- | -- | --
1 | -1 | -

4. What is your TiDB version? (Required)

v6.5.2

@xhebox xhebox self-assigned this Jun 19, 2023
@ti-chi-bot ti-chi-bot bot added may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. labels Jun 19, 2023
@xhebox xhebox removed may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. labels Jun 19, 2023
ti-chi-bot bot pushed a commit that referenced this issue Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants