Class 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 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
    • appendComments

      public void appendComments(SQLScript script)
      Description copied from class: AbstractStatement
      Appends comment SQL to the script if this statement has comments.
      Overrides:
      appendComments in class AbstractStatement
      Parameters:
      script - the SQL script to append comments 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
    • isRecreated

      public final boolean isRecreated(ITable newTable, ISettings settings)
      Description copied from interface: ITable
      Compares this table with the newTable to 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:
      isRecreated in interface ITable
      Parameters:
      newTable - the new table definition to compare against
      settings - application settings that may affect the comparison logic
      Returns:
      true if the table requires recreation (DROP and CREATE) rather than being alterable, false if 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

      public boolean compareIgnoringColumnOrder(ITable newTable)
      Specified by:
      compareIgnoringColumnOrder in interface ITable
      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: ITable
      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.
      Specified by:
      appendMoveDataSql in interface ITable
    • getColumns

      public List<IColumn> getColumns()
      Specified by:
      getColumns in interface ITable
    • fillChildrenList

      public void fillChildrenList(List<Collection<? extends AbstractStatement>> l)
      Overrides:
      fillChildrenList in class PgAbstractStatementContainer
    • addChild

      public void addChild(IStatement st)
      Description copied from interface: IStatementContainer
      Adds a child statement to this container.
      Specified by:
      addChild in interface IStatementContainer
      Overrides:
      addChild in class PgAbstractStatementContainer
      Parameters:
      st - the child statement to add
    • getChild

      public AbstractStatement getChild(String name, DbObjType type)
      Description copied from interface: IStatementContainer
      Gets a child statement by name and type.
      Specified by:
      getChild in interface IStatementContainer
      Overrides:
      getChild in class PgAbstractStatementContainer
      Parameters:
      name - the name of the child to find
      type - the type of the child to find
      Returns:
      the child statement, or null if not found
    • getChildrenByType

      public Collection<IStatement> getChildrenByType(DbObjType type)
      Description copied from interface: IStatementContainer
      get all children by type
      Specified by:
      getChildrenByType in interface IStatementContainer
      Overrides:
      getChildrenByType in class PgAbstractStatementContainer
      Parameters:
      type - the type of the children
      Returns:
      unmodifiable collection of child statement, or empty list
    • isClustered

      public boolean isClustered()
      Description copied from class: PgAbstractStatementContainer
      Checks if this container has any clustered indexes or constraints.
      Overrides:
      isClustered in class PgAbstractStatementContainer
    • getConstraints

      public Collection<IConstraint> getConstraints()
      Getter for constraints. The list cannot be modified.
      Specified by:
      getConstraints in interface ITable
      Specified by:
      getConstraints in class PgAbstractStatementContainer
      Returns:
      constraints
    • addOption

      public void addOption(String option, String value)
      Description copied from interface: IOptionContainer
      Adds an option to this container.
      Specified by:
      addOption in interface IOptionContainer
      Parameters:
      option - the option key
      value - the option value
    • getOptions

      public Map<String,String> getOptions()
      Description copied from interface: IOptionContainer
      Gets all options for this container.
      Specified by:
      getOptions in interface IOptionContainer
      Returns:
      a map of option keys to values
    • getRelationColumns

      public Stream<Pair<String,String>> getRelationColumns()
      Description copied from interface: IRelation
      Gets the columns of this relation as name-type pairs.
      Specified by:
      getRelationColumns in interface IRelation
      Returns:
      a stream of column name and type pairs
    • addInherits

      public void addInherits(String schemaName, String tableName)
      Adds a parent table to the inheritance list.
      Parameters:
      schemaName - parent table schema name.
      tableName - parent table name
    • getInherits

      public List<Inherits> getInherits()
      Getter for inherits.
      Returns:
      inherits
    • hasInherits

      public boolean hasInherits()
      Checks if this table has any inheritance relationships.
      Returns:
      true if table inherits from other tables
    • putTriggerState

      public void putTriggerState(String triggerName, PgTriggerState state)
      Sets the state of a specific trigger on this table.
      Parameters:
      triggerName - name of the trigger
      state - desired trigger state
    • setHasOids

      public void setHasOids(boolean hasOids)
    • getConstraint

      public PgConstraint getConstraint(String name)
    • getColumn

      public PgColumn getColumn(String name)
      Finds column according to specified column name.
      Specified by:
      getColumn in interface ITable
      Parameters:
      name - name of the column to be searched
      Returns:
      found column or null if no such column has been found
    • addColumn

      public void addColumn(PgColumn column)
    • 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
    • computeChildrenHash

      public void computeChildrenHash(Hasher hasher)
      Overrides:
      computeChildrenHash in class PgAbstractStatementContainer
    • 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
    • compareChildren

      public boolean compareChildren(AbstractStatement obj)
      Description copied from class: AbstractStatement
      Deep part of AbstractStatement.equals(Object). Compares all object's child PgStatements for equality.
      Overrides:
      compareChildren in class PgAbstractStatementContainer