Re: Collation & ctype method table, and extension hooks

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Andreas Karlsson <andreas(at)proxel(dot)se>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Collation & ctype method table, and extension hooks
Date: 2024-10-09 23:27:41
Message-ID: fecea00b4ad9b9a2426cc34e78f30a0c75406ca7.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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

Attachment Content-Type Size
v6-0001-Move-ICU-specific-code-from-pg_locale.c-into-pg_l.patch text/x-patch 40.0 KB
v6-0002-Move-libc-specific-code-from-pg_locale.c-into-pg_.patch text/x-patch 26.1 KB
v6-0003-Refactor-the-code-to-create-a-pg_locale_t-into-ne.patch text/x-patch 11.3 KB
v6-0004-Perform-provider-specific-initialization-code-in-.patch text/x-patch 16.6 KB
v6-0005-Control-collation-behavior-with-a-method-table.patch text/x-patch 18.4 KB
v6-0006-Control-case-mapping-behavior-with-a-method-table.patch text/x-patch 35.7 KB
v6-0007-Control-ctype-behavior-with-a-method-table.patch text/x-patch 31.0 KB
v6-0008-Remove-provider-field-from-pg_locale_t.patch text/x-patch 4.7 KB
v6-0009-Make-provider-data-in-pg_locale_t-an-opaque-point.patch text/x-patch 21.6 KB
v6-0010-Don-t-include-ICU-headers-in-pg_locale.h.patch text/x-patch 3.7 KB
v6-0011-Introduce-hooks-for-creating-custom-pg_locale_t.patch text/x-patch 6.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tristan Partin 2024-10-09 23:30:13 Re: Official devcontainer config
Previous Message Heikki Linnakangas 2024-10-09 23:11:53 Re: sunsetting md5 password support