pg.ddx.io pgsql-bugs@postgresql.org mailing list archive
help / color / mirror / Atom feedECPGdo fails to restore LC_NUMERIC
2+ messages / 2 participants
[nested] [flat]
* ECPGdo fails to restore LC_NUMERIC
@ 2011-09-01 11:27 Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
0 siblings, 1 reply; 2+ messages in thread
From: Heikki Linnakangas @ 2011-09-01 11:27 UTC (permalink / raw)
To: pgsql-bugs
ECPGdo function in ecpglib sets LC_NUMERIC locale temporarily to C, to
make sure it uses the '.' as the decimal separator for any numerics it
sends to the backend. However, it fails to restore it back to the
original locale in some error cases. I can see two returns from the
function that neglect that, on lines 1776 and 1803 in execute.c.
Attached is a test program to showcase the first of those. It produces
this output for me:
LC_NUMERIC before: fi_FI.utf8
number: 1,230000
LC_NUMERIC after: C
number: 1.230000
--
Heikki Linnakangas
EnterpriseDB http://www.enterprisedb.com
Attachments:
autoprep-setlocale.pgc (text/plain, 438B) download
/*
* precompile with "ecpg -r prepare autoprep-setlocale.pgc" to make this fail.
*/
#include <locale.h>
#include <stdio.h>
int main(void)
{
setlocale(LC_ALL, "");
EXEC SQL CONNECT TO postgres;
printf("LC_NUMERIC before: %s\nnumber: %f\n", setlocale(LC_NUMERIC, NULL), 1.23);
EXEC SQL SELECT fail;
printf("LC_NUMERIC after: %s\nnumber: %f\n", setlocale(LC_NUMERIC, NULL), 1.23);
EXEC SQL DISCONNECT ALL;
return 0;
}
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: ECPGdo fails to restore LC_NUMERIC
@ 2011-09-01 13:48 Michael Meskes <meskes@postgresql.org>
parent: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
0 siblings, 0 replies; 2+ messages in thread
From: Michael Meskes @ 2011-09-01 13:48 UTC (permalink / raw)
To: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>; +Cc: pgsql-bugs
On Thu, Sep 01, 2011 at 02:27:07PM +0300, Heikki Linnakangas wrote:
> ECPGdo function in ecpglib sets LC_NUMERIC locale temporarily to C,
> to make sure it uses the '.' as the decimal separator for any
> numerics it sends to the backend. However, it fails to restore it
> back to the original locale in some error cases. I can see two
> returns from the function that neglect that, on lines 1776 and 1803
> in execute.c.
Fixed.
Thanks for spotting this.
Michael
--
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Michael at BorussiaFan dot De, Meskes at (Debian|Postgresql) dot Org
Jabber: michael.meskes at googlemail dot com
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2011-09-01 13:48 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-09-01 11:27 ECPGdo fails to restore LC_NUMERIC Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
2011-09-01 13:48 ` Michael Meskes <meskes@postgresql.org>
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