Class PgAbstractFunction
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgAbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgAbstractFunction
- All Implemented Interfaces:
IFunction,ISearchPath,IStatement,IHashable
- Direct Known Subclasses:
PgAggregate,PgFunction,PgProcedure
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassPostgreSQL-specific function argument implementation. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringConstant representing "FROM CURRENT" configuration value for function parameters -
Method Summary
Modifier and TypeMethodDescriptionvoidaddArgument(Argument argDst) voidaddConfiguration(String par, String val) Adds a configuration parameter for this function.voidaddReturnsColumn(String name, String type) Adds a column to the RETURNS TABLE definition.voidaddTransform(String datatype) Adds a data type transform for this function.appendAlterSQL(IStatement newCondition, SQLScript script) Fill script with object changes and return change typevoidappendFunctionSignature(StringBuilder sb, boolean includeDefaultValues, boolean includeArgNames) Appends signature of statement to sb.booleanChecks if this statement can be dropped before being recreated.booleancompare(IStatement obj) This method does not account for nested child PgStatements.voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.Gets the list of function arguments.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.getName()Alias forgetSignature()which provides a unique function ID.Gets the fully qualified name of this statement.Gets the return columns for table-valued functions.Returns function signature.booleanbooleanDetermines whether this function needs to be dropped before creating the new version.voidvoidsetExecuteOn(String executeOn) voidsetInStatementBody(boolean inStatementBody) voidsetLanguageCost(String language, Float cost) Sets the function language and cost.voidsetLeakproof(boolean isLeakproof) voidsetParallel(String parallel) voidsetRows(float rows) voidsetSecurityDefiner(boolean isSecurityDefiner) voidsetStrict(boolean isStrict) voidsetSupportFunc(String supportFunc) voidsetVolatileType(String volatileType) voidsetWindow(boolean isWindow) Methods inherited from class org.pgcodekeeper.core.database.pg.schema.PgAbstractStatement
addPrivilege, appendDefaultPrivileges, appendOwnerSQL, formatSql, getQuoter, getRenameCommand, isOwnedMethods inherited from class org.pgcodekeeper.core.database.base.schema.AbstractStatement
addDependency, appendAlterComments, appendComments, appendPrivileges, canDrop, checkComments, clearPrivileges, compareChildren, deepCopy, equals, fillChildrenList, fillDescendantsList, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getDropSQL, getLibName, getLocation, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getSeparator, getSQL, getTwin, hasChildren, hashCode, isLib, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, shallowCopy, toStringMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IFunction
getReturns, setReturnsMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ISearchPath
getContainingSchema, getDatabase, getSchemaName, toObjectReferenceMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IStatement
addDependency, appendOwnerSQL, canDrop, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getLibName, getLocation, getOwner, getParent, getPrivileges, getQuotedName, getQuoter, getRenameCommand, getSeparator, getSQL, getStatementType, getTwin, getTypeName, hasChildren, isLib, isOwned, quote, setComment, setLibName, setLocation, setOwner, shallowCopy
-
Field Details
-
FROM_CURRENT
Constant representing "FROM CURRENT" configuration value for function parameters- See Also:
-
-
Method Details
-
getCreationSQL
Description copied from interface:IStatementGenerates 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:
getCreationSQLin interfaceIStatement- Parameters:
script- the SQL script to append creation statements to
-
appendAlterSQL
Description copied from interface:IStatementFill script with object changes and return change type- Specified by:
appendAlterSQLin interfaceIStatement- Parameters:
newCondition- new object statescript- 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 toincludeDefaultValues- whether to include default values in signatureincludeArgNames- whether to include argument names in signature- Returns:
- the same StringBuilder instance for chaining
-
canDropBeforeCreate
public boolean canDropBeforeCreate()Description copied from interface:IStatementChecks if this statement can be dropped before being recreated. Override in subclasses that support drop-before-create behavior.- Specified by:
canDropBeforeCreatein interfaceIStatement- Overrides:
canDropBeforeCreatein classAbstractStatement- Returns:
- true if the statement can be dropped before recreation
-
needDrop
Description copied from interface:IFunctionDetermines whether this function needs to be dropped before creating the new version. -
getName
Alias forgetSignature()which provides a unique function ID.Use
AbstractStatement.getBareName()to get just the function name.- Specified by:
getNamein interfaceIStatement- Overrides:
getNamein classAbstractStatement- Returns:
- the statement name
-
appendFullName
-
setWindow
public void setWindow(boolean isWindow) -
getLanguage
-
setLanguageCost
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 languagecost- function execution cost, null to use default
-
setVolatileType
-
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
-
setParallel
-
setBody
-
addTransform
Adds a data type transform for this function.- Parameters:
datatype- data type to add transform for
-
addConfiguration
Adds a configuration parameter for this function.- Parameters:
par- parameter nameval- parameter value
-
setSupportFunc
-
setExecuteOn
-
getReturnsColumns
Description copied from interface:IFunctionGets the return columns for table-valued functions.- Specified by:
getReturnsColumnsin interfaceIFunction- Returns:
- unmodifiable RETURNS TABLE map
-
addReturnsColumn
Adds a column to the RETURNS TABLE definition.- Parameters:
name- column nametype- column type
-
isInStatementBody
public boolean isInStatementBody() -
setInStatementBody
public void setInStatementBody(boolean inStatementBody) -
getSignature
Returns function signature. It consists of unquoted name and argument data types.- Returns:
- function signature
-
addArgument
-
getArguments
Description copied from interface:IFunctionGets the list of function arguments.- Specified by:
getArgumentsin interfaceIFunction- Returns:
- the list of arguments
-
getQualifiedName
Description copied from interface:IStatementGets the fully qualified name of this statement.- Specified by:
getQualifiedNamein interfaceIStatement- Overrides:
getQualifiedNamein classAbstractStatement- Returns:
- fully qualified (up to schema) dot-delimited object name. Identifiers are quoted.
-
computeHash
Description copied from interface:IHashableComputes the hash of the implementing object using the provided hasher. The implementation should call appropriateputmethods on the hasher for all fields that should contribute to the hash value.- Specified by:
computeHashin interfaceIHashable- Parameters:
hasher- the hasher instance to use for hash computation
-
compare
Description copied from class:AbstractStatementThis method does not account for nested child PgStatements. Shallow version ofAbstractStatement.equals(Object)- Specified by:
comparein interfaceIStatement- Overrides:
comparein classAbstractStatement
-