From: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
---|---|
To: | Michael Meskes <meskes(at)postgresql(dot)org> |
Cc: | pgsql-hackers(at)postgresql(dot)org, Hans-Juergen Schoenig <hs(at)cybertec(dot)at> |
Subject: | Re: Question about ECPGset_noind_null() and ECPGis_noind_null() |
Date: | 2009-11-19 19:12:24 |
Message-ID: | 4B059898.2090007@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Boszormenyi Zoltan írta:
> Hi,
>
> my question is that what platform were these
> functions developed and tested?
>
> We have come across a value that fails a NOT NULL
> constraint upon INSERT under HP-UX/IA64, but not
> under x86-64 Linux. The value in question is
> 1.9999999999999998 assigned to a "double" variable.
> Under HP-UX/IA64, testing with risnull() from
> the application indeed returns true, but under
> Linux/x86-64 returns false.
>
> I will test rsetnull() results on real Informix under
> HP-UX/IA64.
>
I have tested it under ESQL/C on HP-UX/ia64 and
this happened:
- rsetnull() on a double value creates
FF FF FF FF FF FF FF FF
- the value causing the error above is
3F FF FF FF FF FF FF FF
It seems that this function in ecpglib/misc.c has
an off-by-one bug as it's interpreted by the HP-UX CC:
static bool
_check(unsigned char *ptr, int length)
{
for (; length > 0 && ptr[--length] == 0xff;);
if (length <= 0)
return true;
return false;
}
I suspect that GCC does the "--length" after checking
"length > 0" and before checking the "ptr[...] == 0xff",
but HP CC does it before checking "length > 0".
The attached patch solves the problem.
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/
Attachment | Content-Type | Size |
---|---|---|
risnull-fix-ctxdiff.patch | text/x-patch | 588 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | hgonzalez | 2009-11-19 19:21:47 | Re: Timezones (in 8.5?) |
Previous Message | Tom Lane | 2009-11-19 19:00:29 | Re: TRIGGER with WHEN clause |