Class Holdability
- java.lang.Object
-
- org.postgresql.pljava.example.annotation.Holdability
-
- All Implemented Interfaces:
org.postgresql.pljava.ResultSetHandle
@SQLAction(requires={"Holdability.stash","Holdability.unstash"}, install={"SELECT javatest.stashResultSet()","SELECT CASE WHEN 1000 < count(*) THEN javatest.logmessage(\'INFO\', \'Holdability OK\') ELSE javatest.logmessage(\'WARNING\', \'Holdability suspicious\') END FROM javatest.unstashResultSet()"}) public class Holdability extends Object implements org.postgresql.pljava.ResultSetHandle
Demonstrate holdability of ResultSets (test for issue 168).The
stashResultSet
method will execute a query and save itsResultSet
(wrapped in aResultSetHandle
in a static for later retrieval. TheunstashResultSet
method, called later in the same transaction, retrieves and returns the result set. A call after the transaction has ended will fail.The query selects all rows from
pg_description
, a table that should always exist, with more rows than the default connectionfetchSize
, to ensure the stashedResultSet
has work to do.
-
-
Method Summary
Modifier and Type Method Description void
close()
ResultSet
getResultSet()
static void
stashResultSet()
Query all rows frompg_description
, but stash theResultSet
for retrieval later in the same transaction byunstashResultSet
.static org.postgresql.pljava.ResultSetHandle
unstashResultSet()
Return the results stashed earlier in the same transaction bystashResultSet
.
-
-
-
Method Detail
-
stashResultSet
@Function(schema="javatest", provides="Holdability.stash") public static void stashResultSet() throws SQLException
Query all rows frompg_description
, but stash theResultSet
for retrieval later in the same transaction byunstashResultSet
.This must be called in an open, multiple-statement (non-auto) transaction to have any useful effect.
- Throws:
SQLException
-
unstashResultSet
@Function(schema="javatest", type="pg_catalog.pg_description", provides="Holdability.unstash") public static org.postgresql.pljava.ResultSetHandle unstashResultSet() throws SQLException
Return the results stashed earlier in the same transaction bystashResultSet
.- Throws:
SQLException
-
getResultSet
public ResultSet getResultSet() throws SQLException
- Specified by:
getResultSet
in interfaceorg.postgresql.pljava.ResultSetHandle
- Throws:
SQLException
-
close
public void close() throws SQLException
- Specified by:
close
in interfaceorg.postgresql.pljava.ResultSetHandle
- Throws:
SQLException
-
-