- java.lang.Object
-
- org.postgresql.pljava.internal.Function
-
public class Function extends Object
Methods to look up a PL/Java function and prepare it for invocation.This class contains, mostly, logic that was originally in
Function.c
and has been ported to Java for better maintainability and adaptability. Many methods here have similar or identical names to the C functions they replace.When a PL/Java function is called, the C call handler will call the C
Function_getFunction
, which will delegate toFunction_create
if the function has not already been called. That C function calls thecreate
method here, which ultimately (after all parsing of theCREATE FUNCTION ... AS ...
information, matching up of parameter and return types, etc.) will return anInvocable
to use when invoking the function.This remains a hybrid approach, in which PL/Java's legacy C
Type
infrastructure is used for converting the parameter and return values, and a CFunction_
structure kept in a C hash table holds the details needed for invocation, including theInvocable
created here. The methods in this class also use some JNI calls to contribute and retrieve additional details that belong in the C structure.The
Invocable
returned here bycreate
will have return typeObject
in all cases, and no formal parameters. It can contain bound references to the statics_referenceParameters
ands_primitiveParameters
declared in this class, and will fetch the parameters from there (where invocation code inFunction.c
will have put them) at the time of invocation. The parameter areas are static, but invocation takes place only on the PG thread, and the method handles created here will have fetched all of the values to push on the stack before the (potentially reentrant) target method is invoked. If the method has a primitive return type, its return value will be placed in the first slot ofs_primitiveParameters
and theInvocable
returns null. Naturally, the (potentially reentrant) target method has already returned before that value is placed in the static slot.
-
-
Method Summary
Modifier and Type Method Description static org.postgresql.pljava.internal.EntryPoints.Invocable<?>
create(long wrappedPtr, ResultSet procTup, String langName, String schemaName, boolean trusted, boolean calledAsTrigger, boolean forValidator, boolean checkBody)
Parse the function specification inprocTup
, initializing most fields of the CFunction
structure, and returning anInvocable
for invoking the method, or null in the case of a UDT.static Class<? extends SQLData>
getClassIfUDT(ResultSet procTup, String schemaName)
Return null if theprosrc
field in the providedprocTup
does not have the form of a UDT specification; if it does, return the associated class, loaded with the class loader forschemaName
.
-
-
-
Method Detail
-
getClassIfUDT
public static Class<? extends SQLData> getClassIfUDT(ResultSet procTup, String schemaName) throws SQLException
Return null if theprosrc
field in the providedprocTup
does not have the form of a UDT specification; if it does, return the associated class, loaded with the class loader forschemaName
.- Throws:
SQLException
-
create
public static org.postgresql.pljava.internal.EntryPoints.Invocable<?> create(long wrappedPtr, ResultSet procTup, String langName, String schemaName, boolean trusted, boolean calledAsTrigger, boolean forValidator, boolean checkBody) throws SQLException
Parse the function specification inprocTup
, initializing most fields of the CFunction
structure, and returning anInvocable
for invoking the method, or null in the case of a UDT.- Throws:
SQLException
-
-