Re: [PATCHES] Problem with setlocale (found in libecpg) [accessing a - Mailing list pgsql-hackers

From Christof Petig
Subject Re: [PATCHES] Problem with setlocale (found in libecpg) [accessing a
Date
Msg-id 3BB2FCBB.45A2849D@petig-baender.de
Whole thread Raw
List pgsql-hackers
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.]




pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: Re: multibyte performance
Next
From: Christof Petig
Date:
Subject: Re: Abort transaction on duplicate key error