Re: lc_time and localized dates

Поиск
Список
Период
Сортировка
Искать
От
Bruce Momjian
Тема
Re: lc_time and localized dates
Дата
в 01:26:30
Msg-id
200805180425.m4I4PkZ05239@momjian.us
Ответ на
Re: lc_time and localized dates (Euler Taveira de Oliveira)
Список
Дерево обсуждения
lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates "Gevik Babakhani" <pgdev@xs4all.nl>
Re: lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates "Gevik Babakhani" <pgdev@xs4all.nl>
Re: lc_time and localized dates Zdenek Kotala <Zdenek.Kotala@Sun.COM>
Re: lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates Zdenek Kotala <Zdenek.Kotala@Sun.COM>
Re: lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates Zdenek Kotala <Zdenek.Kotala@Sun.COM>
Re: lc_time and localized dates Peter Eisentraut <peter_e@gmx.net>
Re: lc_time and localized dates "Gevik Babakhani" <pgdev@xs4all.nl>
Re: lc_time and localized dates Zdeněk Kotala <Zdenek.Kotala@Sun.COM>
Re: lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates Tom Lane <tgl@sss.pgh.pa.us>
Re: lc_time and localized dates "Gevik Babakhani" <pgdev@xs4all.nl>
Re: lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates Bruce Momjian <bruce@momjian.us>
Re: lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates Alvaro Herrera <alvherre@commandprompt.com>
Re: lc_time and localized dates Bruce Momjian <bruce@momjian.us>
Re: lc_time and localized dates Euler Taveira de Oliveira <euler@timbira.com>
Re: lc_time and localized dates Tom Lane <tgl@sss.pgh.pa.us>

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          http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
В списке pgsql-patches по дате отправления
От: Euler Taveira de Oliveira
Дата:
От: Euler Taveira de Oliveira
Дата:
FAQ