Collation & ctype method table, and extension hooks
Jeff Davis <pgsql@j-davis.com>
From: Jeff Davis <pgsql@j-davis.com>
To: pgsql-hackers@postgresql.org
Date: 2024-09-26T22:30:09Z
Lists: pgsql-hackers
Attachments
- v5-0008-Introduce-hooks-for-creating-custom-pg_locale_t.patch (text/x-patch) patch v5-0008
- v5-0007-Control-ctype-behavior-with-a-method-table.patch (text/x-patch) patch v5-0007
- v5-0006-Control-case-mapping-behavior-with-a-method-table.patch (text/x-patch) patch v5-0006
- v5-0005-Control-collation-behavior-with-a-method-table.patch (text/x-patch) patch v5-0005
- v5-0004-Perform-provider-specific-initialization-code-in-.patch (text/x-patch) patch v5-0004
- v5-0003-Refactor-the-code-to-create-a-pg_locale_t-into-ne.patch (text/x-patch) patch v5-0003
- v5-0002-Move-libc-specific-code-from-pg_locale.c-into-pg_.patch (text/x-patch) patch v5-0002
- v5-0001-Move-ICU-specific-code-from-pg_locale.c-into-pg_l.patch (text/x-patch) patch v5-0001
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. In practice, the main use is to replace, for example, ICU with a different version of ICU. But it can also be used to control libc behavior, or to use a different set of methods that have nothing to do with ICU or libc. It also isolates code to some new files: ICU code goes in pg_locale_icu.c, and libc code goes in pg_locale_libc.c. And it reduces a lot of code that branches on the provider. That's easier to reason about, in my opinion. With these patches, the collation provider becomes mainly a catalog concept used to create the right pg_locale_t, rather than an execution- time concept. We could take this further and make providers a concept in the catalog, like "CREATE LOCALE PROVIDER", and it would just provide an arbitrary handler function to create the pg_locale_t. If we decide how we'd like to handle versioning, that could potentially allow a much smoother upgrade process that preserves the provider versions. 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