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

Builtin function ifnull() infers the wrong flen for param marker #38844

Closed
tangenta opened this issue Nov 2, 2022 · 1 comment · Fixed by #38845
Closed

Builtin function ifnull() infers the wrong flen for param marker #38844

tangenta opened this issue Nov 2, 2022 · 1 comment · Fixed by #38845
Assignees
Labels
affects-6.1 severity/moderate sig/execution SIG execution type/bug The issue is confirmed as a bug.

Comments

@tangenta
Copy link
Contributor

tangenta commented Nov 2, 2022

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists t;
create table t (c1 varchar(100), c2 varchar(128));
prepare pr1 from "insert into t values(ifnull(?,' '),ifnull(?,' '))";
set @a='1',@b=repeat('x', 80);
execute pr1 using @a,@b;

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

mysql> execute pr1 using @a,@b;
Query OK, 1 row affected (0.01 sec)

3. What did you see instead (Required)

mysql> execute pr1 using @a,@b;
ERROR 1406 (22001): Data too long for column 'c2' at row 1

4. What is your TiDB version? (Required)

8db7c3b

@tangenta tangenta added type/bug The issue is confirmed as a bug. severity/moderate labels Nov 2, 2022
@tangenta tangenta self-assigned this Nov 2, 2022
@tangenta
Copy link
Contributor Author

tangenta commented Nov 2, 2022

The root cause is that ifnull() infers the flen to 23(the max REAL length) even if the type is "ETString", which is apparently incorrect.

resultFieldType.SetFlen(maxlen(lhs.GetFlen(), rhs.GetFlen()))

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

2 participants