Thomas Kellerer wrote:
> I always thought that this is a major shortcoming (if not a bug) in Postgres
> that the collation support is left to the OS.
>
> Because it essentially means that that exactly the same query with exactly
> the same data might return a different result if run on different OS
Could an extension help with this?
CREATE EXTENSION pg_locales;
The extension would provide its own strcoll/strxfrm/etc. and a set
of locale definitions, presumably slurped from Linux or BSD.
It would probably be preloaded in postgresql.conf:
shared_preload_libraries = pg_locales
A collation would be created with
SELECT create_pg_collation(name,locale,lc_collate,lc_ctype);
which would be a kind of CREATE COLLATION but relying on the
extension code/data rather than the libc.
Then tables and columns could be set to use that collation, and the
core postgres code should divert the corresponding string comparisons
to the extension functions.
Benefits:
- being insulated from unexpected OS changes.
- portability across OS, assuming that the extension would be itself
portable.
- the core postgres would not be responsible of maintaining these locales.
Would something like that make sense?
Best regards,
--
Daniel Vérité
PostgreSQL-powered mailer: http://www.manitou-mail.org
Twitter: @DanielVerite