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

Update RESTORE behaviour for LIKE operator for CS_AI collation #3296

Conversation

ahmed-shameem
Copy link
Contributor

@ahmed-shameem ahmed-shameem commented Dec 21, 2024

Description

We introduced the support for LIKE operator for AI collations for Latin characters from versions 15.7 and 16.3 onwards. We use function remove_accents_internal to remove accents from the characters to find the base character. To improve the performance further, we introduced a cached version of remove_accents_internal function named remove_accents_internal_using_cache from 15.8 and 16.4 onwards.

In cases where there is CHECK constraint in the table definition for CS_AI, we observed that after upgrade from any version before 15.8 to 16.latest, the INSERT was failing on the table as another call to remove_accents_internal_using_cache was getting added on top of current node during restore. This issue is only observed for CS_AI as we do not modify the LIKE operator whereas for CI_AI we modify LIKE to ILIKE and BETWEEN operators.

We fix this issue by checking whether the incoming LIKE operator is for CS_AI. If yes, then we update the collation information for the OpExpr for that node and return from there directly. In this way, during restore we won't go in the code path where we add extra call to remove_accents_internal* on already modified node.

Issues Resolved

BABEL-5471
Cherry-picked from: 3fe245b3a16b47ddc05642f23c26a238f7641a04

Signed-off-by: Shameem Ahmed [email protected]

Test Scenarios Covered

  • Use case based -

  • Boundary conditions -

  • Arbitrary inputs -

  • Negative test cases -

  • Minor version upgrade tests -

  • Major version upgrade tests -

  • Performance tests -

  • Tooling impact -

  • Client tests -

Check List

  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is under the terms of the Apache 2.0 and PostgreSQL licenses, and grant any person obtaining a copy of the contribution permission to relicense all or a portion of my contribution to the PostgreSQL License solely to contribute all or a portion of my contribution to the PostgreSQL open source project.

For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 12445356832

Details

  • 2 of 11 (18.18%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.01%) to 74.851%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contrib/babelfishpg_tsql/src/collation.c 1 3 33.33%
contrib/babelfishpg_common/src/collation.c 1 8 12.5%
Totals Coverage Status
Change from base Build 12434009047: -0.01%
Covered Lines: 46566
Relevant Lines: 62212

💛 - Coveralls

@ahmed-shameem ahmed-shameem changed the title Update RESTORE behaviour for LIKE operator for CS_AI collation (#3207) Update RESTORE behaviour for LIKE operator for CS_AI collation Dec 21, 2024
Copy link
Contributor

@jsudrik jsudrik left a comment

Choose a reason for hiding this comment

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

Cherry pick from another branch. Approved.

@jsudrik jsudrik merged commit a692763 into babelfish-for-postgresql:BABEL_5_X_DEV Dec 23, 2024
44 checks passed
pranavJ23 pushed a commit to pranavJ23/babelfish_extensions that referenced this pull request Jan 6, 2025
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