- All Superinterfaces:
PLJavaBasedLanguage
- Enclosing interface:
PLJavaBasedLanguage
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.postgresql.pljava.PLJavaBasedLanguage
PLJavaBasedLanguage.InlineBlocks, PLJavaBasedLanguage.Routine, PLJavaBasedLanguage.Routines, PLJavaBasedLanguage.Template
-
Method Summary
Modifier and TypeMethodDescriptiondefault void
additionalChecks
(RegProcedure<ProceduralLanguage.PLJavaBased> subject, boolean checkBody) Performs additional validation checks on a proposed PL/Java-based routine.default void
essentialChecks
(RegProcedure<ProceduralLanguage.PLJavaBased> subject, boolean checkBody) Performs the essential validation checks on a proposed PL/Java-based routine.Prepares a template for a call of the routine target.
-
Method Details
-
essentialChecks
default void essentialChecks(RegProcedure<ProceduralLanguage.PLJavaBased> subject, boolean checkBody) throws SQLException Performs the essential validation checks on a proposed PL/Java-based routine.This method should check (when checkBody is true) all the essential conditions that
prepare
will assume have been checked. Because there is no guarantee that validation at routine-creation time always occurred, PL/Java's dispatcher will call this method not only at validation time, but also just beforeprepare
is first called at run time (always passing true for checkBody in that case).This method should throw an informative exception for any check that fails, otherwise returning normally.
Checks that are helpful at routine-creation time, but not essential to correctness of
prepare
, can be made inadditionalChecks
.If checkBody is false, less-thorough checks may be needed. The details are left to the language implementation; in general, basic checks of syntax, matching parameter counts, and so on are ok, while checks that load or compile user code or depend on other database state may be better avoided. The validator may be invoked with checkBody false at times when not all expected state may be in place, such as during
pg_restore
orpg_upgrade
.This method is invoked with checkBody false only if the receiver has already been loaded and instantiated. If it has not, and checkBody is false, PL/Java does not attempt to do so, and treats the validation as successful.
This default implementation checks nothing.
- Throws:
SQLException
-
additionalChecks
default void additionalChecks(RegProcedure<ProceduralLanguage.PLJavaBased> subject, boolean checkBody) throws SQLException Performs additional validation checks on a proposed PL/Java-based routine.This method should be used for checks that may give helpful feedback at routine-creation time, but can be skipped at run time because the correct behavior of
prepare
does not depend on them. PL/Java calls this method only at routine-creation time, ifessentialChecks
completed normally.This method should throw an informative exception for any check that fails, otherwise returning normally.
Checks of conditions essential to correctness of
prepare
must be made inessentialChecks
.If checkBody is false, less-thorough checks may be needed. The details are left to the language implementation; in general, basic checks of syntax, matching parameter counts, and so on are ok, while checks that load or compile user code or depend on other database state may be better avoided. The validator may be invoked with checkBody false at times when not all expected state may be in place, such as during
pg_restore
orpg_upgrade
.This default implementation checks nothing.
- Throws:
SQLException
-
prepare
PLJavaBasedLanguage.Template prepare(RegProcedure<ProceduralLanguage.PLJavaBased> target) throws SQLException Prepares a template for a call of the routine target.The information available at this stage comes from the system catalogs, reflecting the static declaration of the target routine. The methods of target can be used to examine that catalog information; the
memo
method retrieves a PL/Java-specificmemo
with some derived information, including tuple descriptors for the inputs and outputs. (All routines, including those treated by PostgreSQL as returning a scalar result, are presented to a PL/Java handler with the inputs and outputs represented byTupleTableSlot
.) The tuple descriptors seen at this stage may include attributes with polymorphic types, not resolvable to specific types until theTemplate
instance this method returns is later applied at an actual call site.This method should return a
Template
, which may encapsulate any useful precomputed values based on the catalog information this method consulted.The template, when its
specialize
method is invoked on an actualLookup
instance, should return aRoutine
able to apply the target function's logic when invoked any number of times onCall
instances associated with the sameLookup
.When there is no polymorphic or variadic-"any" funny business in target's declaration, this method may return a
Template
that ignores its argument and always returns the sameRoutine
. It could even do so in all cases, if implementing a language where those dynamic details are left to user code.- Throws:
SQLException
-