Interface IStatement

All Known Subinterfaces:
ICast, IColumn, ICompositeType, IConstraint, IConstraintFk, IConstraintPk, IDatabase, IForeignTable, IFunction, IIndex, IOperator, IOptionContainer, IPartitionTable, IPolicy, IRelation, IRule, ISchema, ISearchPath, ISequence, ISimpleColumnContainer, ISimpleOptionContainer, IStatementContainer, IStatistics, ISubElement, ITable, ITrigger, IType, IView, MsSourceStatement, PgForeignOptionContainer
All Known Implementing Classes:
AbstractStatement, ChAbstractStatement, ChColumn, ChConstraint, ChDatabase, ChDictionary, ChFunction, ChIndex, ChPolicy, ChRole, ChSchema, ChTable, ChTableLog, ChUser, ChView, GpExternalTable, GpPartitionTable, MetaCast, MetaCompositeType, MetaConstraint, MetaFunction, MetaOperator, MetaRelation, MetaStatement, MsAbstractClrFunction, MsAbstractCommonFunction, MsAbstractFunction, MsAbstractStatement, MsAbstractStatementContainer, MsAssembly, MsClrFunction, MsClrProcedure, MsColumn, MsConstraint, MsConstraintCheck, MsConstraintFk, MsConstraintPk, MsDatabase, MsFunction, MsIndex, MsProcedure, MsRole, MsSchema, MsSequence, MsStatistics, MsTable, MsTrigger, MsType, MsUser, MsView, PgAbstractForeignTable, PgAbstractFunction, PgAbstractRegularTable, PgAbstractStatement, PgAbstractStatementContainer, PgAbstractTable, PgAbstractType, PgAbstractView, PgAggregate, PgBaseType, PgCast, PgCollation, PgColumn, PgCompositeType, PgConstraint, PgConstraintCheck, PgConstraintExclude, PgConstraintFk, PgConstraintNotNull, PgConstraintPk, PgDatabase, PgDomain, PgEnumType, PgEventTrigger, PgExtension, PgForeignDataWrapper, PgFtsConfiguration, PgFtsDictionary, PgFtsParser, PgFtsTemplate, PgFunction, PgIndex, PgMaterializedView, PgOperator, PgPartitionForeignTable, PgPartitionTable, PgPolicy, PgProcedure, PgRangeType, PgRule, PgSchema, PgSequence, PgServer, PgShellType, PgSimpleForeignTable, PgSimpleTable, PgStatistics, PgTrigger, PgTypedTable, PgUserMapping, PgView

