"errno" not set in case of "libm" functions (HPUX)

Ibrar Ahmed <ibrar.ahmad@gmail.com>

From: Ibrar Ahmed <ibrar.ahmad@gmail.com>
To: pgsql-hackers@postgresql.org
Date: 2011-05-24T17:21:42Z
Lists: pgsql-hackers

Attachments

I have found a problem which is specifically related to  "HP-UX" compiler.
All 'libm' functions on "HP-UX Integrity server" do not set "errno" by
default. For 'errno' setting we should compile the code using +Olibmerrno
option. So we should add this option in "/src/makefiles/Makefile.hpux".
Otherwise we cannot expect this code to work properly


[float.c]
Datum
dacos(PG_FUNCTION_ARGS)
{
...
        errno = 0;
        result = acos(arg1);
        if (errno != 0)
                ereport(ERROR,

(errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
                                 errmsg("input is out of range")));

...
}

Because "acos" function will not set the errono in case of invalid input, so
check will not trigger the error message. I have attached a patch to add
this option in HPUX makefile.

BTW I have found same kind of discussion without any conclusion here

http://archives.postgresql.org/pgsql-hackers/2011-05/msg00046.php

-- 
   Ibrar Ahmed