Class PgAbstractTable
java.lang.Object
org.pgcodekeeper.core.database.base.schema.AbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgAbstractStatement
org.pgcodekeeper.core.database.pg.schema.PgAbstractStatementContainer
org.pgcodekeeper.core.database.pg.schema.PgAbstractTable
- All Implemented Interfaces:
IOptionContainer,IRelation,ISearchPath,IStatement,IStatementContainer,ITable,IHashable
- Direct Known Subclasses:
GpExternalTable,PgAbstractForeignTable,PgAbstractRegularTable
public abstract class PgAbstractTable
extends PgAbstractStatementContainer
implements ITable, IOptionContainer
Base PostgreSQL table class providing common functionality for all PostgreSQL table types.
Handles table inheritance, trigger states, column management, and various PostgreSQL-specific
table features like WITH OIDS, row-level security, and storage parameters.
- Since:
- 5.3.1.
- Author:
- galiev_mr
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddChild(IStatement st) Adds a child statement to this container.voidvoidaddInherits(String schemaName, String tableName) Adds a parent table to the inheritance list.voidAdds an option to this container.appendAlterSQL(IStatement newCondition, SQLScript script) Fill script with object changes and return change typevoidappendComments(SQLScript script) Appends comment SQL to the script if this statement has comments.voidappendMoveDataSql(IStatement newCondition, SQLScript script, String tblTmpBareName, List<String> identityCols) Adds commands to the script for move data from the temporary table to the new table, given the identity columns, and a command to delete the temporary table.booleancompare(IStatement obj) This method does not account for nested child PgStatements.booleanDeep part ofAbstractStatement.equals(Object).booleancompareIgnoringColumnOrder(ITable newTable) voidcomputeChildrenHash(Hasher hasher) voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.voidfillChildrenList(List<Collection<? extends AbstractStatement>> l) Gets a child statement by name and type.getChildrenByType(DbObjType type) get all children by typeFinds column according to specified columnname.getConstraint(String name) Getter forconstraints.voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.Getter forinherits.Gets all options for this container.Gets the columns of this relation as name-type pairs.booleanChecks if this table has any inheritance relationships.booleanChecks if this container has any clustered indexes or constraints.final booleanisRecreated(ITable newTable, ISettings settings) Compares this table with thenewTableto determine if a full table recreation is required.voidputTriggerState(String triggerName, PgTriggerState state) Sets the state of a specific trigger on this table.voidsetHasOids(boolean hasOids) voidSorts columns on table.Methods inherited from class org.pgcodekeeper.core.database.pg.schema.PgAbstractStatementContainer
getIndex, getIndexes, getPolicies, getPolicy, getRule, getTrigger, getTriggersMethods 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, appendPrivileges, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, deepCopy, equals, fillDescendantsList, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSeparator, getSQL, getTwin, hasChildren, hashCode, isLib, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, shallowCopy, toStringMethods inherited from interface org.pgcodekeeper.core.database.api.schema.IOptionContainer
compareOptionsMethods 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, canDropBeforeCreate, clearPrivileges, deepCopy, formatSql, getAuthor, getBareName, getChildren, getComment, getDependencies, getDescendants, getDropSQL, getLibName, getLocation, getName, getOwner, getParent, getPrivileges, getQualifiedName, getQuotedName, getQuoter, getRenameCommand, getSeparator, getSQL, getTwin, getTypeName, hasChildren, isLib, isOwned, quote, setComment, setLibName, setLocation, setOwner, shallowCopyMethods inherited from interface org.pgcodekeeper.core.database.api.schema.ITable
getStatementType
-
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
-
appendComments
Description copied from class:AbstractStatementAppends comment SQL to the script if this statement has comments.- Overrides:
appendCommentsin classAbstractStatement- Parameters:
script- the SQL script to append comments 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
-
isRecreated
Description copied from interface:ITableCompares this table with thenewTableto determine if a full table recreation is required. A full recreation (DROP and CREATE) is needed when the tables differ in ways that cannot be altered using ALTER TABLE statements.- Specified by:
isRecreatedin interfaceITable- Parameters:
newTable- the new table definition to compare againstsettings- application settings that may affect the comparison logic- Returns:
trueif the table requires recreation (DROP and CREATE) rather than being alterable,falseif the changes can be applied via ALTER TABLE
-
sortColumns
public void sortColumns()Sorts columns on table.
First the usual columns in the order of adding, then sorted alphabetically the inheritance columns -
compareIgnoringColumnOrder
- Specified by:
compareIgnoringColumnOrderin interfaceITable- Parameters:
newTable- new state of the table- Returns:
- true if the tables are identical
-
appendMoveDataSql
public void appendMoveDataSql(IStatement newCondition, SQLScript script, String tblTmpBareName, List<String> identityCols) Description copied from interface:ITableAdds commands to the script for move data from the temporary table to the new table, given the identity columns, and a command to delete the temporary table.- Specified by:
appendMoveDataSqlin interfaceITable
-
getColumns
- Specified by:
getColumnsin interfaceITable
-
fillChildrenList
- Overrides:
fillChildrenListin classPgAbstractStatementContainer
-
addChild
Description copied from interface:IStatementContainerAdds a child statement to this container.- Specified by:
addChildin interfaceIStatementContainer- Overrides:
addChildin classPgAbstractStatementContainer- Parameters:
st- the child statement to add
-
getChild
Description copied from interface:IStatementContainerGets a child statement by name and type.- Specified by:
getChildin interfaceIStatementContainer- Overrides:
getChildin classPgAbstractStatementContainer- Parameters:
name- the name of the child to findtype- the type of the child to find- Returns:
- the child statement, or null if not found
-
getChildrenByType
Description copied from interface:IStatementContainerget all children by type- Specified by:
getChildrenByTypein interfaceIStatementContainer- Overrides:
getChildrenByTypein classPgAbstractStatementContainer- Parameters:
type- the type of the children- Returns:
- unmodifiable collection of child statement, or empty list
-
isClustered
public boolean isClustered()Description copied from class:PgAbstractStatementContainerChecks if this container has any clustered indexes or constraints.- Overrides:
isClusteredin classPgAbstractStatementContainer
-
getConstraints
Getter forconstraints. The list cannot be modified.- Specified by:
getConstraintsin interfaceITable- Specified by:
getConstraintsin classPgAbstractStatementContainer- Returns:
constraints
-
addOption
Description copied from interface:IOptionContainerAdds an option to this container.- Specified by:
addOptionin interfaceIOptionContainer- Parameters:
option- the option keyvalue- the option value
-
getOptions
Description copied from interface:IOptionContainerGets all options for this container.- Specified by:
getOptionsin interfaceIOptionContainer- Returns:
- a map of option keys to values
-
getRelationColumns
Description copied from interface:IRelationGets the columns of this relation as name-type pairs.- Specified by:
getRelationColumnsin interfaceIRelation- Returns:
- a stream of column name and type pairs
-
addInherits
Adds a parent table to the inheritance list.- Parameters:
schemaName- parent table schema name.tableName- parent table name
-
getInherits
Getter forinherits.- Returns:
inherits
-
hasInherits
public boolean hasInherits()Checks if this table has any inheritance relationships.- Returns:
- true if table inherits from other tables
-
putTriggerState
Sets the state of a specific trigger on this table.- Parameters:
triggerName- name of the triggerstate- desired trigger state
-
setHasOids
public void setHasOids(boolean hasOids) -
getConstraint
-
getColumn
Finds column according to specified columnname. -
addColumn
-
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
-
computeChildrenHash
- Overrides:
computeChildrenHashin classPgAbstractStatementContainer
-
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
-
compareChildren
Description copied from class:AbstractStatementDeep part ofAbstractStatement.equals(Object). Compares all object's child PgStatements for equality.- Overrides:
compareChildrenin classPgAbstractStatementContainer
-