ECPG patch: get descriptor did not use "C" locale while parsing data
ECPG patch: get descriptor did not use "C" locale while parsing data
Hi Michael,
The bug description is quite simple try to use get descriptor on a float
variable while LC_NUMERIC=de is active ... you get incorrectly formatted
float value.
Please apply the fix.
Yours
Christof
Re: ECPG patch: get descriptor did not use "C" locale while
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Is this a fix you want applied to 7.2 or 7.3? I am confused.
Patch attached.
---------------------------------------------------------------------------
Christof Petig wrote:
> Hi Michael,
>
> The bug description is quite simple try to use get descriptor on a float
> variable while LC_NUMERIC=de is active ... you get incorrectly formatted
> float value.
>
> Please apply the fix.
>
> Yours
> Christof
>
[ application/gzip is not supported, skipping... ]
>
> ---------------------------(end of broadcast)---------------------------
> TIP 4: Don't 'kill -9' the postmaster
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026
Index: lib/descriptor.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/lib/descriptor.c,v
retrieving revision 1.21
diff -u -r1.21 descriptor.c
--- lib/descriptor.c 2002/01/11 14:43:11 1.21
+++ lib/descriptor.c 2002/01/23 15:32:54
@@ -330,11 +330,18 @@
if (data_var.type!=ECPGt_EORT)
{
struct statement stmt;
+ char *oldlocale;
+
+ /* Make sure we do NOT honor the locale for numeric input */
+ /* since the database gives the standard decimal point */
+ oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
+ setlocale(LC_NUMERIC, "C");
memset (&stmt, 0, sizeof stmt);
stmt.lineno=lineno;
/* desparate try to guess something sensible */
stmt.connection=ECPGget_connection(NULL);
ECPGstore_result(ECPGresult, index, &stmt, &data_var);
+ setlocale(LC_NUMERIC, oldlocale);
}
else if (data_var.ind_type!=ECPGt_NO_INDICATOR)
{
Re: ECPG patch: get descriptor did not use "C" locale while parsing data
От:
Christof Petig <christof@petig-baender.de>
Дата:
Bruce Momjian wrote: > Is this a fix you want applied to 7.2 or 7.3? I am confused. > I would suggest to apply it to 7.2 (and 7.3, too - if that already exists) since it fixes a recently found bug and is straightforward (the code is already used in ECPGexecute, ECPGget_desc missed it). Christof
Re: ECPG patch: get descriptor did not use "C" locale while
От:
Bernhard Herzog <bh@intevation.de>
Дата:
Bruce Momjian writes:
> RCS file: /projects/cvsroot/pgsql/src/interfaces/ecpg/lib/descriptor.c,v
> retrieving revision 1.21
> diff -u -r1.21 descriptor.c
> --- lib/descriptor.c 2002/01/11 14:43:11 1.21
> +++ lib/descriptor.c 2002/01/23 15:32:54
> @@ -330,11 +330,18 @@
> if (data_var.type!=ECPGt_EORT)
> {
> struct statement stmt;
> + char *oldlocale;
> +
> + /* Make sure we do NOT honor the locale for numeric input */
> + /* since the database gives the standard decimal point */
> + oldlocale = strdup(setlocale(LC_NUMERIC, NULL));
> + setlocale(LC_NUMERIC, "C");
> memset (&stmt, 0, sizeof stmt);
> stmt.lineno=lineno;
> /* desparate try to guess something sensible */
> stmt.connection=ECPGget_connection(NULL);
> ECPGstore_result(ECPGresult, index, &stmt, &data_var);
> + setlocale(LC_NUMERIC, oldlocale);
There should be a free(oldlocale); here, I think.
> }
Bernhard
--
Intevation GmbH http://intevation.de/
Sketch http://sketch.sourceforge.net/
MapIt! http://mapit.de/
Re: ECPG patch: get descriptor did not use "C" locale while parsing data
От:
Michael Meskes <meskes@postgresql.org>
Дата:
On Wed, Jan 23, 2002 at 10:55:19AM -0500, Bruce Momjian wrote: > Is this a fix you want applied to 7.2 or 7.3? I am confused. I did apply it to HEAD. Do I have to apply it to 7.2 too? BTW there is a minor glitch with the patch, it misses a ECPGfree(oldlocale). So please do not apply the patch as is to 7.2 but instead use the version from HEAD. Ecpg as it is right now can go into 7.2. I will not commit any new stuff until 7.2 is released. Michael -- Michael Meskes Michael@Fam-Meskes.De Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
Re: ECPG patch: get descriptor did not use "C" locale while parsing data
От:
Michael Meskes <meskes@postgresql.org>
Дата:
Committed. Michael -- Michael Meskes Michael@Fam-Meskes.De Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
Re: ECPG patch: get descriptor did not use "C" locale while parsing data
От:
Christof Petig <christof@petig-baender.de>
Дата:
Michael Meskes wrote: > On Wed, Jan 23, 2002 at 10:55:19AM -0500, Bruce Momjian wrote: > >>Is this a fix you want applied to 7.2 or 7.3? I am confused. >> > > I did apply it to HEAD. Do I have to apply it to 7.2 too? > > BTW there is a minor glitch with the patch, it misses a ECPGfree(oldlocale). > So please do not apply the patch as is to 7.2 but instead use the version > from HEAD. > You are right. Four eyes see more than two ... Christof
Re: ECPG patch: get descriptor did not use "C" locale while
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Michael Meskes wrote: > On Wed, Jan 23, 2002 at 10:55:19AM -0500, Bruce Momjian wrote: > > Is this a fix you want applied to 7.2 or 7.3? I am confused. > > I did apply it to HEAD. Do I have to apply it to 7.2 too? We haven't split 7.3 yet. HEAD is all that is needed. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 853-3000 + If your life is a hard drive, | 830 Blythe Avenue + Christ can be your backup. | Drexel Hill, Pennsylvania 19026