Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 2BE67B5DC06 for ; Thu, 1 Sep 2011 08:27:19 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 18287-09 for ; Thu, 1 Sep 2011 11:27:12 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exprod7og104.obsmtp.com (exprod7og104.obsmtp.com [64.18.2.161]) by mail.postgresql.org (Postfix) with ESMTP id E8075B5DC0F for ; Thu, 1 Sep 2011 08:27:11 -0300 (ADT) Received: from mail-fx0-f41.google.com ([209.85.161.41]) (using TLSv1) by exprod7ob104.postini.com ([64.18.6.12]) with SMTP ID DSNKTl9sD/UU1fD2XWUbC49Ks35GpvF3FsBC@postini.com; Thu, 01 Sep 2011 04:27:12 PDT Received: by mail-fx0-f41.google.com with SMTP id 9so780975fxg.14 for ; Thu, 01 Sep 2011 04:27:11 -0700 (PDT) Received: by 10.223.33.17 with SMTP id f17mr200526fad.3.1314876430878; Thu, 01 Sep 2011 04:27:10 -0700 (PDT) Received: from [192.168.1.183] (dsl-hkibrasgw2-ff7ac300-240.dhcp.inet.fi [88.195.122.240]) by mx.google.com with ESMTPS id b13sm418449fak.16.2011.09.01.04.27.09 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 01 Sep 2011 04:27:09 -0700 (PDT) Message-ID: <4E5F6C0B.6030708@enterprisedb.com> Date: Thu, 01 Sep 2011 14:27:07 +0300 From: Heikki Linnakangas User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; fi-FI; rv:1.9.2.21) Gecko/20110831 Icedove/3.1.13 MIME-Version: 1.0 To: PostgreSQL Bugs Subject: ECPGdo fails to restore LC_NUMERIC Content-Type: multipart/mixed; boundary="------------080904050104090602040107" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.9 tagged_above=-5 required=5 tests=BAYES_00=-1.9 X-Spam-Level: X-Archive-Number: 201109/5 X-Sequence-Number: 31022 This is a multi-part message in MIME format. --------------080904050104090602040107 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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 --------------080904050104090602040107 Content-Type: text/plain; name="autoprep-setlocale.pgc" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="autoprep-setlocale.pgc" /* * precompile with "ecpg -r prepare autoprep-setlocale.pgc" to make this fail. */ #include #include 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; } --------------080904050104090602040107--