util/ranger: support use like
to build range for new collation columns | tidb-test=pr/2247 (#48522)
#52598
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.
This is an automated cherry-pick of #48522
What problem does this PR solve?
Issue Number: close #48181 close #49138
What is changed and how it works?
builder
inpkg/util/ranger/points.go
, we provide a new parameterconvertToSortKey bool
. If it'strue
, we can build ranges for new collation columns innewBuildFromPatternLike
. The user ofbuilder
should specify if it should convert the string values to the sort key or keep the original value.KeyWithoutTrimRightSpace()
and then +1 to calculate the end key. TheKeyWithoutTrimRightSpace
prevents regression compared to the existing behavior for binary collations. For other details, please see the comments.pointsConvertToSortKey
, andpointConvertToSortKey
to do the conversion work.convertPoint
happens before converting to the sort key. Specifically, it's called inpoints2Ranges
,appendPoints2Ranges
, andpoints2TableRanges
, which are right afterbuild()
. Now we try to keep this logic unchanged. So we do aconvertPoint
inside these two functions before the conversion to the sort key.newTp
into thebuilder
. Therefore I merged it with the previousCollator
parameter for thebuild()
.convertPoint
is not removed because it's needed to handle non-string cases. In such a case, we need to make the existingconvertPoint
able to correctly handle the new sort key cases. Specifically, we need to use the binary collation instead of the collation of the column for theFieldType
passed intoconvertPoint
.convertStringFTToBinaryCollate()
to reduce some repeated code.pkg/util/ranger/checker.go
, remove the limitation that we can't useLIKE
function on new collation column to build ranges.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.