Class PgDatabase

All Implemented Interfaces:
IDatabase, IStatement, IStatementContainer, IHashable

public class PgDatabase extends PgAbstractStatement implements IDatabase
PostgreSQL database implementation. Manages database-level objects such as schemas, extensions, event triggers, foreign data wrappers, servers, user mappings, and casts.
Author:
fordfrog
  • Constructor Details

    • PgDatabase

      public PgDatabase()
      Creates a new PostgreSQL database.
  • Method Details

    • concat

      public void concat(IStatement st)
      Description copied from interface: IDatabase
      Adds library object to database with override
      Specified by:
      concat in interface IDatabase
      Parameters:
      st - the library object to add
    • sortColumns

      public void sortColumns()
      Sorts columns in all tables within all schemas of this database. This is used to ensure consistent column ordering in inherited tables.
    • getStatement

      public final AbstractStatement getStatement(ObjectReference reference)
      Specified by:
      getStatement in interface IDatabase
      Parameters:
      reference - - object reference
      Returns:
      object from database by reference, or null if not found
    • fillDescendantsList

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

      public void fillChildrenList(List<Collection<? extends AbstractStatement>> l)
      Overrides:
      fillChildrenList 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
    • getSchema

      public PgSchema getSchema(String name)
      Returns schema of given name or null if the schema has not been found. If schema name is null then default schema is returned.
      Specified by:
      getSchema in interface IDatabase
      Parameters:
      name - schema name or null which means default schema
      Returns:
      found schema or null
    • getDefaultSchema

      public PgSchema getDefaultSchema()
      Specified by:
      getDefaultSchema in interface IDatabase
    • setDefaultSchema

      public void setDefaultSchema(String name)
      Specified by:
      setDefaultSchema in interface IDatabase
    • 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
    • getExtension

      public PgExtension getExtension(String name)
      Returns extension of given name or null if the extension has not been found.
      Parameters:
      name - extension name
      Returns:
      found extension or null
    • getEventTrigger

      public PgEventTrigger getEventTrigger(String name)
    • getForeignDW

      public PgForeignDataWrapper getForeignDW(String name)
      Returns foreign data wrapper of given name or null if the foreign data wrapper has not been found.
      Parameters:
      name - foreign data wrapper name
      Returns:
      found foreign data wrapper or null
    • getServer

      public PgServer getServer(String name)
    • getCast

      public PgCast getCast(String name)
      Returns cast of given name or null if the cast has not been found.
      Parameters:
      name - cast name
      Returns:
      found cast or null
    • getSchemas

      public Collection<PgSchema> getSchemas()
      Getter for schemas. The list cannot be modified.
      Specified by:
      getSchemas in interface IDatabase
      Returns:
      schemas
    • getVersion

      public ISupportedVersion getVersion()
      Specified by:
      getVersion in interface IDatabase
      Returns:
      default database version
    • addOverride

      public void addOverride(ObjectOverride override)
      Description copied from interface: IDatabase
      Adds object override
      Specified by:
      addOverride in interface IDatabase
      Parameters:
      override - object override
    • getOverrides

      public List<ObjectOverride> getOverrides()
      Description copied from interface: IDatabase
      Gets the list of object overrides for this database.
      Specified by:
      getOverrides in interface IDatabase
      Returns:
      the list of overrides
    • getObjReferences

      public Map<String,Set<ObjectLocation>> getObjReferences()
      Specified by:
      getObjReferences in interface IDatabase
      Returns:
      all object references for this database
    • getAnalysisLaunchers

      public List<IAnalysisLauncher> getAnalysisLaunchers()
      Specified by:
      getAnalysisLaunchers in interface IDatabase
      Returns:
      all analysis launcher for this database
    • addAnalysisLauncher

      public void addAnalysisLauncher(IAnalysisLauncher launcher)
      Description copied from interface: IDatabase
      Add 'analysis launcher' for deferred analyze.
      Specified by:
      addAnalysisLauncher in interface IDatabase
      Parameters:
      launcher - launcher that contains almost everything needed to analyze a statement contained in it
    • addReference

      public void addReference(String fileName, ObjectLocation loc)
      Description copied from interface: IDatabase
      Adds an object reference to the specified file.
      Specified by:
      addReference in interface IDatabase
      Parameters:
      fileName - the file name to associate with the location
      loc - the object location to add
    • clearAnalysisLaunchers

      public void clearAnalysisLaunchers()
      Clears all analysis launchers and trims the internal list to size.
      Specified by:
      clearAnalysisLaunchers in interface IDatabase
    • 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)
    • 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