All Packages Class Hierarchy This Package Previous Next Index
java.lang.Object | +----postgresql.fastpath.Fastpath
This is a means of executing functions imbeded in the postgresql backend from within a java application.
It is based around the file src/interfaces/libpq/fe-exec.c
Implementation notes:
Network protocol:
The code within the backend reads integers in reverse.
There is work in progress to convert all of the protocol to network order but it may not be there for v6.3
When fastpath switches, simply replace SendIntegerReverse() with SendInteger()
Important Notice
This is called from postgresql.Connection, and should not be called
from client code.
If addFunction() or addFunctions() have not been called for this name, then an SQLException is thrown.
public Fastpath(Connection conn,
PG_Stream stream)
Important Notice
This is called from postgresql.Connection, and should not be called
from client code.
public Object fastpath(int fnid,
boolean resulttype,
FastpathArg args[]) throws SQLException
public Object fastpath(String name,
boolean resulttype,
FastpathArg args[]) throws SQLException
public int getInteger(String name,
FastpathArg args[]) throws SQLException
public byte[] getData(String name,
FastpathArg args[]) throws SQLException
public void addFunction(String name,
int fnid)
User code should use the addFunctions method, which is based upon a query, rather than hard coding the oid. The oid for a function is not guaranteed to remain static, even on different servers of the same version.
public void addFunctions(ResultSet rs) throws SQLException
It reads the entire ResultSet, loading the values into the function table.
REMEMBER to close() the resultset after calling this!!
Implementation note about function name lookups:
PostgreSQL stores the function id's and their corresponding names in the pg_proc table. To speed things up locally, instead of querying each function from that table when required, a Hashtable is used. Also, only the function's required are entered into this table, keeping connection times as fast as possible.
The postgresql.LargeObject class performs a query upon it's startup, and passes the returned ResultSet to the addFunctions() method here.
Once this has been done, the LargeObject api refers to the functions by name.
Dont think that manually converting them to the oid's will work. Ok, they will for now, but they can change during development (there was some discussion about this for V7.0), so this is implemented to prevent any unwarranted headaches in the future.
public int getID(String name) throws SQLException
If addFunction() or addFunctions() have not been called for this name, then an SQLException is thrown.
All Packages Class Hierarchy This Package Previous Next Index