Re: Collation & ctype method table, and extension hooks

Noah Misch <noah@leadboat.com>

From: Noah Misch <noah@leadboat.com>
To: Jeff Davis <pgsql@j-davis.com>
Cc: Andreas Karlsson <andreas@proxel.se>, pgsql-hackers@postgresql.org, Peter Eisentraut <peter@eisentraut.org>
Date: 2026-06-30T01:29:19Z
Lists: pgsql-hackers
On Wed, Jun 11, 2025 at 10:49:17PM -0700, Jeff Davis wrote:
> Attached v16.

> I plan to commit this soon after branching.

> Subject: [PATCH v16 1/4] Control ctype behavior internally with a method
>  table.
> 
> Previously, pattern matching and case mapping behavior branched based
> on the provider.
> 
> Refactor to use a method table, which is less error-prone and easier
> to hook.

This became refactor commit 5a38104.  In a UTF8 database, the commit changed
the behavior of:

  SELECT 'café' ILIKE 'caf_' COLLATE "C";

That query reports true in v18, false in v19.  I've copied Claude's whole
review for the commit to
https://docs.google.com/document/d/19_xKpKUQlY5N51qbfXyipXs3rqIYEC3qk5oaUDJ48YA/edit?tab=t.0.
Two of its other findings sound potentially important, but I didn't verify
them.

nm



Commits

  1. Remove provider field from pg_locale_t.

  2. Control ctype behavior internally with a method table.

  3. Control collation behavior with a method table.

  4. Move code for collation version into provider-specific files.

  5. Refactor string case conversion into provider-specific files.

  6. Move check for ucol_strcollUTF8 to pg_locale_icu.c

  7. Perform provider-specific initialization in new functions.

  8. Refactor the code to create a pg_locale_t into new function.