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

exec: fix LIKE handling for patterns like '%a%' #38911

Merged
merged 1 commit into from
Jul 16, 2019

Conversation

solongordon
Copy link
Contributor

GetLikeOperator was choosing the wrong operator when both the first and
last characters of the pattern were wildcards. I fixed this logic and
improved the unit tests to cover GetLikeOperator rather than just the
underlying operators.

While I was here I also added better handling for the case where there
are no wildcards, i.e. exact string matching.

Fixes #38888

Release note: None

GetLikeOperator was choosing the wrong operator when both the first and
last characters of the pattern were wildcards. I fixed this logic and
improved the unit tests to cover GetLikeOperator rather than just the
underlying operators.

While I was here I also added better handling for the case where there
are no wildcards, i.e. exact string matching.

Fixes cockroachdb#38888

Release note: None
@solongordon solongordon requested review from yuzefovich and a team July 16, 2019 20:42
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member

@jordanlewis jordanlewis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:lgtm:

Reviewed 2 of 2 files at r1.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @yuzefovich)

@solongordon
Copy link
Contributor Author

bors r+

Copy link
Member

@yuzefovich yuzefovich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @solongordon)


pkg/sql/exec/like_ops_test.go, line 78 at r1 (raw file):

		},
		{
			pattern:  "%e%",

We should test "mixed" cases like %e_ and _e%. It seems to me that such cases are not handled (or I'm not seeing it).

craig bot pushed a commit that referenced this pull request Jul 16, 2019
38908: exec: Fix type ambiguity error out for IN and NOT IN. r=jordanlewis a=rohany

A previous PR introduced this error, this PR fixes it and adds a regression test.

Release note: None

38911: exec: fix LIKE handling for patterns like '%a%' r=solongordon a=solongordon

GetLikeOperator was choosing the wrong operator when both the first and
last characters of the pattern were wildcards. I fixed this logic and
improved the unit tests to cover GetLikeOperator rather than just the
underlying operators.

While I was here I also added better handling for the case where there
are no wildcards, i.e. exact string matching.

Fixes #38888

Release note: None

Co-authored-by: Rohan Yadav <rohany@alumni.cmu.edu>
Co-authored-by: Solon Gordon <solon@cockroachlabs.com>
@craig
Copy link
Contributor

craig bot commented Jul 16, 2019

Build succeeded

@craig craig bot merged commit 5bff499 into cockroachdb:master Jul 16, 2019
@solongordon solongordon deleted the fix-like-wildcard-handling branch July 17, 2019 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

exec: LIKE broken for patterns which begin and end with wildcards
4 participants