Re: ECPGset_var

From: Boszormenyi Zoltan <zb(at)cybertec(dot)at>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Michael Meskes <meskes(at)postgresql(dot)org>, PostgreSQL Hacker <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ECPGset_var
Date: 2010-01-26 20:55:22
Message-ID: 4B5F56BA.90405@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane írta:
> Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:
>
>> Also, another "bug" is fixed in one regression test,
>> it seems NaN is different across platforms, so
>> we must not test for it either.
>>
>
> Really? The main regression tests have several test cases for NaN,
> and no provision that I can see for platform dependence of the
> result.
>
> -- special inputs
> SELECT 'NaN'::float8;
> float8
> --------
> NaN
> (1 row)
>
> If ecpg isn't handling this maybe you have a real bug to deal with.
>
> regards, tom lane
>
>

I meant this, e.g. from "gypsy_moth":

===================================

*** /export/home/tmp/pg-test/build-suncc/HEAD/pgsql.11494/src/interfaces/ecpg/test/expected/preproc-outofscope.stdout Tue Jan 26 13:51:59 2010
--- /export/home/tmp/pg-test/build-suncc/HEAD/pgsql.11494/src/interfaces/ecpg/test/results/preproc-outofscope.stdout Tue Jan 26 14:14:58 2010
***************
*** 1,4 ****
id=1 t='a' d1=1.000000 d2=2.000000 c = 'a '
id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
! id=3 t='"a"' d1=-1.000000 d2=nan c = 'a '
id=4 t='b' d1=2.000000 d2=3.000000 c = 'b '
--- 1,4 ----
id=1 t='a' d1=1.000000 d2=2.000000 c = 'a '
id=2 t='' (NULL) d1=0.000000 (NULL) d2=0.000000 (NULL) c = '' (NULL)
! id=3 t='"a"' d1=-1.000000 d2=NaN c = 'a '
id=4 t='b' d1=2.000000 d2=3.000000 c = 'b '

===================================

This is the result of a printf(). My Fedora 9 writes out "nan",
every Sparc machine in the buildfarm writes out "NaN".
This is not an ECPG parser bug, only a difference in the
system libc.

However, on "mastodon", a Windows Server 2003 machine:

===================================
--- 92,96 ----
[NO_PID]: sqlca: code: 0, state: 00000
[NO_PID]: ecpg_get_data on line 49: RESULT: NaN offset: -1; array: yes
[NO_PID]: sqlca: code: 0, state: 00000
! [NO_PID]: raising sqlcode -206 on line 49: invalid input syntax for floating-point type: "NaN", on line 49
! [NO_PID]: sqlca: code: -206, state: 42804
===================================

This comes from this code in data.c, in ecpg_get_data():

case ECPGt_float:
case ECPGt_double:
if (isarray && *pval == '"')
dres = strtod(pval + 1,
&scan_length);
else
dres = strtod(pval,
&scan_length);

if (isarray && *scan_length == '"')
scan_length++;

if (garbage_left(isarray,
scan_length, compat))
{
ecpg_raise(lineno,
ECPG_FLOAT_FORMAT,

ECPG_SQLSTATE_DATATYPE_MISMATCH, pval);
return (false);
}

It seems Windows doesn't accept "NaN" in strtod(). Is it really the case?

Best regards,
Zoltán Böszörményi

--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics

----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2010-01-26 21:03:10 Re: ECPGset_var
Previous Message Tom Lane 2010-01-26 20:40:15 Re: ECPGset_var