Collation & ctype method table, and extension hooks

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Collation & ctype method table, and extension hooks
Date: 2024-09-26 22:30:09
Message-ID: 2830211e1b6e6a2e26d845780b03e125281ea17b.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v5-0008-Introduce-hooks-for-creating-custom-pg_locale_t.patch text/x-patch 4.9 KB
v5-0007-Control-ctype-behavior-with-a-method-table.patch text/x-patch 26.7 KB
v5-0006-Control-case-mapping-behavior-with-a-method-table.patch text/x-patch 34.8 KB
v5-0005-Control-collation-behavior-with-a-method-table.patch text/x-patch 16.7 KB
v5-0004-Perform-provider-specific-initialization-code-in-.patch text/x-patch 18.0 KB
v5-0003-Refactor-the-code-to-create-a-pg_locale_t-into-ne.patch text/x-patch 11.3 KB
v5-0002-Move-libc-specific-code-from-pg_locale.c-into-pg_.patch text/x-patch 16.8 KB
v5-0001-Move-ICU-specific-code-from-pg_locale.c-into-pg_l.patch text/x-patch 40.0 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2024-09-26 22:46:27 Re: query_id, pg_stat_activity, extended query protocol
Previous Message Michael Paquier 2024-09-26 22:06:16 Re: Add has_large_object_privilege function