I've got an external  C function that I call from a SELECT, for example:

select * from <table> where <cond1> and CFunction(columnName) > 1.0;

The 'CFunction' has been installed into Postgreql using CREATE FUNCTION,
with a single 'text' argument, and returning a float8 (i.e. double).
I can tell that the 'CFunction' is getting called with the correct
argument, because it can be compiled to echo its activities to a file.
Also, if I rewrite the second condition (for example, leaving out the
'>' sign), psql complains that the function returns a float8, not a
boolean value.

The problem is that Postgresql seems to treat the latter condition
as an "fail always".  I can compile the function to return a constant,
say for example, 1.0.  Without the second condition, I always get the
expected set of results.  With the second condition, no results are
returned regardless of the sense of the comparison: >, <, =, <> all
return nothing.

I would appreciate it if someone could help me be able to use an
externally compiled function that returns a result.

TIA!

        -frank




************

Reply via email to