From: Bernd Reiß <bd_reiss@gmx.at>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: missing possibility to use alternative translated month names in to_char function
Date: Sun, 23 Aug 2026 08:31:56 +0200
Message-ID: <df181efc-666d-46d0-8dc0-e78e99e424b0@gmx.at> (raw)
In-Reply-To: <CAFj8pRAXEfkTJY1r7t6erYznBjU9xZANk_0=XyHtRMAKJK4Hjg@mail.gmail.com>
References: <CAFj8pRB6-Bzd=mC6f-aXC89=cXLGDZt2C4NeW1ZTXqFS0wJhXg@mail.gmail.com>
<CAFj8pRBmUN4iWWQfqFo0F4kqN75jctZ26SX-0RzxWhSFikxYTQ@mail.gmail.com>
<CAFj8pRDqXN5Rr1DeVP8dQm29YZAEgnhOnsyFOnLkAHkcDEFe+w@mail.gmail.com>
<78010782-fe08-402c-83e9-5239f6d322a3@gmx.at>
<CAFj8pRBz=C8UNwS8S2rfaVr1LuifmKNoxymC8R1kFhy8T5j7FQ@mail.gmail.com>
<034c0c9c-5e42-4aca-918d-03b1d3f8e528@gmx.at>
<CAFj8pRBjgzGhf2AK5y+YXJMMiu8u67ejhVHZbsTyfb3tFSadEQ@mail.gmail.com>
<bd61f759-fc35-449f-b168-b0ea927a3e25@gmx.at>
<CAFj8pRAXEfkTJY1r7t6erYznBjU9xZANk_0=XyHtRMAKJK4Hjg@mail.gmail.com>
Hi,
On 23/08/2026 07:30, Pavel Stehule wrote:
> Hi
>
> pá 21. 8. 2026 v 18:56 odesílatel Bernd Reiß <bd_reiss@gmx.at> napsal:
>
> Hi Pavel,
>
> On 8/18/26 8:47 PM, Pavel Stehule wrote:
> > Hi
> >
> > so 15. 8. 2026 v 14:03 odesílatel Bernd Reiß <bd_reiss@gmx.at
> <mailto:bd_reiss@gmx.at>> napsal:
> >
> > Hi again,
> >
> > thanks for the updated patch.
> > > TAMMON is not implemented, because glibc doesn't provide an
> > > alternative form for abbreviated month names.
> > > It is a question if it is better to raise an error, return
> a non
> > > alternative name or just ignore this flag. I have not strong
> > > opinion about this. Inside DCH_to_char the prefix TM is
> ignored when
> > > it is not used. So I did the same.
> > The Locale standard actually mentions abbreviated
> alternative month
> > names as
> > "ab_alt_mon" (see [1]). I tested this by setting your
> TAMMONTH strftime
> > call to '%Ob'.
> > If we set the locale to Russian and call the function for
> May this
> > actually returns
> > an abbreviated version of the month name:
> >
> > Breakpoint 1, cache_locale_time () at pg_locale.c:772
> > 772 if (strftime_l(bufptr, MAX_L10N_DATA, "%Ob",
> timeinfo,
> > locale) <= 0)
> > (gdb) n
> > 774 bufptr += MAX_L10N_DATA;
> > (gdb) print bufptr
> > $4 = 0x7ffde4554630 "май"
> >
> > Compared to the TMMON form of May in Russian this actually
> makes a
> > difference:
> >
> > postgres=# set lc_time='ru_RU.UTF8';
> > SET
> > postgres=# select to_char('2026-05-01'::date, 'TMMON');
> > to_char
> > ---------
> > МАЯ
> > (1 row)
> >
> > postgres=# select to_char('2026-05-01'::date, 'TAMMONTH');
> > to_char
> > ---------
> > МАЙ
> > (1 row)
> >
> > Again, TAMMONTH uses %Ob here. So I would argue for
> implementing the
> > abbreviated
> > forms too.
> >
> >
> > I implemented it - please check
>
> LGTM. I compiled it and it works as expected. I also like the
> introduction of
> the get_localized_*_months functions. However, this leads to
> suffix_len being
> declared and set but never used in the DCH_MONTH, DCH_Month, and
> DCH_month
> cases (as well as for the abbreviated equivalents) in
> DCH_from_char. Passing
> NULL and guarding in the functions would be an option to avoid
> this. However,
> I don't feel strongly about this.
>
> In DCH_to_char I think you forgot to refactor this if statement
> for the
> MON/Mon/mon cases?
>
> if (strlen(str) <= (n->key->len + TM_SUFFIX_LEN) *
> DCH_MAX_ITEM_SIZ)
> strcpy(s, str);
>
>
> this code is removed in new version
>
>
> >
> > Please check updated patch
> >
>
> With the if statements cleaned up this is a +1 for Ready for
> Committer from me.
>
>
> Regards
>
> Pavel
Patch applies cleanly now on HEAD. New changes LGTM. Compiles without
problems and
regression tests are all green. I am moving this to Ready for Reviewer.
Best
Bernd
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: bd_reiss@gmx.at, pavel.stehule@gmail.com
Subject: Re: missing possibility to use alternative translated month names in to_char function
In-Reply-To: <df181efc-666d-46d0-8dc0-e78e99e424b0@gmx.at>
References: <CAFj8pRB6-Bzd=mC6f-aXC89=cXLGDZt2C4NeW1ZTXqFS0wJhXg@mail.gmail.com> <CAFj8pRBmUN4iWWQfqFo0F4kqN75jctZ26SX-0RzxWhSFikxYTQ@mail.gmail.com> <CAFj8pRDqXN5Rr1DeVP8dQm29YZAEgnhOnsyFOnLkAHkcDEFe+w@mail.gmail.com> <78010782-fe08-402c-83e9-5239f6d322a3@gmx.at> <CAFj8pRBz=C8UNwS8S2rfaVr1LuifmKNoxymC8R1kFhy8T5j7FQ@mail.gmail.com> <034c0c9c-5e42-4aca-918d-03b1d3f8e528@gmx.at> <CAFj8pRBjgzGhf2AK5y+YXJMMiu8u67ejhVHZbsTyfb3tFSadEQ@mail.gmail.com> <bd61f759-fc35-449f-b168-b0ea927a3e25@gmx.at> <CAFj8pRAXEfkTJY1r7t6erYznBjU9xZANk_0=XyHtRMAKJK4Hjg@mail.gmail.com> <df181efc-666d-46d0-8dc0-e78e99e424b0@gmx.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox