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

fuzzystrmatch: fix crash and compatibility #82761

Merged
merged 1 commit into from
Jun 27, 2022

Conversation

jordanlewis
Copy link
Member

Closes #82640

Release note (bug fix): fix behavior of soundex function when passed
certain unicode inputs. Previously, certain unicode inputs could result
in crashes, errors or incorrect outputs.

Release note (bug fix): fix behavior of soundex function when passed
certain unicode inputs. Previously, certain unicode inputs could result
in crashes, errors or incorrect outputs.
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@jordanlewis
Copy link
Member Author

cc @mgoddard

@@ -39,12 +42,25 @@ func TestSoundex(t *testing.T) {
},
{
Source: "🌞",
Expected: "000",
Expected: "",
Copy link
Collaborator

Choose a reason for hiding this comment

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

why did this one change? it looks like PG returns 000 for it (binary d0303030)

},
{
Source: "😄 🐃 🐯 🕣 💲 🏜 👞 🔠 🌟 📌",
Expected: "",
},
{
Source: "zażółćx",
Expected: "Z200",
Copy link
Collaborator

Choose a reason for hiding this comment

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

PG returns just Z i think? (binary 5ac5c3c5)

},
{
Source: "K😋",
Expected: "K000",
Copy link
Collaborator

Choose a reason for hiding this comment

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

PG returns K00 (binary 4bd03030)

@jordanlewis
Copy link
Member Author

The differences you wrote don't materialize on the system I was testing on... what version are you testing on?

@rafiss
Copy link
Collaborator

rafiss commented Jun 13, 2022

rafiss=# select version();
                                                      version
-------------------------------------------------------------------------------------------------------------------
 PostgreSQL 14.2 on x86_64-apple-darwin21.3.0, compiled by Apple clang version 13.0.0 (clang-1300.0.29.30), 64-bit
(1 row)

rafiss=# select soundex('zażółćx');
 soundex
---------
 Z
(1 row)

rafiss=# select soundex('🌞');
 soundex
---------
 000
(1 row)

rafiss=# select soundex('K😋');
 soundex
---------
 K00
(1 row)

(and i captured the results using wireshark)

@jordanlewis
Copy link
Member Author

Here's what I get:


jordan=> select version();
                                                              version
-----------------------------------------------------------------------------------------------------------------------------------
 PostgreSQL 14.3 (Ubuntu 14.3-1.pgdg20.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, 64-bit
(1 row)

jordan=> select soundex('🌞');
 soundex
---------

(1 row)

jordan=> select soundex('K😋');
 soundex
---------
 K000
(1 row)

jordan=>

It sounds like this functionality just doesn't work consistently for UTF8:

image

@jordanlewis
Copy link
Member Author

BTW, I get this same output even in Postgres 12 (I upgraded to Postgres 14 to see if it would repro on your version)

Copy link
Collaborator

@rafiss rafiss left a comment

Choose a reason for hiding this comment

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

ah i see thanks for looking. lgtm then

@rafiss
Copy link
Collaborator

rafiss commented Jun 27, 2022

bors r+

@craig
Copy link
Contributor

craig bot commented Jun 27, 2022

Build succeeded:

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.

util/fuzzystrmatch: v22.2.0-alpha: index out of bounds
3 participants