Package org.pgcodekeeper.core.schema.pg
Class AbstractPgTable
java.lang.Object
org.pgcodekeeper.core.schema.PgStatement
org.pgcodekeeper.core.schema.PgStatementContainer
org.pgcodekeeper.core.schema.AbstractTable
org.pgcodekeeper.core.schema.pg.AbstractPgTable
- All Implemented Interfaces:
IHashable,IOptionContainer,IRelation,ISearchPath,IStatement,IStatementContainer
- Direct Known Subclasses:
AbstractForeignTable,AbstractRegularTable,GpExternalTable
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
-
Field Summary
Fields inherited from class org.pgcodekeeper.core.schema.PgStatement
GOFields inherited from interface org.pgcodekeeper.core.schema.IOptionContainer
GP_OPTION_LIST -
Method Summary
Modifier and TypeMethodDescriptionvoidaddInherits(String schemaName, String tableName) Adds a parent table to the inheritance list.appendAlterSQL(PgStatement 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.booleancompare(PgStatement obj) This method does not account for nested child PgStatements.voidcomputeHash(Hasher hasher) Computes the hash of the implementing object using the provided hasher.getColsForMovingData(AbstractTable newTable) voidgetCreationSQL(SQLScript script) Generates the SQL statements needed to create this database object.Getter forinherits.Gets the columns of this relation as name-type pairs.booleanChecks if this table has any inheritance relationships.voidputTriggerState(String triggerName, TriggerState state) Sets the state of a specific trigger on this table.voidsetHasOids(boolean hasOids) Copies all object properties into a new object and leaves all its children empty.voidSorts columns on table.Methods inherited from class org.pgcodekeeper.core.schema.AbstractTable
addColumn, addConstraint, addOption, appendMoveDataSql, columnAdder, compareChildren, compareIgnoringColumnOrder, computeChildrenHash, containsColumn, getAlterTable, getColumn, getColumns, getConstraint, getConstraints, getOption, getOptions, getStatementType, isRecreatedMethods inherited from class org.pgcodekeeper.core.schema.PgStatementContainer
addChild, addIndex, addPolicy, addRule, addTrigger, getChild, getContainingSchema, getIndex, getIndexes, getPolicies, getPolicy, getRule, getRules, getTrigger, getTriggers, isClusteredMethods inherited from class org.pgcodekeeper.core.schema.PgStatement
addAllDeps, addDep, addPrivilege, appendAlterComments, appendOwnerSQL, canDrop, canDropBeforeCreate, checkComments, clearPrivileges, deepCopy, equals, getAuthor, getBareName, getChildren, getComment, getDbType, getDeps, getDescendants, getDropSQL, getDropSQL, getLibName, getLocation, getName, getObjectState, getObjectState, getOwner, getParent, getPrivileges, getQualifiedName, getSQL, getTwin, getTypeName, hasChildren, hashCode, isLib, isOwned, isSubElement, setAuthor, setComment, setLibName, setLocation, setOwner, setParent, toStringMethods inherited from interface org.pgcodekeeper.core.schema.IOptionContainer
compareOptionsMethods inherited from interface org.pgcodekeeper.core.schema.ISearchPath
getDatabase, getSchemaNameMethods inherited from interface org.pgcodekeeper.core.schema.IStatement
getBareName, getComment, getName, getParent, getQualifiedName
-
Method Details
-
getCreationSQL
Description copied from class:PgStatementGenerates 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 classPgStatement- Parameters:
script- the SQL script to append creation statements to
-
appendComments
Description copied from class:PgStatementAppends comment SQL to the script if this statement has comments.- Overrides:
appendCommentsin classPgStatement- Parameters:
script- the SQL script to append comments to
-
appendAlterSQL
Description copied from class:PgStatementFill script with object changes and return change type- Specified by:
appendAlterSQLin classPgStatement- Parameters:
newCondition- new object statescript- script to collect changes- Returns:
- object change type
-
getRelationColumns
Description copied from interface:IRelationGets the columns of this relation as name-type pairs.- Specified by:
getRelationColumnsin interfaceIRelation- Overrides:
getRelationColumnsin classAbstractTable- 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) -
sortColumns
public void sortColumns()Sorts columns on table.
First the usual columns in the order of adding, then sorted alphabetically the inheritance columns -
compare
Description copied from class:PgStatementThis method does not account for nested child PgStatements. Shallow version ofPgStatement.equals(Object)- Overrides:
comparein classAbstractTable
-
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- Overrides:
computeHashin classAbstractTable- Parameters:
hasher- the hasher instance to use for hash computation
-
shallowCopy
Description copied from class:PgStatementCopies all object properties into a new object and leaves all its children empty.- Overrides:
shallowCopyin classAbstractTable- Returns:
- shallow copy of a DB object.
-
getColsForMovingData
-