- java.lang.Object
-
- org.postgresql.pljava.management.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 anySECURITY 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 usingSET LOCAL pljava.implementors TO thing, thing, thing
. It is re-parsed each timeforImplementor
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 finaltrue
gives the setting the same lifetime asSET LOCAL
, that is, it reverts when the transaction is over.The possibility that, for certain implementor names,
forImplementor
could return other subclasses ofDDRExecutor
with specialized behavior, is definitely contemplated.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
DDRExecutor()
-
Method Summary
Modifier and Type Method Description abstract void
execute(String sql, Connection conn)
Execute the commandsql
using the connectionconn
, according to whatever meaning of "execute" the targetDDRExecutor
subclass implements.static DDRExecutor
forImplementor(Lexicals.Identifier name)
Return aDDRExecutor
instance chosen according to the supplied implementor name and currentpljava.implementors
value.
-
-
-
Method Detail
-
execute
public abstract void execute(String sql, Connection conn) throws SQLException
Execute the commandsql
using the connectionconn
, according to whatever meaning of "execute" the targetDDRExecutor
subclass implements.- Parameters:
sql
- The command to executeconn
- The connection to use- Throws:
SQLException
- Anything thrown in the course of executingsql
-
forImplementor
public static DDRExecutor forImplementor(Lexicals.Identifier name) throws SQLException
Return aDDRExecutor
instance chosen according to the supplied implementor name and currentpljava.implementors
value. See the class description for more.- Parameters:
name
- The<implementor name>
associated with the deployment descriptor<command>
, ornull
if the<command>
is an unadorned<SQL statement>
instead of an<implementor block>
.- Throws:
SQLException
-
-