Class DDRExecutor


  • public abstract class DDRExecutor
    extends Object
    Abstract class for executing one deployment descriptor <command> on a connection.

    The forImplementor method returns an executor according to the <implementor name> associated with the command. The two possibilities that support standard behavior are a "plain" executor, which simply executes the SQL text (with any SECURITY DEFINER identity dropped), and a "no-op" executor, which (you'll be shocked) does nothing. Normally, a plain executor is returned if the implementor name is null (command is for all implementations) or in the list recognized as being for this implementation (normally just PostgreSQL, case-insensitively, but adjustable as described below). A no-op executor is returned if there is an implementor name and it is anything not on the recognized list.

    Adjusting the recognized implementor names:

    The recognized implementor names are taken from the (comma-separated) string configuration option pljava.implementors, which can be set from ordinary SQL using SET LOCAL pljava.implementors TO thing, thing, thing. It is re-parsed each time forImplementor is called, which happens for every <command> in a deployment descriptor, so that SQL code early in a deployment descriptor can influence which code blocks later are executed.

    The SET LOCAL command shown above only accepts a literal list of elements. It will ordinarily be better for SQL code to add another element to whatever is currently in the list, which is fussier in SQL:

      SELECT set_config('pljava.implementors', 'NewThing,' ||
                        current_setting('pljava.implementors'), true)
     
    where the final true gives the setting the same lifetime as SET LOCAL, that is, it reverts when the transaction is over.

    The possibility that, for certain implementor names, forImplementor could return other subclasses of DDRExecutor with specialized behavior, is definitely contemplated.

    • Constructor Detail

      • DDRExecutor

        protected DDRExecutor()
    • Method Detail

      • execute

        public abstract void execute​(String sql,
                                     Connection conn)
                              throws SQLException
        Execute the command sql using the connection conn, according to whatever meaning of "execute" the target DDRExecutor subclass implements.
        Parameters:
        sql - The command to execute
        conn - The connection to use
        Throws:
        SQLException - Anything thrown in the course of executing sql
      • forImplementor

        public static DDRExecutor forImplementor​(Lexicals.Identifier name)
                                          throws SQLException
        Return a DDRExecutor instance chosen according to the supplied implementor name and current pljava.implementors value. See the class description for more.
        Parameters:
        name - The <implementor name> associated with the deployment descriptor <command>, or null if the <command> is an unadorned <SQL statement> instead of an <implementor block>.
        Throws:
        SQLException