statistics: fix "data too long" error when dumping stats from table with new collation data (#27033) #28757
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
cherry-pick #27033 to release-5.1-20211012
What problem does this PR solve?
Issue Number: close #27024
When storing a histogram for a new collation column, we store its collate key instead of the original value.
However (1) when loading the histogram into stats cache, we try to convert the bounds of the histogram to the
FieldType
of this column (2) the collate key of a value is usually longer than the original value.So when doing the type conversion, the value may exceed the
FieldType.Flen
, which caused the "Data Too Long" error.What is changed and how it works?
When loading stats from storage into stats cache, for
String
values, no longer convert them to theFieldType
of this column.Now we always convert them to
TypeBlob
to bypass length checks.Check List
Tests
Side effects
Documentation
Release note