Re: Final result (display) collation?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org, Vik Fearing <vik(at)postgresfriends(dot)org>, Peter Eisentraut <peter(at)eisentraut(dot)org>
Subject: Re: Final result (display) collation?
Date: 2025-02-08 20:23:39
Message-ID: 5305e7f2d7337b1d775abcd804b9ba481c89da2d.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Tue, 2024-12-17 at 20:36 -0500, Tom Lane wrote:
> Jeff Davis <pgsql(at)j-davis(dot)com> writes:
> > Crazy idea: what if we treated the top-level ORDER BY as special?
>
> This seems like an amazing kluge, and it's not even clear that
> there's any field demand for it.

I had a discussion with Vik, and he suggested something less crazy:
what if we had a "COLLATE SESSION" (or some special name) that would
mean that it should get the actual collation from a GUC? (Obviously
this would only work on expressions and not column definitions.)

That would solve one fairly annoying problem: we don't guarantee that
any particular collation actually exists (aside from the memcmp-based
ones), so it's hard to configure applications to use the COLLATE clause
at all.

The Django docs[1] reference "et-x-icu", but it's hard to know which
ones are available. We have documentation about how to construct ICU
language tags, but not about which specific language/region
combinations are available, because those comes from ICU, which doesn't
seem to document them either.

Granted, if you want to use US English, someone will have to know the
name "en-US-x-icu" or "en_US" at some point. But it's more reasonable
to expect a user doing "ALTER USER ... SET" to know the available
Postgres collations on that particular server than an application
developer who might expect it to work on any Postgres instance. And
GUCs are a much more flexible solution than an application
configuration file, or worse, hard-coded in application code[2].

Aside: we'd need to differentiate this enough from the SQL standard
"SET COLLATION", which (IIUC) affects all expressions in the query.

Regards,
Jeff Davis

[1]
https://docs.djangoproject.com/en/5.1/ref/models/database-functions/

[2]
https://stackoverflow.com/questions/60318707/how-to-use-collate-as-with-sequel-and-ruby

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Ed Behn 2025-02-08 20:24:03 Re: access numeric data in module
Previous Message Pavel Stehule 2025-02-08 19:56:28 Re: proposal - plpgsql - support standard syntax for named arguments for cursors