Class PostgresAdapter

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void alterTableColumnIdentityCache​(java.lang.String schemaName, java.lang.String tableName, java.lang.String columnName, int cache)
      Change the CACHE value of the named identity generated always column
      java.lang.String blobClause​(long size, int inlineSize)
      Generate a clause for BLOB (with an inline size if supported)
      boolean checkCompatibility​(java.lang.String adminSchema)
      checks connectivity to the database and that it is compatible
      java.lang.String clobClause()  
      void createArrType​(java.lang.String schemaName, java.lang.String typeName, java.lang.String valueType, int arraySize)
      Create ARRAY type used for passing values to stored procedures e.g.: CREATE OR REPLACE TYPE .t_str_values_arr AS .t_str_values ARRAY[256]
      void createForeignKeyConstraint​(java.lang.String constraintName, java.lang.String schemaName, java.lang.String name, java.lang.String targetSchema, java.lang.String targetTable, java.lang.String targetColumnName, java.util.List<java.lang.String> columns, boolean enforced)  
      void createIndex​(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns)  
      void createOrReplaceFunction​(java.lang.String schemaName, java.lang.String functionName, java.util.function.Supplier<java.lang.String> supplier)
      creates or replaces the SQL function
      void createOrReplaceProcedure​(java.lang.String schemaName, java.lang.String procedureName, java.util.function.Supplier<java.lang.String> supplier)
      Create the stored procedure using the DDL text provided by the supplier
      void createRowType​(java.lang.String schemaName, java.lang.String typeName, java.util.List<ColumnBase> columns)
      Create ROW type used for passing values to stored procedures e.g.:
      void createSchema​(java.lang.String schemaName)
      Create a database schema
      void createSequence​(java.lang.String schemaName, java.lang.String sequenceName, long startWith, int cache, int incrementBy)  
      void createTable​(java.lang.String schemaName, java.lang.String name, java.util.List<ColumnBase> columns, PrimaryKeyDef primaryKey, IdentityDef identity, java.lang.String tablespaceName, java.util.List<With> withs, java.util.List<CheckConstraint> checkConstraints, DistributionContext distributionContext)
      Build the create table DDL
      void createTablespace​(java.lang.String tablespaceName)
      Create a new tablespace with the given name
      void createTablespace​(java.lang.String tablespaceName, int extentSizeKB)
      Create a new tablespace using the given extent size
      void createUniqueIndex​(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns, java.util.List<java.lang.String> includeColumns, DistributionContext distributionContext)
      Create a unique index
      void createUniqueIndex​(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns, DistributionContext distributionContext)
      Create a unique index
      void disableForeignKey​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Disable the FK with the given constraint name
      boolean doesForeignKeyConstraintExist​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Does the named foreign key constraint exist
      boolean doesTableExist​(java.lang.String schemaName, java.lang.String tableName)
      Check if the table currently exists
      java.lang.String doubleClause()
      Generate a clause for double data type
      void dropForeignKey​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Drop the FK on the table with the given constraint name
      void dropIndex​(java.lang.String schemaName, java.lang.String indexName)
      Drop the named index
      void dropPermission​(java.lang.String schemaName, java.lang.String permissionName)
      Drop permission object from the schema
      void dropProcedure​(java.lang.String schemaName, java.lang.String procedureName)
      Drop the given procedure
      void dropSequence​(java.lang.String schemaName, java.lang.String sequenceName)  
      void dropTable​(java.lang.String schemaName, java.lang.String tableName)
      Drop table from the schema
      void dropTablespace​(java.lang.String tablespaceName)
      Drop an existing tablespace, including all of its contents
      void dropType​(java.lang.String schemaName, java.lang.String typeName)
      Drop the type object from the schema
      void dropVariable​(java.lang.String schemaName, java.lang.String variableName)  
      void dropView​(java.lang.String schemaName, java.lang.String viewName)
      Drop the view from the database
      void enableForeignKey​(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)
      Enable the FK with the given constraint name
      void grantAllSequenceUsage​(java.lang.String schemaName, java.lang.String grantToUser)
      Grant access to all sequences in the named schema
      void grantProcedurePrivileges​(java.lang.String schemaName, java.lang.String procedureName, java.util.Collection<Privilege> privileges, java.lang.String toUser)
      Grant the collection of privileges on the named procedure to the user
      void grantSchemaUsage​(java.lang.String schemaName, java.lang.String grantToUser)
      Grants USAGE on the given schemaName to the given user
      java.util.List<SchemaInfoObject> listSchemaObjects​(java.lang.String schemaName)
      List the objects present in the given schema
      protected java.util.List<OrderedColumnDef> prefixTenantColumn​(java.lang.String tenantColumnName, java.util.List<OrderedColumnDef> columns)
      Prefix the tenantColumnName to the list of columns, or do nothing if tenantColumnName is null
      void runStatement​(IDatabaseStatement stmt)
      Run the statement using the connectionProvider to obtain a new connection.
      void setIntegrityOff​(java.lang.String schemaName, java.lang.String tableName)  
      void setIntegrityUnchecked​(java.lang.String schemaName, java.lang.String tableName)  
      java.lang.String timestampClause​(java.lang.Integer precision)
      Generate a clause for TIMESTAMP
      java.lang.String varbinaryClause​(int size)
      Generate a clause for binary data type
      java.lang.String varcharClause​(int size)
      Generate a clause for VARCHAR
      void warnOnce​(PostgresAdapter.MessageKey messageKey, java.lang.String msg)
      Once write each warning message once
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PostgresAdapter

        public PostgresAdapter​(IDatabaseTarget tgt)
        Public constructor
        Parameters:
        tgt - the target database we want to manage
      • PostgresAdapter

        public PostgresAdapter()
    • Method Detail

      • warnOnce

        public void warnOnce​(PostgresAdapter.MessageKey messageKey,
                             java.lang.String msg)
        Once write each warning message once
        Parameters:
        msg -
      • createRowType

        public void createRowType​(java.lang.String schemaName,
                                  java.lang.String typeName,
                                  java.util.List<ColumnBase> columns)
        Description copied from interface: IDatabaseAdapter
        Create ROW type used for passing values to stored procedures e.g.:
         CREATE OR REPLACE TYPE .t_str_values AS ROW (parameter_name_id INTEGER,
         str_value VARCHAR(511 OCTETS), str_value_lcase VARCHAR(511 OCTETS))
         
      • createArrType

        public void createArrType​(java.lang.String schemaName,
                                  java.lang.String typeName,
                                  java.lang.String valueType,
                                  int arraySize)
        Description copied from interface: IDatabaseAdapter
        Create ARRAY type used for passing values to stored procedures e.g.: CREATE OR REPLACE TYPE .t_str_values_arr AS .t_str_values ARRAY[256]
      • dropType

        public void dropType​(java.lang.String schemaName,
                             java.lang.String typeName)
        Description copied from interface: IDatabaseAdapter
        Drop the type object from the schema
      • createTablespace

        public void createTablespace​(java.lang.String tablespaceName)
        Description copied from interface: IDatabaseAdapter
        Create a new tablespace with the given name
      • dropTablespace

        public void dropTablespace​(java.lang.String tablespaceName)
        Description copied from interface: IDatabaseAdapter
        Drop an existing tablespace, including all of its contents
      • createTablespace

        public void createTablespace​(java.lang.String tablespaceName,
                                     int extentSizeKB)
        Description copied from interface: IDatabaseAdapter
        Create a new tablespace using the given extent size
      • doesTableExist

        public boolean doesTableExist​(java.lang.String schemaName,
                                      java.lang.String tableName)
        Description copied from interface: IDatabaseAdapter
        Check if the table currently exists
        Returns:
      • createSequence

        public void createSequence​(java.lang.String schemaName,
                                   java.lang.String sequenceName,
                                   long startWith,
                                   int cache,
                                   int incrementBy)
        Specified by:
        createSequence in interface IDatabaseAdapter
        Overrides:
        createSequence in class CommonDatabaseAdapter
        startWith - the START WITH value for the sequence
        cache - the sequence CACHE value
      • varbinaryClause

        public java.lang.String varbinaryClause​(int size)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for binary data type
        Returns:
      • blobClause

        public java.lang.String blobClause​(long size,
                                           int inlineSize)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for BLOB (with an inline size if supported)
        Returns:
      • varcharClause

        public java.lang.String varcharClause​(int size)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for VARCHAR
        Returns:
      • timestampClause

        public java.lang.String timestampClause​(java.lang.Integer precision)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for TIMESTAMP
        Returns:
      • doubleClause

        public java.lang.String doubleClause()
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for double data type
        Returns:
      • clobClause

        public java.lang.String clobClause()
      • createForeignKeyConstraint

        public void createForeignKeyConstraint​(java.lang.String constraintName,
                                               java.lang.String schemaName,
                                               java.lang.String name,
                                               java.lang.String targetSchema,
                                               java.lang.String targetTable,
                                               java.lang.String targetColumnName,
                                               java.util.List<java.lang.String> columns,
                                               boolean enforced)
        Specified by:
        createForeignKeyConstraint in interface IDatabaseAdapter
        Overrides:
        createForeignKeyConstraint in class CommonDatabaseAdapter
      • checkCompatibility

        public boolean checkCompatibility​(java.lang.String adminSchema)
        Description copied from interface: IDatabaseAdapter
        checks connectivity to the database and that it is compatible
        Returns:
      • createSchema

        public void createSchema​(java.lang.String schemaName)
        Description copied from interface: IDatabaseAdapter
        Create a database schema
      • disableForeignKey

        public void disableForeignKey​(java.lang.String schemaName,
                                      java.lang.String tableName,
                                      java.lang.String constraintName)
        Description copied from interface: IDatabaseAdapter
        Disable the FK with the given constraint name
      • enableForeignKey

        public void enableForeignKey​(java.lang.String schemaName,
                                     java.lang.String tableName,
                                     java.lang.String constraintName)
        Description copied from interface: IDatabaseAdapter
        Enable the FK with the given constraint name
      • doesForeignKeyConstraintExist

        public boolean doesForeignKeyConstraintExist​(java.lang.String schemaName,
                                                     java.lang.String tableName,
                                                     java.lang.String constraintName)
        Description copied from interface: IDatabaseAdapter
        Does the named foreign key constraint exist
        Returns:
      • setIntegrityOff

        public void setIntegrityOff​(java.lang.String schemaName,
                                    java.lang.String tableName)
      • setIntegrityUnchecked

        public void setIntegrityUnchecked​(java.lang.String schemaName,
                                          java.lang.String tableName)
      • listSchemaObjects

        public java.util.List<SchemaInfoObject> listSchemaObjects​(java.lang.String schemaName)
        Description copied from interface: IDatabaseAdapter
        List the objects present in the given schema
        Returns: