Class PgAbstractFunction

All Implemented Interfaces:
IFunction, ISearchPath, IStatement, IHashable
Direct Known Subclasses:
PgAggregate, PgFunction, PgProcedure

public abstract class PgAbstractFunction extends PgAbstractStatement implements IFunction
Base implementation of PostgreSQL functions and procedures. Provides common functionality for managing function properties such as language, volatility, security, parallelism, and other PostgreSQL-specific attributes.
  • Field Details

    • FROM_CURRENT

      public static final String FROM_CURRENT
      Constant representing "FROM CURRENT" configuration value for function parameters
      See Also:
  • Method Details

    • getCreationSQL

      public void getCreationSQL(SQLScript script)
      Description copied from interface: IStatement
      Generates the SQL statements needed to create this database object. This is an abstract method that must be implemented by subclasses to provide the specific CREATE SQL for each object type.
      Specified by:
      getCreationSQL in interface IStatement
      Parameters:
      script - the SQL script to append creation statements to
    • appendAlterSQL

      public ObjectState appendAlterSQL(IStatement newCondition, SQLScript script)
      Description copied from interface: IStatement
      Fill script with object changes and return change type
      Specified by:
      appendAlterSQL in interface IStatement
      Parameters:
      newCondition - new object state
      script - script to collect changes
      Returns:
      object change type
    • appendFunctionSignature

      public StringBuilder appendFunctionSignature(StringBuilder sb, boolean includeDefaultValues, boolean includeArgNames)
      Appends signature of statement to sb.
      Parameters:
      sb - StringBuilder to append signature to
      includeDefaultValues - whether to include default values in signature
      includeArgNames - whether to include argument names in signature
      Returns:
      the same StringBuilder instance for chaining
    • canDropBeforeCreate

      public boolean canDropBeforeCreate()
      Description copied from interface: IStatement
      Checks if this statement can be dropped before being recreated. Override in subclasses that support drop-before-create behavior.
      Specified by:
      canDropBeforeCreate in interface IStatement
      Overrides:
      canDropBeforeCreate in class AbstractStatement
      Returns:
      true if the statement can be dropped before recreation
    • needDrop

      public boolean needDrop(IFunction newFunction)
      Description copied from interface: IFunction
      Determines whether this function needs to be dropped before creating the new version.
      Specified by:
      needDrop in interface IFunction
      Parameters:
      newFunction - the new function version to compare against
      Returns:
      true if the function needs to be dropped and recreated
    • getName

      public String getName()
      Alias for getSignature() which provides a unique function ID.

      Use AbstractStatement.getBareName() to get just the function name.

      Specified by:
      getName in interface IStatement
      Overrides:
      getName in class AbstractStatement
      Returns:
      the statement name
    • appendFullName

      public void appendFullName(StringBuilder sb)
    • setWindow

      public void setWindow(boolean isWindow)
    • getLanguage

      public String getLanguage()
    • setLanguageCost

      public void setLanguageCost(String language, Float cost)
      Sets the function language and cost. Cost is only set if it differs from the default value for the given language type.
      Parameters:
      language - function language
      cost - function execution cost, null to use default
    • setVolatileType

      public void setVolatileType(String volatileType)
    • setStrict

      public void setStrict(boolean isStrict)
    • setSecurityDefiner

      public void setSecurityDefiner(boolean isSecurityDefiner)
    • setLeakproof

      public void setLeakproof(boolean isLeakproof)
    • setRows

      public void setRows(float rows)
    • getParallel

      public String getParallel()
    • setParallel

      public void setParallel(String parallel)
    • setBody

      public void setBody(String body)
    • addTransform

      public void addTransform(String datatype)
      Adds a data type transform for this function.
      Parameters:
      datatype - data type to add transform for
    • addConfiguration

      public void addConfiguration(String par, String val)
      Adds a configuration parameter for this function.
      Parameters:
      par - parameter name
      val - parameter value
    • setSupportFunc

      public void setSupportFunc(String supportFunc)
    • setExecuteOn

      public void setExecuteOn(String executeOn)
    • getReturnsColumns

      public Map<String,String> getReturnsColumns()
      Description copied from interface: IFunction
      Gets the return columns for table-valued functions.
      Specified by:
      getReturnsColumns in interface IFunction
      Returns:
      unmodifiable RETURNS TABLE map
    • addReturnsColumn

      public void addReturnsColumn(String name, String type)
      Adds a column to the RETURNS TABLE definition.
      Parameters:
      name - column name
      type - column type
    • isInStatementBody

      public boolean isInStatementBody()
    • setInStatementBody

      public void setInStatementBody(boolean inStatementBody)
    • getSignature

      public String getSignature()
      Returns function signature. It consists of unquoted name and argument data types.
      Returns:
      function signature
    • addArgument

      public void addArgument(Argument argDst)
    • getArguments

      public List<IArgument> getArguments()
      Description copied from interface: IFunction
      Gets the list of function arguments.
      Specified by:
      getArguments in interface IFunction
      Returns:
      the list of arguments
    • getQualifiedName

      public String getQualifiedName()
      Description copied from interface: IStatement
      Gets the fully qualified name of this statement.
      Specified by:
      getQualifiedName in interface IStatement
      Overrides:
      getQualifiedName in class AbstractStatement
      Returns:
      fully qualified (up to schema) dot-delimited object name. Identifiers are quoted.
    • computeHash

      public void computeHash(Hasher hasher)
      Description copied from interface: IHashable
      Computes the hash of the implementing object using the provided hasher. The implementation should call appropriate put methods on the hasher for all fields that should contribute to the hash value.
      Specified by:
      computeHash in interface IHashable
      Parameters:
      hasher - the hasher instance to use for hash computation
    • compare

      public boolean compare(IStatement obj)
      Description copied from class: AbstractStatement
      This method does not account for nested child PgStatements. Shallow version of AbstractStatement.equals(Object)
      Specified by:
      compare in interface IStatement
      Overrides:
      compare in class AbstractStatement