pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Heikki Linnakangas <heikki.linnakangas@enterprisedb.com>
To: PostgreSQL Bugs <pgsql-bugs@postgresql.org>
Subject: ECPGdo fails to restore LC_NUMERIC
Date: Thu, 01 Sep 2011 14:27:07 +0300
Message-ID: <4E5F6C0B.6030708@enterprisedb.com> (raw)

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; }

view thread (2+ messages)  latest in thread

Message-ID: <4E5F6C0B.6030708@enterprisedb.com>
Permalink:  ../4E5F6C0B.6030708@enterprisedb.com/
Also on:    postgresql.org/message-id/4E5F6C0B.6030708@enterprisedb.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: heikki.linnakangas@enterprisedb.com
  Subject: Re: ECPGdo fails to restore LC_NUMERIC
  In-Reply-To: <4E5F6C0B.6030708@enterprisedb.com>
  References: <4E5F6C0B.6030708@enterprisedb.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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