public interface IStatement
Base interface for all database statements and objects. Provides common functionality for identifying and accessing database objects.
  • Method Details

    • getName

      String getName()
      Gets the name of this statement.
      Returns:
      the statement name
    • getStatementType

      DbObjType getStatementType()
      Gets the type of this database object.
      Returns:
      the database object type
    • getDatabase

      default IDatabase getDatabase()
      Gets the database that contains this statement.
      Returns:
      the containing database
    • getTypeName

      default String getTypeName()
      Gets the type name of this statement for SQL generation.
      Returns:
      the type name
    • isOwned

      default boolean isOwned()
      Checks if this statement type supports ownership.
      Returns:
      true if the statement can have an owner
    • getParent

      IStatement getParent()
      Gets the parent statement that contains this statement.
      Returns:
      the parent statement, or null if this is a top-level object
    • getQualifiedName

      String getQualifiedName()
      Gets the fully qualified name of this statement.
      Returns:
      the qualified name
    • getComment

      String getComment()
      Gets the comment associated with this statement.
      Returns:
      the comment, or null if no comment is set
    • getBareName

      String getBareName()
      Gets the bare name without qualifiers or arguments.
      Returns:
      the bare name
    • getTwin

      IStatement getTwin(IDatabase newDb)
      Returns:
      an element in another db sharing the same name and location
    • deepCopy

      IStatement deepCopy()
      Performs shallowCopy() on this object and all its children.
      Returns:
      a fully recursive copy of this statement.
    • shallowCopy

      IStatement shallowCopy()
      Copies all object properties into a new object and leaves all its children empty.
      Returns:
      shallow copy of a DB object.
    • compare

      boolean compare(IStatement statement)
    • addDependency

      void addDependency(ObjectReference dependency)
      Adds a dependency to this statement.
      Parameters:
      dependency - the dependency to add
    • getDependencies

      Set<ObjectReference> getDependencies()
      Returns:
      all object dependencies
    • getPrivileges

      Set<IPrivilege> getPrivileges()
      Gets an unmodifiable set of privileges for this statement.
      Returns:
      unmodifiable set of privileges
    • clearPrivileges

      void clearPrivileges()
      Removes all privileges from this statement.
    • getSQL

      String getSQL(boolean isFormatted, ISettings settings)
      Gets the SQL representation of this statement with optional formatting.
      Parameters:
      isFormatted - whether to apply formatting to the SQL
      settings - the settings to use for SQL generation and formatting
      Returns:
      the SQL string representation of this statement
    • getChildren

      Stream<? extends IStatement> getChildren()
      Returns all subelements of current element
    • getDescendants

      Stream<? extends IStatement> getDescendants()
      Returns all subtree elements
    • getOwner

      String getOwner()
      Returns owner of the object
    • setOwner

      void setOwner(String owner)
    • getLocation

      ObjectLocation getLocation()
      Gets the location information for this statement.
      Returns:
      the location where this statement is defined
    • isLib

      boolean isLib()
      Returns:
      true if this statement is from a library
    • getLibName

      String getLibName()
      Gets the name of the library this statement comes from.
      Returns:
      the library name, or null if not from a library
    • setLibName

      void setLibName(String libName)
    • appendAlterSQL

      ObjectState appendAlterSQL(IStatement newCondition, SQLScript script)
      Fill script with object changes and return change type
      Parameters:
      newCondition - new object state
      script - script to collect changes
      Returns:
      object change type
    • getCreationSQL

      void getCreationSQL(SQLScript script)
      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.
      Parameters:
      script - the SQL script to append creation statements to
    • appendOwnerSQL

      void appendOwnerSQL(SQLScript script)
      Appends ALTER OWNER SQL statement to the script for this database object.
      Parameters:
      script - the SQL script to append the owner statement to
      Throws:
      IllegalArgumentException - if database type is unsupported
    • getDropSQL

      void getDropSQL(SQLScript script, boolean generateExists)
      Generates DROP SQL for this statement.
      Parameters:
      script - the SQL script to append the DROP statement to
      generateExists - whether to include "IF EXISTS" in the DROP statement
    • canDrop

      boolean canDrop()
      Returns:
      true if the statement can be dropped
    • getSeparator

      String getSeparator()
    • canDropBeforeCreate

      boolean canDropBeforeCreate()
      Checks if this statement can be dropped before being recreated. Override in subclasses that support drop-before-create behavior.
      Returns:
      true if the statement can be dropped before recreation
    • toObjectReference

      default ObjectReference toObjectReference()
    • formatSql

      String formatSql(String sql, int offset, int length, IFormatConfiguration formatConfiguration)
      Formats string
      Parameters:
      sql - The source SQL text to format
      offset - Starting offset in the source text
      length - Length of text to format
      formatConfiguration - Formatting configuration options
      Returns:
      formatted string
    • getQuotedName

      default String getQuotedName()
      Returns:
      the quoted name
    • quote

      default String quote(String name)
      Parameters:
      name - string to quote
      Returns:
      the quoted string
    • getQuoter

      UnaryOperator<String> getQuoter()
      Returns:
      a function that quotes name
    • getRenameCommand

      String getRenameCommand(String newName)
      Returns sql command to rename the given object.
      Parameters:
      newName - the new name for given object
      Returns:
      sql command to rename the given object
    • setLocation

      void setLocation(ObjectLocation loc)
    • hasChildren

      boolean hasChildren()
    • setComment

      void setComment(String comment)
    • getAuthor

      String getAuthor()