Re: lc_time and localized dates

From: Bruce Momjian <bruce(at)momjian(dot)us>
To: Euler Taveira de Oliveira <euler(at)timbira(dot)com>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Zdenek Kotala <Zdenek(dot)Kotala(at)Sun(dot)COM>, PostgreSQL-patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: lc_time and localized dates
Date: 2008-05-18 04:25:46
Message-ID: 200805180425.m4I4PkZ05239@momjian.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches


I have reviewed this patch. I like the method you used, but I did find
a few things I had to change.

First, I found the abbreviated variable names confusing so I used longer
ones, like:

extern char *localized_abbrev_days[7];
extern char *localized_full_days[7];
extern char *localized_abbrev_months[12];
extern char *localized_full_months[12];

Second, I found that the code doing upper/lower case didn't work. It
was copying the buffer into a 'result' variable, but then incrementing
'result' so by the end 'result' pointed to only the null byte, and that
is the pointer that was returned. Third, there were a few places where
the code assumed str_toupper() modified the passed buffer, rather than
returning a new one. And finally, while you used strdup() to save
values in the cache (good), you never free()'ed the old values when you
were reloading the cache.

I have fixed all these items and the updated patch is at:

ftp://momjian.us/pub/postgresql/mypatches/lc_time

The original patch was here:

http://archives.postgresql.org/message-id/481011DC.3050900@timbira.com

---------------------------------------------------------------------------

Euler Taveira de Oliveira wrote:
> Bruce Momjian wrote:
>
> > Euler, have you updated this patch yet?
> >
> Here is an updated patch. It follows the Oracle behaviour and uses a
> cache mechanism to avoid calling setlocale() all the time. I unified the
> localized_* and str_* functions. I didn't test it on Windows. I would
> appreciate some feedback.
>
>
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
> to_char
> -----------------------------------
> thu Qui Quinta apr ABR abril 2008
> (1 registro)
>
> euler=# set lc_time to 'it_IT.UTF-8';
> SET
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
> to_char
> -------------------------------------
> thu Gio Gioved? apr APR aprile 2008
> (1 registro)
>
> euler=# set lc_time to 'es_ES.UTF-8';
> SET
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
> to_char
> -----------------------------------
> thu Jue Jueves apr ABR abril 2008
> (1 registro)
>
> euler=# set lc_time to 'fr_FR.UTF-8';
> SET
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
> to_char
> ----------------------------------
> thu Jeu Jeudi apr AVR avril 2008
> (1 registro)
>
> euler=# set lc_time to 'cs_CZ.UTF-8';
> SET
> euler=# select to_char(now(), 'dy tmDy tmDay mon tmMON tmmonth YYYY');
> to_char
> -----------------------------------
> thu ?t ?tvrtek apr DUB duben 2008
> (1 registro)
>
>
> --
> Euler Taveira de Oliveira
> http://www.timbira.com/

[ application/x-gzip is not supported, skipping... ]

--
Bruce Momjian <bruce(at)momjian(dot)us> http://momjian.us
EnterpriseDB http://enterprisedb.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Euler Taveira de Oliveira 2008-05-18 05:13:48 Re: lc_time and localized dates
Previous Message Euler Taveira de Oliveira 2008-05-18 00:32:32 Re: pg_dump lock timeout - resend