Interface PLJavaBasedLanguage.Routines

All Superinterfaces:
PLJavaBasedLanguage
Enclosing interface:
PLJavaBasedLanguage

public static interface PLJavaBasedLanguage.Routines extends PLJavaBasedLanguage
To be implemented by a language that supports routines (that is, functions and/or procedures).
  • 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 before prepare 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 in additionalChecks.

      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 or pg_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, if essentialChecks 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 in essentialChecks.

      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 or pg_upgrade.

      This default implementation checks nothing.

      Throws:
      SQLException
    • prepare

      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-specific memo 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 by TupleTableSlot.) The tuple descriptors seen at this stage may include attributes with polymorphic types, not resolvable to specific types until the Template 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 actual Lookup instance, should return a Routine able to apply the target function's logic when invoked any number of times on Call instances associated with the same Lookup.

      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 same Routine. It could even do so in all cases, if implementing a language where those dynamic details are left to user code.

      Throws:
      SQLException