Class Db2Adapter

    • Constructor Detail

      • Db2Adapter

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

        public Db2Adapter()
    • Method Detail

      • createIntVariable

        public void createIntVariable​(String schemaName,
                                      String variableName)
        Description copied from interface: IDatabaseAdapter
         CREATE VARIABLE ptng.session_tenant INT DEFAULT NULL;
         
      • createOrReplacePermission

        public void createOrReplacePermission​(String schemaName,
                                              String permissionName,
                                              String tableName,
                                              String predicate)
        Description copied from interface: IDatabaseAdapter
         CREATE OR REPLACE PERMISSION ROW_ACCESS ON ptng.patients FOR ROWS WHERE patients.mt_id =
         ptng.session_tenant ENFORCED FOR ALL ACCESS ENABLE;
         
      • activateRowAccessControl

        public void activateRowAccessControl​(String schemaName,
                                             String tableName)
        Description copied from interface: IDatabaseAdapter
         ALTER TABLE  ACTIVATE ROW ACCESS CONTROL
         
      • setIntVariable

        public void setIntVariable​(String schemaName,
                                   String variableName,
                                   int value)
        Description copied from interface: IDatabaseAdapter
        Build the DML statement for setting a session variable
      • createTenantPartitions

        public void createTenantPartitions​(Collection<Table> tables,
                                           String schemaName,
                                           int newTenantId,
                                           int extentSizeKB)
        Description copied from interface: IDatabaseAdapter
        Create the partitions on each of these tables
      • addNewTenantPartitions

        public void addNewTenantPartitions​(Collection<Table> tables,
                                           Map<String,​PartitionInfo> partitionInfoMap,
                                           int newTenantId,
                                           String tablespaceName)
        Add a new tenant partition to each of the tables in the collection. Idempotent, so can be run to add partitions for existing tenants to new tables
        Parameters:
        tables -
        partitionInfoMap -
        newTenantId -
        tablespaceName -
      • createTenantPartitionsThr

        public void createTenantPartitionsThr​(Table t,
                                              PartitionInfo pi,
                                              int newTenantId,
                                              String tablespaceName)
        Ensure that the given table has all the partitions necessary up to and including the max tenant id
        Parameters:
        t -
        pi -
        newTenantId -
        tablespaceName -
      • loadPartitionInfoMap

        protected void loadPartitionInfoMap​(Map<String,​PartitionInfo> partitionInfoMap,
                                            String tableSchema)
        Read partition info from the database catalog.
        Parameters:
        partitionInfoMap -
        tableSchema -
      • deactivateRowAccessControl

        public void deactivateRowAccessControl​(String schemaName,
                                               String tableName)
        Description copied from interface: IDatabaseAdapter
        Deactivate row access control on a table ALTER TABLE DEACTIVATE ROW ACCESS CONTROL
      • createRowType

        public void createRowType​(String schemaName,
                                  String typeName,
                                  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​(String schemaName,
                                  String typeName,
                                  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​(String schemaName,
                             String typeName)
        Description copied from interface: IDatabaseAdapter
        Drop the type object from the schema
      • createTablespace

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

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

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

        public void detachPartition​(String schemaName,
                                    String tableName,
                                    String partitionName,
                                    String intoTableName)
        Description copied from interface: IDatabaseAdapter
        Detach the partition
      • removeTenantPartitions

        public void removeTenantPartitions​(Collection<Table> tables,
                                           String schemaName,
                                           int tenantId)
        Description copied from interface: IDatabaseAdapter
        Detach the partition associated with the tenantId from each of the given tables
      • dropDetachedPartitions

        public void dropDetachedPartitions​(Collection<Table> tables,
                                           String schemaName,
                                           int tenantId)
        Description copied from interface: IDatabaseAdapter
        Drop the tables which were created by the detach partition operation (as part of tenant deprovisioning).
      • doesTableExist

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

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

        public 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 String varcharClause​(int size)
        Description copied from interface: IDatabaseTypeAdapter
        Generate a clause for VARCHAR
        Returns:
      • checkCompatibility

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

        public void createSchema​(String schemaName)
        Description copied from interface: IDatabaseAdapter
        Create a database schema
      • useSessionVariable

        public boolean useSessionVariable()
        Returns:
        a false, if not used, or true if used with the persistence layer.
      • dropTenantTablespace

        public void dropTenantTablespace​(int tenantId)
        Description copied from interface: IDatabaseAdapter
        Drop the tablespace associated with the given tenantId
      • disableForeignKey

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

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

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

        public void setIntegrityUnchecked​(String schemaName,
                                          String tableName)