All Implemented Interfaces:
ISchema, IStatement, IStatementContainer, IHashable

public class PgSchema extends PgAbstractStatement implements ISchema
PostgreSQL schema implementation. Schemas are namespaces that contain database objects like tables, functions, types, and operators. Each schema can have its own set of permissions and provides object organization.
  • Constructor Details

    • PgSchema

      public PgSchema(String name)
      Creates a new PostgreSQL schema.
      Parameters:
      name - schema name
  • 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
    • getDomain

      public PgDomain getDomain(String name)
    • getCollation

      public PgCollation getCollation(String name)
    • getFtsParser

      public PgFtsParser getFtsParser(String name)
    • getFtsTemplate

      public PgFtsTemplate getFtsTemplate(String name)
    • getFtsDictionary

      public PgFtsDictionary getFtsDictionary(String name)
    • getFtsConfiguration

      public PgFtsConfiguration getFtsConfiguration(String name)
    • getOperator

      public PgOperator getOperator(String signature)
      Gets an operator by its signature.
      Parameters:
      signature - operator signature including arguments
      Returns:
      operator or null if not found
    • getStatistics

      public PgStatistics getStatistics(String name)
    • getOperators

      public Collection<IOperator> getOperators()
      Gets all operators in this schema.
      Returns:
      unmodifiable collection of operators
    • getType

      public PgAbstractType getType(String name)
      Finds type according to specified type name.
      Parameters:
      name - name of the type to be searched
      Returns:
      found type or null if no such type has been found
    • fillChildrenList

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

      public void fillDescendantsList(List<Collection<? extends AbstractStatement>> l)
      Overrides:
      fillDescendantsList in class AbstractStatement
    • 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
      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
      Parameters:
      type - the type of the children
      Returns:
      unmodifiable collection of child statement, or empty list
    • getFunction

      public PgAbstractFunction getFunction(String signature)
      Finds function according to specified function signature.
      Parameters:
      signature - signature of the function to be searched
      Returns:
      found function or null if no such function has been found
    • getSequence

      public PgSequence getSequence(String name)
      Finds sequence according to specified sequence name.
      Parameters:
      name - name of the sequence to be searched
      Returns:
      found sequence or null if no such sequence has been found
    • getTable

      public PgAbstractTable getTable(String name)
      Finds table according to specified table name.
      Parameters:
      name - name of the table to be searched
      Returns:
      found table or null if no such table has been found
    • getTables

      public Collection<PgAbstractTable> getTables()
    • getView

      public PgAbstractView getView(String name)
      Finds view according to specified view name.
      Parameters:
      name - name of the view to be searched
      Returns:
      found view or null if no such view has been found
    • addChild

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

      public IRelation getRelation(String name)
      Description copied from interface: ISchema
      Gets a relation by name.
      Specified by:
      getRelation in interface ISchema
      Parameters:
      name - the relation name
      Returns:
      found relation or null if no such relation has been found
    • getRelations

      public Stream<IRelation> getRelations()
      Description copied from interface: ISchema
      Gets all relations (tables, views, sequences) in this schema.
      Specified by:
      getRelations in interface ISchema
      Returns:
      a stream of relations
    • getFunctions

      public Collection<IFunction> getFunctions()
      Getter for functions. The list cannot be modified.
      Returns:
      functions
    • getSequences

      public Collection<PgSequence> getSequences()
    • getStatementContainer

      public PgAbstractStatementContainer getStatementContainer(String name)
      Gets a statement container by name.
      Specified by:
      getStatementContainer in interface ISchema
      Parameters:
      name - the name of the container to find
      Returns:
      the statement container with the given name, or null if not found
    • getStatementContainers

      public Stream<PgAbstractStatementContainer> getStatementContainers()
      Gets a stream of all statement containers in this schema.
      Returns:
      a stream of statement containers
    • getIndexByName

      public PgIndex getIndexByName(String indexName)
      Finds an index by name across all tables and views in this schema.
      Parameters:
      indexName - the name of the index to find
      Returns:
      the index with the given name, or null if not found
    • getConstraintByName

      public PgConstraint getConstraintByName(String constraintName)
      Finds a constraint by name across all tables and views in this schema.
      Parameters:
      constraintName - the name of the constraint to find
      Returns:
      the constraint with the given name, or null if not found
    • 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
    • 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 AbstractStatement