Skip to content

Conversation

@uros-db
Copy link
Contributor

@uros-db uros-db commented Aug 12, 2024

What changes were proposed in this pull request?

Fix the following string expressions to handle surrogate pairs properly:

  • StringInstr
  • StringLocate

The issue has to do with counting surrogate pairs, which are single Unicode code points (and single UTF-8 characters), but are represented using 2 characters in UTF-16 (Java String).

Example of incorrect results (under UNICODE collation, but similar issues are noted for all ICU collations):

StringInstr("😄a", "a") // returns: 3 (incorrect), instead of: 2 (correct)
StringLocate("a", "😄a") // returns: 3 (incorrect), instead of: 2 (correct)

Why are the changes needed?

Currently, some string expressions are giving wrong results when working with surrogate pairs.

Does this PR introduce any user-facing change?

Yes, these expressions will now work properly with surrogate pairs: instr, locate/position.

How was this patch tested?

New tests in CollationSupportSuite.

Was this patch authored or co-authored using generative AI tooling?

Yes.

@github-actions github-actions bot added the SQL label Aug 12, 2024
Copy link
Contributor Author

@uros-db uros-db left a comment

Choose a reason for hiding this comment

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

all checks good, marking as ready for review

@cloud-fan
Copy link
Contributor

thanks, merging to master!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants