pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Peter Eisentraut <peter@eisentraut.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make dmetaphone collation-aware
Date: Mon, 12 Jan 2026 07:36:34 +0000
Message-ID: <E1vfCTZ-006C3J-1e@gemulon.postgresql.org> (raw)

Make dmetaphone collation-aware

The dmetaphone() SQL function internally upper-cases the argument
string.  It did this using the toupper() function.  That way, it has a
dependency on the global LC_CTYPE locale setting, which we want to get
rid of.

The "double metaphone" algorithm specifically supports the "C with
cedilla" letter, so just using ASCII case conversion wouldn't work.

To fix that, use the passed-in collation and use the str_toupper()
function, which has full awareness of collations and collation
providers.

Note that this does not change the fact that this function only works
correctly with single-byte encodings.  The change to str_toupper()
makes the case conversion multibyte-enabled, but the rest of the
function is still not ready.

Reviewed-by: Jeff Davis <pgsql@j-davis.com>
Discussion: https://www.postgresql.org/message-id/108e07a2-0632-4f00-984d-fe0e0d0ec726%40eisentraut.org

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/e39ece0343fef7bf5a689d75bbafff9386e6e3da

Modified Files
--------------
contrib/fuzzystrmatch/dmetaphone.c | 27 ++++++++++++++++-----------
1 file changed, 16 insertions(+), 11 deletions(-)



Message-ID: <E1vfCTZ-006C3J-1e@gemulon.postgresql.org>
Permalink:  ../E1vfCTZ-006C3J-1e@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1vfCTZ-006C3J-1e@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-committers@postgresql.org
  Cc: peter@eisentraut.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Make dmetaphone collation-aware
  In-Reply-To: <E1vfCTZ-006C3J-1e@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox