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

release-23.1: tree: apply functions to TEXT expressions compared with the @@ operator #100918

Merged
merged 2 commits into from
Apr 7, 2023

Conversation

msirek
Copy link
Contributor

@msirek msirek commented Apr 7, 2023

Backport:

Please see individual PRs for details.

/cc @cockroachdb/release

Release justification: low risk backport for incorrect results with the @@ operator

Mark Sirek and others added 2 commits April 7, 2023 08:21
The TSQuery and TSVector "matches" operator "@@" returns different results
on CRDB vs. Postgres when one of the arguments is a TEXT expression.
CRDB always applies a CAST, and only for constants. The rules at
https://www.postgresql.org/docs/current/textsearch-intro.html#TEXTSEARCH-MATCHING
specify:
> The form text @@ tsquery is equivalent to to_tsvector(x) @@ y.
> The form text @@ text is equivalent to to_tsvector(x) @@ plainto_tsquery(y).

This PR adds these implicit function calls in these "matches" comparison
expressions during type checking as well as a cast of TEXT to TSQuery
when the other argument is a TSVector, which allows variable expressions
to be handled.

Fixes cockroachdb#98875
Fixes cockroachdb#98804

Release note (bug fix): This allows the text search @@ ("matches")
operator to work with variable expressions and fixes incorrect results
when one of the arguments is a TEXT expression and the other argument is
a TEXT or TSQuery expression.
@msirek msirek requested review from mgartner, DrewKimball and a team April 7, 2023 15:23
@msirek msirek requested a review from a team as a code owner April 7, 2023 15:23
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@msirek
Copy link
Contributor Author

msirek commented Apr 7, 2023

release backport request here

@mgartner mgartner changed the title tree: apply functions to TEXT expressions compared with the @@ operator release-23.1: tree: apply functions to TEXT expressions compared with the @@ operator Apr 7, 2023
Copy link
Collaborator

@mgartner mgartner left a comment

Choose a reason for hiding this comment

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

Thanks for backporting! LGTM

@msirek
Copy link
Contributor Author

msirek commented Apr 7, 2023

TFTR!

@msirek msirek merged commit 7a8b969 into cockroachdb:release-23.1 Apr 7, 2023
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.

3 participants