Interface IDatabaseAdapter
- 
- All Known Implementing Classes:
- CitusAdapter,- CommonDatabaseAdapter,- DerbyAdapter,- PostgresAdapter
 
 public interface IDatabaseAdapterAbstraction of the SQL to use for a given database. This allows us to hide as much as possible the differences in syntax and support between databases.
- 
- 
Method SummaryAll Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description voidalterSequenceRestartWith(java.lang.String schemaName, java.lang.String sequenceName, long restartWith, int cache, int incrementBy)Sets/resets the sequence to start with the given value.voidalterTableAddColumn(java.lang.String schemaName, java.lang.String tableName, ColumnBase column)Add a new column to an existing tablevoidalterTableColumnIdentityCache(java.lang.String schemaName, java.lang.String objectName, java.lang.String columnName, int cache)Change the CACHE value of the named identity generated always columnvoidapplyDistributionRules(java.lang.String schemaName, java.lang.String tableName, DistributionContext distributionContext)Apply any distribution rules configured for the named tablebooleancheckCompatibility(java.lang.String adminSchema)checks connectivity to the database and that it is compatiblevoidcreateArrType(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] voidcreateForeignKeyConstraint(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)voidcreateIndex(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns)voidcreateOrReplaceFunction(java.lang.String schemaName, java.lang.String objectName, java.util.function.Supplier<java.lang.String> supplier)creates or replaces the SQL functionvoidcreateOrReplaceProcedure(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 suppliervoidcreateOrReplaceView(java.lang.String schemaName, java.lang.String objectName, java.lang.String selectClause)Create or replace the viewvoidcreateRowType(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.:voidcreateSchema(java.lang.String schemaName)Create a database schemavoidcreateSequence(java.lang.String schemaName, java.lang.String sequenceName, long startWith, int cache, int incrementBy)voidcreateTable(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 DDLvoidcreateTablespace(java.lang.String tablespaceName)Create a new tablespace with the given namevoidcreateTablespace(java.lang.String tablespaceName, int extentSizeKB)Create a new tablespace using the given extent sizevoidcreateUniqueConstraint(java.lang.String constraintName, java.util.List<java.lang.String> columns, java.lang.String schemaName, java.lang.String name)create a unique constraint on a table.voidcreateUniqueIndex(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 indexvoidcreateUniqueIndex(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns, DistributionContext distributionContext)Create a unique indexvoidcreateView(java.lang.String schemaName, java.lang.String objectName, java.lang.String selectClause)Create the view as defined by the selectClausevoiddisableForeignKey(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)Disable the FK with the given constraint namevoiddistributeFunction(java.lang.String schemaName, java.lang.String functionName, int distributeByParamNumber)For Citus, functions can be distributed by one of their parameters (typically the first)booleandoesForeignKeyConstraintExist(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)Does the named foreign key constraint existbooleandoesTableExist(java.lang.String schemaName, java.lang.String objectName)Check if the table currently existsvoiddropForeignKey(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)Drop the FK on the table with the given constraint namevoiddropFunction(java.lang.String schemaName, java.lang.String functionName)drops a given functionvoiddropIndex(java.lang.String schemaName, java.lang.String indexName)Drop the named indexvoiddropPermission(java.lang.String schemaName, java.lang.String permissionName)Drop permission object from the schemavoiddropProcedure(java.lang.String schemaName, java.lang.String procedureName)Drop the given procedurevoiddropSequence(java.lang.String schemaName, java.lang.String sequenceName)voiddropTable(java.lang.String schemaName, java.lang.String name)Drop table from the schemavoiddropTablespace(java.lang.String tablespaceName)Drop an existing tablespace, including all of its contentsvoiddropType(java.lang.String schemaName, java.lang.String typeName)Drop the type object from the schemavoiddropVariable(java.lang.String schemaName, java.lang.String variableName)voiddropView(java.lang.String schemaName, java.lang.String objectName)Drop the view from the databasevoidenableForeignKey(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)Enable the FK with the given constraint nameIDatabaseTranslatorgetTranslator()Get theIDatabaseTranslatorassociated with this adaptervoidgrantAllSequenceUsage(java.lang.String schemaName, java.lang.String grantToUser)Grant access to all sequences in the named schemavoidgrantFunctionPrivileges(java.lang.String schemaName, java.lang.String functionName, java.util.Collection<Privilege> privileges, java.lang.String toUser)grants permissions on a given functionvoidgrantObjectPrivileges(java.lang.String schemaName, java.lang.String tableName, java.util.Collection<Privilege> privileges, java.lang.String toUser)Grant the list of privileges on the named object to the user.voidgrantProcedurePrivileges(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 uservoidgrantSchemaUsage(java.lang.String schemaName, java.lang.String grantToUser)Grants USAGE on the given schemaName to the given uservoidgrantSequencePrivileges(java.lang.String schemaName, java.lang.String objectName, java.util.Collection<Privilege> group, java.lang.String toUser)Grant the collection of privileges on the named variable to the uservoidgrantVariablePrivileges(java.lang.String schemaName, java.lang.String variableName, java.util.Collection<Privilege> privileges, java.lang.String toUser)Grant the collection of privileges on the named variable to the userjava.util.List<SchemaInfoObject>listSchemaObjects(java.lang.String schemaName)List the objects present in the given schemavoidrunStatement(IDatabaseStatement statement)Run the given statement against the database represented by this adapter<T> TrunStatement(IDatabaseSupplier<T> supplier)Run the given supplier statement against the database represented by this adaptervoidsetIntegrityOff(java.lang.String schemaName, java.lang.String tableName)voidsetIntegrityUnchecked(java.lang.String schemaName, java.lang.String tableName)default booleanuseSessionVariable()
 
- 
- 
- 
Method Detail- 
getTranslatorIDatabaseTranslator getTranslator() Get theIDatabaseTranslatorassociated with this adapter- Returns:
 
 - 
createTablespacevoid createTablespace(java.lang.String tablespaceName) Create a new tablespace with the given name- Parameters:
- tablespaceName-
 
 - 
createTablespacevoid createTablespace(java.lang.String tablespaceName, int extentSizeKB)Create a new tablespace using the given extent size- Parameters:
- tablespaceName-
- extentSizeKB-
 
 - 
dropTablespacevoid dropTablespace(java.lang.String tablespaceName) Drop an existing tablespace, including all of its contents- Parameters:
- tablespaceName-
 
 - 
createTablevoid 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- Parameters:
- schemaName-
- name-
- columns-
- primaryKey-
- identity-
- tablespaceName-
- withs-
- checkConstraints-
- distributionContext-
 
 - 
applyDistributionRulesvoid applyDistributionRules(java.lang.String schemaName, java.lang.String tableName, DistributionContext distributionContext)Apply any distribution rules configured for the named table- Parameters:
- schemaName-
- tableName-
- distributionContext-
 
 - 
alterTableAddColumnvoid alterTableAddColumn(java.lang.String schemaName, java.lang.String tableName, ColumnBase column)Add a new column to an existing table- Parameters:
- schemaName-
- tableName-
- column-
 
 - 
createRowTypevoid 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.:CREATE OR REPLACE TYPE .t_str_values AS ROW (parameter_name_id INTEGER, str_value VARCHAR(511 OCTETS), str_value_lcase VARCHAR(511 OCTETS)) - Parameters:
- schemaName-
- typeName-
- columns-
 
 - 
createArrTypevoid 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] - Parameters:
- schemaName-
- typeName-
- valueType-
- arraySize-
 
 - 
dropTypevoid dropType(java.lang.String schemaName, java.lang.String typeName)Drop the type object from the schema- Parameters:
- schemaName-
- typeName-
 
 - 
createOrReplaceProcedurevoid 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- Parameters:
- schemaName-
- procedureName-
- supplier-
 
 - 
dropProcedurevoid dropProcedure(java.lang.String schemaName, java.lang.String procedureName)Drop the given procedure- Parameters:
- schemaName-
- procedureName-
 
 - 
createUniqueIndexvoid 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- Parameters:
- schemaName-
- tableName-
- indexName-
- indexColumns-
- includeColumns-
- distributionContext-
 
 - 
createUniqueIndexvoid createUniqueIndex(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns, DistributionContext distributionContext)Create a unique index- Parameters:
- schemaName-
- tableName-
- indexName-
- indexColumns-
- distributionContext-
 
 - 
createIndexvoid createIndex(java.lang.String schemaName, java.lang.String tableName, java.lang.String indexName, java.util.List<OrderedColumnDef> indexColumns)- Parameters:
- schemaName-
- tableName-
- indexName-
- indexColumns-
 
 - 
dropTablevoid dropTable(java.lang.String schemaName, java.lang.String name)Drop table from the schema- Parameters:
- schemaName-
- name-
 
 - 
dropPermissionvoid dropPermission(java.lang.String schemaName, java.lang.String permissionName)Drop permission object from the schema- Parameters:
- schemaName-
- permissionName-
 
 - 
dropVariablevoid dropVariable(java.lang.String schemaName, java.lang.String variableName)- Parameters:
- schemaName-
- variableName-
 
 - 
createForeignKeyConstraintvoid 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)- Parameters:
- constraintName-
- schemaName-
- name-
- targetSchema-
- targetTable-
- targetColumnName-
- columns-
- enforced-
 
 - 
createSequencevoid createSequence(java.lang.String schemaName, java.lang.String sequenceName, long startWith, int cache, int incrementBy)- Parameters:
- schemaName-
- sequenceName-
- startWith- the START WITH value for the sequence
- cache- the sequence CACHE value
 
 - 
dropSequencevoid dropSequence(java.lang.String schemaName, java.lang.String sequenceName)- Parameters:
- schemaName-
- sequenceName-
 
 - 
alterSequenceRestartWithvoid alterSequenceRestartWith(java.lang.String schemaName, java.lang.String sequenceName, long restartWith, int cache, int incrementBy)Sets/resets the sequence to start with the given value.- Parameters:
- schemaName-
- sequenceName-
- restartWith-
- cache-
 
 - 
grantObjectPrivilegesvoid grantObjectPrivileges(java.lang.String schemaName, java.lang.String tableName, java.util.Collection<Privilege> privileges, java.lang.String toUser)Grant the list of privileges on the named object to the user. This is a general purpose method which can be used to specify privileges for any object type which doesn't need the object type to be specified in the grant DDL.- Parameters:
- schemaName-
- tableName-
- privileges-
- toUser-
 
 - 
grantProcedurePrivilegesvoid 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- Parameters:
- schemaName-
- procedureName-
- privileges-
- toUser-
 
 - 
grantVariablePrivilegesvoid grantVariablePrivileges(java.lang.String schemaName, java.lang.String variableName, java.util.Collection<Privilege> privileges, java.lang.String toUser)Grant the collection of privileges on the named variable to the user- Parameters:
- schemaName-
- variableName-
- privileges-
- toUser-
 
 - 
grantSequencePrivilegesvoid grantSequencePrivileges(java.lang.String schemaName, java.lang.String objectName, java.util.Collection<Privilege> group, java.lang.String toUser)Grant the collection of privileges on the named variable to the user- Parameters:
- schemaName-
- objectName-
- group-
- toUser-
 
 - 
grantSchemaUsagevoid grantSchemaUsage(java.lang.String schemaName, java.lang.String grantToUser)Grants USAGE on the given schemaName to the given user- Parameters:
- schemaName-
 
 - 
grantAllSequenceUsagevoid grantAllSequenceUsage(java.lang.String schemaName, java.lang.String grantToUser)Grant access to all sequences in the named schema- Parameters:
- schemaName-
- grantToUser-
 
 - 
runStatement<T> T runStatement(IDatabaseSupplier<T> supplier) Run the given supplier statement against the database represented by this adapter- Type Parameters:
- T-
- Parameters:
- supplier-
- Returns:
 
 - 
runStatementvoid runStatement(IDatabaseStatement statement) Run the given statement against the database represented by this adapter- Parameters:
- statement-
 
 - 
doesTableExistboolean doesTableExist(java.lang.String schemaName, java.lang.String objectName)Check if the table currently exists- Parameters:
- schemaName-
- objectName-
- Returns:
 
 - 
createSchemavoid createSchema(java.lang.String schemaName) Create a database schema- Parameters:
- schemaName-
 
 - 
createUniqueConstraintvoid createUniqueConstraint(java.lang.String constraintName, java.util.List<java.lang.String> columns, java.lang.String schemaName, java.lang.String name)create a unique constraint on a table.- Parameters:
- constraintName-
- columns-
- schemaName-
- name-
 
 - 
checkCompatibilityboolean checkCompatibility(java.lang.String adminSchema) checks connectivity to the database and that it is compatible- Parameters:
- adminSchema-
- Returns:
 
 - 
useSessionVariabledefault boolean useSessionVariable() - Returns:
- a false, if not used, or true if used with the persistence layer.
 
 - 
createOrReplaceFunctionvoid createOrReplaceFunction(java.lang.String schemaName, java.lang.String objectName, java.util.function.Supplier<java.lang.String> supplier)creates or replaces the SQL function- Parameters:
- schemaName-
- objectName-
- supplier-
 
 - 
distributeFunctionvoid distributeFunction(java.lang.String schemaName, java.lang.String functionName, int distributeByParamNumber)For Citus, functions can be distributed by one of their parameters (typically the first)- Parameters:
- schemaName-
- functionName-
- distributeByParamNumber-
 
 - 
dropFunctionvoid dropFunction(java.lang.String schemaName, java.lang.String functionName)drops a given function- Parameters:
- schemaName-
- functionName-
 
 - 
grantFunctionPrivilegesvoid grantFunctionPrivileges(java.lang.String schemaName, java.lang.String functionName, java.util.Collection<Privilege> privileges, java.lang.String toUser)grants permissions on a given function- Parameters:
- schemaName-
- functionName-
- privileges-
- toUser-
 
 - 
disableForeignKeyvoid disableForeignKey(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)Disable the FK with the given constraint name- Parameters:
- tableName-
- constraintName-
 
 - 
dropForeignKeyvoid dropForeignKey(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)Drop the FK on the table with the given constraint name- Parameters:
- schemaName-
- tableName-
- constraintName-
 
 - 
enableForeignKeyvoid enableForeignKey(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)Enable the FK with the given constraint name- Parameters:
- schemaName-
- tableName-
- constraintName-
 
 - 
doesForeignKeyConstraintExistboolean doesForeignKeyConstraintExist(java.lang.String schemaName, java.lang.String tableName, java.lang.String constraintName)Does the named foreign key constraint exist- Parameters:
- schemaName-
- tableName-
- constraintName-
- Returns:
 
 - 
setIntegrityOffvoid setIntegrityOff(java.lang.String schemaName, java.lang.String tableName)- Parameters:
- schemaName-
- tableName-
 
 - 
setIntegrityUncheckedvoid setIntegrityUnchecked(java.lang.String schemaName, java.lang.String tableName)- Parameters:
- schemaName-
- tableName-
 
 - 
alterTableColumnIdentityCachevoid alterTableColumnIdentityCache(java.lang.String schemaName, java.lang.String objectName, java.lang.String columnName, int cache)Change the CACHE value of the named identity generated always column- Parameters:
- schemaName-
- objectName-
- columnName-
- cache-
 
 - 
dropIndexvoid dropIndex(java.lang.String schemaName, java.lang.String indexName)Drop the named index- Parameters:
- schemaName-
- indexName-
 
 - 
createViewvoid createView(java.lang.String schemaName, java.lang.String objectName, java.lang.String selectClause)Create the view as defined by the selectClause- Parameters:
- schemaName-
- objectName-
- selectClause-
 
 - 
dropViewvoid dropView(java.lang.String schemaName, java.lang.String objectName)Drop the view from the database- Parameters:
- schemaName-
- objectName-
 
 - 
createOrReplaceViewvoid createOrReplaceView(java.lang.String schemaName, java.lang.String objectName, java.lang.String selectClause)Create or replace the view- Parameters:
- schemaName-
- objectName-
- selectClause-
 
 - 
listSchemaObjectsjava.util.List<SchemaInfoObject> listSchemaObjects(java.lang.String schemaName) List the objects present in the given schema- Parameters:
- schemaName-
- Returns:
 
 
- 
 
-