tidb icon indicating copy to clipboard operation
tidb copied to clipboard

expression: fix wrong flen from baseFunctionClass

Open joechenrh opened this issue 4 months ago • 6 comments

What problem does this PR solve?

Issue Number: close #56587

Problem Summary:

What changed and how does it work?

ro Previously, quoteFunctionClass may return type with flen = 0

https://github.com/pingcap/tidb/blob/f0b3bf0332ae33b0593f5f89ead872f71816cbd3/pkg/expression/builtin_string.go#L2899

And this type will be passed into LogicalUnionAll, which will result to a wrong type.

https://github.com/pingcap/tidb/blob/f0b3bf0332ae33b0593f5f89ead872f71816cbd3/pkg/planner/core/logical_plan_builder.go#L1586-L1591

Some other functions also have this problem, for example:

mysql> select elt(2, "123", cast('abcdefg' as char)) union all select "1234";
+----------------------------------------+
| elt(2, "123", cast('abcdefg' as char)) |
+----------------------------------------+
| abcd                                   |
| 1234                                   |
+----------------------------------------+
2 rows in set, 1 warning (0.00 sec)

Check List

Tests

  • [X] Unit test
  • [ ] Integration test
  • [ ] Manual test (add detailed scripts or steps below)
  • [ ] No need to test
    • [ ] I checked and no code files have been changed.

Side effects

  • [ ] Performance regression: Consumes more CPU
  • [ ] Performance regression: Consumes more Memory
  • [ ] Breaking backward compatibility

Documentation

  • [ ] Affects user behaviors
  • [ ] Contains syntax changes
  • [ ] Contains variable changes
  • [ ] Contains experimental features
  • [ ] Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

joechenrh avatar Oct 12 '24 06:10 joechenrh