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
/*
 * 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;
}
-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs

Reply via email to