Re: Allow to_date() and to_timestamp() to accept localized names - Mailing list pgsql-hackers

From Juan José Santamaría Flecha
Subject Re: Allow to_date() and to_timestamp() to accept localized names
Date
Msg-id CAC+AXB1ao4uniAXNnWU3uyq6Ks=nyKq5MwzrFM8sw_MLUF+E=Q@mail.gmail.com
Whole thread Raw
In response to Re: Allow to_date() and to_timestamp() to accept localized names  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: Allow to_date() and to_timestamp() to accept localized names
List pgsql-hackers
On Fri, Sep 13, 2019 at 10:31 PM Alvaro Herrera
<alvherre@2ndquadrant.com> wrote:
>
Thanks for taking a look at this.

> I'm confused why we acquire the MONTH_DIM / etc definitions.  Can't we
> just use lengthof() of the corresponding array?  AFAICS it should work
> just as well.
>

It was because of the length difference between ascii-name arrays,
which were all null-ended, and localized-name arrays. The attached
version uses lengthof().

> I wonder if the "compare first char" thing (seq_search_localized) really
> works when there are multibyte chars in the day/month names.  I think
> the code compares just the first char ... but what if the original
> string uses those funny Unicode non-normalized letters and the locale
> translation uses normalized letters?  My guess is that the first-char
> comparison will fail, but surely you'll want the name to match.
> (There's no month/day name in Spanish that doesn't start with an ASCII
> letter, but I bet there are some in other languages.)  I think the
> localized comparison should avoid the first-char optimization, just
> compare the whole string all the time, and avoid possible weird issues.

The localized search is reformulated in this version to deal with
multibyte normalization. A regression test for this issue is included.


Regards,

Juan José Santamaría Flecha

Attachment

pgsql-hackers by date:

Previous
From: Quan Zongliang
Date:
Subject: Add a GUC variable that control logical replication
Next
From: Peter Eisentraut
Date:
Subject: Re: Add a GUC variable that control logical replication