Re: Collation & ctype method table, and extension hooks

Andreas Karlsson <andreas@proxel.se>

From: Andreas Karlsson <andreas@proxel.se>
To: Jeff Davis <pgsql@j-davis.com>, pgsql-hackers@postgresql.org
Date: 2024-12-02T15:39:11Z
Lists: pgsql-hackers

Attachments

Hi,

I have not looked at the later patches in the series yet as I got 
sidetracked while reviewing and decided to clean up some related 
collation things which I added to the patch set (feel free to ignore 
them if you want). The goal of my added patches is to move provider 
specific code into fewer places and not have provider specific logic all 
over the codebase.

I feel your first patch in the series is something you can just commit. 
It looks good and is simple, obvious refactoring. In theory we could 
share the code which does the lookup in the catalog table but I do not 
think it would be worth it. I fixed a small issue with it and the 
function prototypes in pg_collation.c.

I will look at the rest of your patches later.

My patches:

= v9-0002-Move-check-for-ucol_strcollUTF8-to-pg_locale_icu..patch

Broken out from v9-0010-Don-t-include-ICU-headers-in-pg_locale.h.patch.

= v9-0003-Move-code-for-collation-version-into-provider-spe.patch

Moves some code from pg_collate.c into provider specific files.

= v9-0004-Move-ICU-database-encoding-check-into-validation-.patch

Makes the ICU code more similar to the built-in provider plus reduces 
some code duplication. I feel we could go one step further and also only 
normalize built-in when "if (!IsBinaryUpgrade && dblocale != 
src_locale)" but I leave that for another patch if that is something we 
actually want to unify.

= v9-0005-Move-provider-specific-code-when-looking-up-local.patch

I did not like how namespace.c had knowledge of ICU.

Andreas

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.