All Implemented Interfaces:
IIndex, IOptionContainer, ISearchPath, ISimpleColumnContainer, ISimpleOptionContainer, IStatement, ISubElement, IHashable

public class PgIndex extends PgAbstractStatement implements IIndex
PostgreSQL index implementation. Supports all PostgreSQL index features including unique constraints, partial indexes, expression indexes, and index inheritance for partitioned tables.
  • Constructor Details

    • PgIndex

      public PgIndex(String name)
      Creates a new PostgreSQL index.
      Parameters:
      name - index 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
    • getQualifiedName

      public String getQualifiedName()
      Description copied from interface: IStatement
      Gets the fully qualified name of this statement.
      Specified by:
      getQualifiedName in interface IStatement
      Overrides:
      getQualifiedName in class AbstractStatement
      Returns:
      fully qualified (up to schema) dot-delimited object name. Identifiers are quoted.
    • canDrop

      public boolean canDrop()
      Specified by:
      canDrop in interface IStatement
      Overrides:
      canDrop in class AbstractStatement
      Returns:
      true if the statement can be dropped
    • compareColumns

      public boolean compareColumns(Collection<String> refs)
      Description copied from interface: IIndex
      Compares the columns of this index with a collection of column references.
      Specified by:
      compareColumns in interface IIndex
      Parameters:
      refs - the collection of column references to compare against
      Returns:
      true if the columns match in order and count
    • getMethod

      public String getMethod()
      Gets the index access method (btree, hash, gin, gist, etc.).
      Returns:
      index method name
    • setMethod

      public void setMethod(String method)
    • addInherit

      public void addInherit(String schemaName, String indexName)
      Sets the parent index for this partitioned index.
      Parameters:
      schemaName - parent index schema name
      indexName - parent index name
    • setNullsDistinction

      public void setNullsDistinction(boolean nullsDistinction)
    • addOption

      public void addOption(String key, String value)
      Description copied from interface: IOptionContainer
      Adds an option to this container.
      Specified by:
      addOption in interface IOptionContainer
      Parameters:
      key - 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
    • addColumn

      public void addColumn(SimpleColumn column)
      Description copied from interface: ISimpleColumnContainer
      Adds a column reference to this container.
      Specified by:
      addColumn in interface ISimpleColumnContainer
      Parameters:
      column - the simple column to add
    • addInclude

      public void addInclude(String column)
      Description copied from interface: ISimpleColumnContainer
      Adds an included column to this container.
      Specified by:
      addInclude in interface ISimpleColumnContainer
      Parameters:
      column - the column name to include
    • isClustered

      public boolean isClustered()
    • setClustered

      public void setClustered(boolean isClustered)
    • setUnique

      public void setUnique(boolean isUnique)
    • setWhere

      public void setWhere(String where)
    • setTablespace

      public void setTablespace(String tablespace)
    • isUnique

      public boolean isUnique()
      Specified by:
      isUnique in interface IIndex
      Returns:
      true if unique index
    • 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