Class 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 its ResultSet (wrapped in a ResultSetHandle in a static for later retrieval. The unstashResultSet 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 connection fetchSize, to ensure the stashed ResultSet has work to do.

    • Method Detail

      • stashResultSet

        @Function(schema="javatest",
                  provides="Holdability.stash")
        public static void stashResultSet()
                                   throws SQLException
        Query all rows from pg_description, but stash the ResultSet for retrieval later in the same transaction by unstashResultSet.

        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 by stashResultSet.
        Throws:
        SQLException