Re: [PATCHES] Problem with setlocale (found in libecpg) [accessing a

From: Christof Petig <christof(at)petig-baender(dot)de>
To: Michael Meskes <meskes(at)postgresql(dot)org>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] Problem with setlocale (found in libecpg) [accessing a
Date: 2001-09-27 10:17:31
Message-ID: 3BB2FCBB.45A2849D@petig-baender.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Michael Meskes wrote:

> On Thu, Sep 27, 2001 at 12:08:29AM -0400, Tom Lane wrote:
> > I looked around, and am worried about the behavior of PGLC_current()
> > in src/backend/utils/adt/pg_locale.c. It doesn't change locale but
> > does retrieve several successive setlocale() results. Does that work
> > in glibc?
>
> I haven't experienced any problem so far, but then I wasn't able to
> reproduce Christof's either on my glibc2.2 system.

You have to link with efence to see it (see below). (BTW the bug is in
libecpg)

Otherwise the bug is hidden (setting an illegal locale simply does not do
anything if we ignore it's return value (setlocale returns NULL on
error)). Perhaps outputting a notice to the debug stream if setlocale
fails is a good choice (I don't like to raise a SQL error).

Christof

[More detailed: if the former value is freed, the pointer still points to
a valid memory region (without efence), further processing inside ecpg
will reuse that region for just another string (an input variable's value
in SQL notation).
So setting locale '0' or 'ISO' or 'some string' silently fails.]

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Christof Petig 2001-09-27 10:47:58 Re: Abort transaction on duplicate key error
Previous Message Karel Zak 2001-09-27 10:11:15 pg_locale (Was: Re: Problem with setlocale (found in libecpg)...)

Browse pgsql-patches by date

  From Date Subject
Next Message Vianen, Jeroen van 2001-09-27 14:05:22 Fix for broken JDBC's getColumn() (take 2)
Previous Message Karel Zak 2001-09-27 10:11:15 pg_locale (Was: Re: Problem with setlocale (found in libecpg)...)