Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support MaxDB for sequences #932

Merged
merged 5 commits into from Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -1544,6 +1544,11 @@ private String createSql(String catalogName, String schemaName, String tableName
if (tableName != null) {
sql += " and table_name='" + tableName + "'";
}
} else if (database.getClass().getName().contains("MaxDB")) { //have to check classname as this is currently an extension
sql = "select distinct tablename AS TABLE_NAME, constraintname AS CONSTRAINT_NAME from CONSTRAINTCOLUMNS WHERE CONSTRAINTTYPE = 'UNIQUE_CONST'";
if (tableName != null) {
sql += " and tablename='" + tableName + "'";
}
} else if (database instanceof MSSQLDatabase) {
sql =
"SELECT " +
Expand Down
Expand Up @@ -278,9 +278,11 @@ protected String getSelectSequenceSql(Schema schema, Database database) {
"FROM SYS.SYSSEQUENCE s " +
"JOIN SYS.SYSUSER u ON s.OWNER = u.USER_ID "+
"WHERE u.USER_NAME = '" + schema.getName() + "'";
} else {
} else if (database.getClass().getName().contains("MaxDB")) { //have to check classname as this is currently an extension
return "SELECT SEQUENCE_NAME, MIN_VALUE, MAX_VALUE, INCREMENT_BY, CYCLE_FLAG AS WILL_CYCLE " +
"FROM sequences WHERE SCHEMANAME = '" + schema.getName() + "'";
} else {
throw new UnexpectedLiquibaseException("Don't know how to query for sequences on " + database);
}

}
}
}
Expand Up @@ -183,7 +183,6 @@ protected List<CachedRow> listConstraints(Table table, DatabaseSnapshot snapshot
+ "and const.table_name=col.table_name "
+ "and const.constraint_name=col.constraint_name "
+ "where const.constraint_catalog='" + database.correctObjectName(schema.getCatalogName(), Catalog.class) + "' ";

if (database instanceof CockroachDatabase) {
sql += " and (select count(*) from (select indexdef from pg_indexes where schemaname='" + database.correctObjectName(schema.getSchema().getName(), Schema.class) + "' AND indexname='" + database.correctObjectName(name, UniqueConstraint.class) + "' AND (position('DESC,' in indexdef) > 0 OR position('DESC)' in indexdef) > 0))) = 0"
+ "and const.constraint_name != 'primary' ";
Expand All @@ -195,6 +194,10 @@ protected List<CachedRow> listConstraints(Table table, DatabaseSnapshot snapshot
}

sql += "order by ordinal_position";
} else if (database.getClass().getName().contains("MaxDB")) { //have to check classname as this is currently an extension
sql = "select CONSTRAINTNAME as constraint_name, COLUMNNAME as column_name from CONSTRAINTCOLUMNS WHERE CONSTRAINTTYPE = 'UNIQUE_CONST' AND tablename = '"
+ database.correctObjectName(example.getRelation().getName(), Table.class) + "' AND constraintname = '"
+ database.correctObjectName(name, UniqueConstraint.class) + "'";
} else if (database instanceof MSSQLDatabase) {
sql =
"SELECT " +
Expand Down