Re: Final result (display) collation?

From: Jeff Davis <pgsql(at)j-davis(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: pgsql-hackers(at)postgresql(dot)org
Subject: Re: Final result (display) collation?
Date: 2024-12-18 18:47:02
Message-ID: 6463b6defad02bc6242f8b4d9234530cdbc47102.camel@j-davis.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 2024-12-18 at 08:26 +0100, Laurenz Albe wrote:
> Yes, that approach seems strange.

My thought was it would be more like a client option than anything
else: a way for the application to request the same result in a more
convenient order. A bit strange, but depending on how you look at it,
is not very radical. More like setting lc_numeric.

>   Also, wouldn't that prevent
> plans that calculate the final sort using a nested loop or merge
> join further down?

If the purpose is for a final result to be displayed to a human (rather
than fed into some other data processing system), then it's going to be
a small result and the final sort should be very cheap.

> But I like the idea of a parameter that determines the collation.
> I am aware that it is anathema here to have a GUC that influences
> query semantics, but it wouldn't be any worse than creating a
> database with a different collation, so I think it would be fine.

That appears to be how the SET COLLATION statement is specified in SQL.
Perhaps we should explore that in more detail?

I think we'd have to be careful that it only applies to the top-level
query and not SPI queries or CHECK constraints. There are probably some
technical challenges in that, but it might not be too bad.

> FWIW, Oracle has a parameter NLS_SORT that does just that.

Ah, interesting.

Regards,
Jeff Davis

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2024-12-18 19:55:24 Re: Support regular expressions with nondeterministic collations
Previous Message Andreas Karlsson 2024-12-18 18:44:47 Re: pure parsers and reentrant scanners