Arguments not being passed to a function

Started by Barry Lindalmost 26 years ago2 messagesgeneral
Jump to latest
#1Barry Lind
barry@xythos.com

I am trying to call PL/pgSQL functions from JDBC via the Fastpath
interface. The function is executing but none of the arguments to the
function are getting set.

here is a simple example:

create function testcall (int4) returns int4 as '
begin
return $1;
end;
' language 'plpgsql';

In java I call it via:

FastpathArg args[] = new FastpathArg[1];
args[0] = new FastpathArg(55555);
Integer l_return = (Integer)fp.fastpath("testcall", true, args);

The result is always zero. I know that the function is executing
because if I change it to do an insert the insert happens (but if I use
a parameter in the insert, i.e. $1, it is always null).

However if I run the function from a select, (ie. select
testcall(55555); ) it works correctly.

Can anyone shed some light on this?

thanks,
--Barry

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Barry Lind (#1)
Re: Arguments not being passed to a function

Barry Lind <barry@xythos.com> writes:

I am trying to call PL/pgSQL functions from JDBC via the Fastpath
interface. The function is executing but none of the arguments to the
function are getting set.

Looks like fastpath.c is passing a garbage isNull flag to the function
it calls :-(. None of the functions "usually" called this way pay
attention to isNull, but plpgsql functions sure do.

Turns out I had already fixed this for 7.1 as a side-effect of some
other work, but I will stick a patch into 7.0.1. If you're in a hurry,
the bug is in src/backend/tcop/fastpath.c, and the appropriate patch is

#ifndef NO_FASTPATH
+ isNull = false;
retval = fmgr_array_args(fid, nargs, arg, &isNull);
#else
retval = NULL;
#endif /* NO_FASTPATH */

regards, tom lane