BUG #6069: C function returns NaN when part of an SQL function
От | Robert Kruus |
---|---|
Тема | BUG #6069: C function returns NaN when part of an SQL function |
Дата | |
Msg-id | 201106201554.p5KFs81o010354@wwwmaster.postgresql.org обсуждение исходный текст |
Список | pgsql-bugs |
The following bug has been logged online: Bug reference: 6069 Logged by: Robert Kruus Email address: robert.kruus@gov.sk.ca PostgreSQL version: 9.0.4 Operating system: FreeBSD 8.1 64 Bit Description: C function returns NaN when part of an SQL function Details: I have a c function in an external lib that have written and when called on its own it works as expected: SELECT dmc(13.433, 16.1, 9, 9.6, 21.59, 6); dmc ------------------- 0.316972255706787 But if I include it as part of an SQL function which returns a custom type: SELECT * FROM fwi_all(22.63, 13.433, 148.451, 62.34, 16.1, 93, 9.6, 21.59, 6); ffmc | dmc | dc | isi | bui | fwi | sdmc ------------------+-----+------------------+----------------------+-----+--- --+------------------ 12.9909820556641 | NaN | 109.883583068848 | 1.83133633981925e-05 | NaN | NaN | 28.2005863189697 CREATE OR REPLACE FUNCTION fwi_all(old_ffmc FLOAT, old_dmc FLOAT, old_dc FLOAT, sdmc_old FLOAT, "temp" FLOAT, rh FLOAT, wind FLOAT, rain FLOAT, month INTEGER) RETURNS fwi AS $BODY$ SELECT ffmc, dmc, dc, isi, bui, fwi(isi, bui), sdmc FROM (SELECT s1.*, isi(s1.ffmc, $8), bui(s1.dmc, s1.dc) FROM (SELECT ffmc($1, $5, $6, $7, $8), dmc($2, $5, $6, $7, $8, $9), dc($3, $5, $6, $7, $8, $9), sdmc($4, $5, $6, $7, $8, $9)) s1) s2 $BODY$ LANGUAGE 'sql' STABLE; The dmc function returns a double, and the custom type consists of doubles as well. I initially noticed the error as the fwi type was returning a set of real and I thought it may have been due type casting. Adding explicit type casting throughout does not change the result.
В списке pgsql-bugs по дате отправления: