Re: Collation & ctype method table, and extension hooks
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: Andreas Karlsson <andreas@proxel.se>, pgsql-hackers@postgresql.org
Date: 2024-10-09T23:27:41Z
Lists: pgsql-hackers
Attachments
- v6-0001-Move-ICU-specific-code-from-pg_locale.c-into-pg_l.patch (text/x-patch) patch v6-0001
- v6-0002-Move-libc-specific-code-from-pg_locale.c-into-pg_.patch (text/x-patch) patch v6-0002
- v6-0003-Refactor-the-code-to-create-a-pg_locale_t-into-ne.patch (text/x-patch) patch v6-0003
- v6-0004-Perform-provider-specific-initialization-code-in-.patch (text/x-patch) patch v6-0004
- v6-0005-Control-collation-behavior-with-a-method-table.patch (text/x-patch) patch v6-0005
- v6-0006-Control-case-mapping-behavior-with-a-method-table.patch (text/x-patch) patch v6-0006
- v6-0007-Control-ctype-behavior-with-a-method-table.patch (text/x-patch) patch v6-0007
- v6-0008-Remove-provider-field-from-pg_locale_t.patch (text/x-patch) patch v6-0008
- v6-0009-Make-provider-data-in-pg_locale_t-an-opaque-point.patch (text/x-patch) patch v6-0009
- v6-0010-Don-t-include-ICU-headers-in-pg_locale.h.patch (text/x-patch) patch v6-0010
- v6-0011-Introduce-hooks-for-creating-custom-pg_locale_t.patch (text/x-patch) patch v6-0011
On Fri, 2024-10-04 at 15:24 +0200, Andreas Karlsson wrote:
> On 9/27/24 12:30 AM, Jeff Davis wrote:
> > The attached patch series refactors the collation and ctype
> > behavior
> > into method tables, and provides a way to hook the creation of a
> > pg_locale_t so that an extension can create any kind of method
> > table it
> > wants.
>
> Great! I had been planning to do this myself so great to see that you
> already did it before me. Will take a look at this work later.
Attached v6 with significant improvements, and should be easier to
review.
This removes all runtime branching for collation & ctype operations; I
even removed the "provider" field of pg_locale_t to be sure.
This series gets us to the point where it's possible (though not easy)
to completely replace the provider at runtime without missing any
capabilities.
There are many things that would be nice to improve further, such as:
* Have a CREATE LOCALE PROVIDER command and make "provider" an Oid
rather than a char ('b'/'i'/'c'). The v6 patches brings us close to
this point, but I'm not sure if we want to go this far in v18.
* Need an actual extension to prove that it works.
* Clean up the way versions are handled.
* Do we want to provide support for changing the provider at initdb
time?
* The catalog representation is not very clean or general. The libc
provider allows collation and ctype to be set separately, but they
control the environment variables, too. ICU has rules, which are
specific to ICU.
* I've tested the performance for collation and case mapping, and there
does not appear to be any overhead. I didn't observe any performance
overhead for ctype either, but I think I need a more strenuous test to
be sure.
Regards,
Jeff Davis
Commits
-
Remove provider field from pg_locale_t.
- 8af0d0ab01b4 19 (unreleased) landed
-
Control ctype behavior internally with a method table.
- 5a38104b3642 19 (unreleased) landed
-
Control collation behavior with a method table.
- a2f17f004d22 18.0 landed
-
Move code for collation version into provider-specific files.
- 4f5cef2607c1 18.0 landed
-
Refactor string case conversion into provider-specific files.
- 86a5d6006aff 18.0 landed
-
Move check for ucol_strcollUTF8 to pg_locale_icu.c
- 7167e05fc7d1 18.0 landed
-
Perform provider-specific initialization in new functions.
- 1ba0782ce90c 18.0 landed
-
Refactor the code to create a pg_locale_t into new function.
- 3aa2373c1141 18.0 landed