Thread: 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
Attachment
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) {
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
Bruce Momjian <pgman@candle.pha.pa.us> 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/
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!
Committed. Michael -- Michael Meskes Michael@Fam-Meskes.De Go SF 49ers! Go Rhein Fire! Use Debian GNU/Linux! Use PostgreSQL!
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
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, Pennsylvania19026