CockroachDB (#3577)
* Update pom.xml * Data behavior overrides for CockroachDB * Unwind two unintended changes * Update Spring framework version This is n response to CVE-2022-22968 reported by WhiteSource Security Check ran by GitHub * Update elasticsearch-rest-high-level-client version This is n response to CVE-2021-22145 and CVE-2021-22134 reported by WhiteSource Security Check ran by GitHub Co-authored-by: Shook, Joseph <Joseph.Shook@surescripts.com>
This commit is contained in:
parent
3a286c306f
commit
4b638bbfee
|
@ -404,6 +404,7 @@
|
|||
</dialects>
|
||||
<customDialects>
|
||||
<customDialect>ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect</customDialect>
|
||||
<customDialect>org.hibernate.dialect.CockroachDB201Dialect</customDialect>
|
||||
</customDialects>
|
||||
<outputDirectory>${project.build.directory}/classes/ca/uhn/hapi/fhir/jpa/docs/database</outputDirectory>
|
||||
<packages>
|
||||
|
|
|
@ -54,6 +54,8 @@ public enum DriverTypeEnum {
|
|||
|
||||
MSSQL_2012("com.microsoft.sqlserver.jdbc.SQLServerDriver", false),
|
||||
|
||||
COCKROACHDB_21_1("org.postgresql.Driver", false),
|
||||
|
||||
;
|
||||
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(DriverTypeEnum.class);
|
||||
|
@ -103,6 +105,9 @@ public enum DriverTypeEnum {
|
|||
case MSSQL_2012:
|
||||
retval = "sqlserver2012.sql";
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
retval = "cockroachdb201.sql";
|
||||
break;
|
||||
default:
|
||||
throw new ConfigurationException(Msg.code(45) + "No schema initialization script available for driver " + this);
|
||||
}
|
||||
|
|
|
@ -82,6 +82,7 @@ public class AddForeignKeyTask extends BaseTableColumnTask {
|
|||
// Quote the column names as "SYSTEM" is a reserved word in MySQL
|
||||
sql = "alter table " + getTableName() + " add constraint " + myConstraintName + " foreign key (`" + getColumnName() + "`) references " + myForeignTableName + " (`" + myForeignColumnName + "`)";
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
case POSTGRES_9_4:
|
||||
case DERBY_EMBEDDED:
|
||||
case H2_EMBEDDED:
|
||||
|
|
|
@ -73,6 +73,7 @@ public class AddIdGeneratorTask extends BaseTask {
|
|||
case H2_EMBEDDED:
|
||||
sql = "create sequence " + myGeneratorName + " start with 1 increment by 50";
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
case POSTGRES_9_4:
|
||||
sql = "create sequence " + myGeneratorName + " start 1 increment 50";
|
||||
break;
|
||||
|
|
|
@ -105,6 +105,7 @@ public class AddIndexTask extends BaseTableTask {
|
|||
switch (getDriverType()) {
|
||||
case POSTGRES_9_4:
|
||||
case MSSQL_2012:
|
||||
case COCKROACHDB_21_1:
|
||||
includeClause = " INCLUDE (" + String.join(", ", myIncludeColumns) + ")";
|
||||
break;
|
||||
case H2_EMBEDDED:
|
||||
|
@ -133,6 +134,7 @@ public class AddIndexTask extends BaseTableTask {
|
|||
if (myOnline) {
|
||||
switch (getDriverType()) {
|
||||
case POSTGRES_9_4:
|
||||
case COCKROACHDB_21_1:
|
||||
postgresOnline = "CONCURRENTLY ";
|
||||
// This runs without a lock, and can't be done transactionally.
|
||||
setTransactional(false);
|
||||
|
|
|
@ -102,6 +102,7 @@ public class AddTableByColumnTask extends BaseTableTask {
|
|||
case ORACLE_12C:
|
||||
case MSSQL_2012:
|
||||
case H2_EMBEDDED:
|
||||
case COCKROACHDB_21_1:
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,9 @@ public class DropForeignKeyTask extends BaseTableTask {
|
|||
case MSSQL_2012:
|
||||
sqls.add("alter table " + theTableName + " drop constraint " + theConstraintName);
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
sqls.add("drop index if exists " + theTableName + "@" + theConstraintName + " cascade");
|
||||
break;
|
||||
default:
|
||||
throw new IllegalStateException(Msg.code(59));
|
||||
}
|
||||
|
|
|
@ -76,6 +76,7 @@ public class DropIdGeneratorTask extends BaseTask {
|
|||
sql = "drop sequence " + myGeneratorName;
|
||||
break;
|
||||
case POSTGRES_9_4:
|
||||
case COCKROACHDB_21_1:
|
||||
sql = "drop sequence " + myGeneratorName;
|
||||
break;
|
||||
case ORACLE_12C:
|
||||
|
|
|
@ -94,6 +94,9 @@ public class DropIndexTask extends BaseTableTask {
|
|||
sql.add("drop index " + (myOnline?"CONCURRENTLY ":"") + "if exists " + myIndexName + " cascade");
|
||||
setTransactional(!myOnline);
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
sql.add("drop index if exists " + getTableName() + "@" + myIndexName + " cascade");
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
// Drop index
|
||||
|
@ -116,6 +119,9 @@ public class DropIndexTask extends BaseTableTask {
|
|||
case MSSQL_2012:
|
||||
sql.add("drop index " + getTableName() + "." + myIndexName );
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
sql.add("drop index " + getTableName() + "@" + myIndexName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return sql;
|
||||
|
|
|
@ -108,6 +108,7 @@ public class ModifyColumnTask extends BaseTableColumnTypeTask {
|
|||
sql = "alter table " + getTableName() + " modify column `" + getColumnName() + "` " + type + notNull;
|
||||
break;
|
||||
case POSTGRES_9_4:
|
||||
case COCKROACHDB_21_1:
|
||||
if (!alreadyOfCorrectType) {
|
||||
sql = "alter table " + getTableName() + " alter column " + getColumnName() + " type " + type;
|
||||
}
|
||||
|
|
|
@ -147,6 +147,7 @@ public class RenameColumnTask extends BaseTableTask {
|
|||
break;
|
||||
case POSTGRES_9_4:
|
||||
case ORACLE_12C:
|
||||
case COCKROACHDB_21_1:
|
||||
sql = "ALTER TABLE " + getTableName() + " RENAME COLUMN " + myOldName + " TO " + myNewName;
|
||||
break;
|
||||
case MSSQL_2012:
|
||||
|
|
|
@ -68,6 +68,7 @@ public class RenameIndexTask extends BaseTableTask {
|
|||
case H2_EMBEDDED:
|
||||
case POSTGRES_9_4:
|
||||
case ORACLE_12C:
|
||||
case COCKROACHDB_21_1:
|
||||
sql.add("alter index " + theOldIndexName + " rename to " + theNewIndexName);
|
||||
break;
|
||||
case MSSQL_2012:
|
||||
|
|
|
@ -174,6 +174,7 @@ public class AddIndexTest extends BaseTest {
|
|||
mySql = myTask.generateSql();
|
||||
switch (theDriver) {
|
||||
case POSTGRES_9_4:
|
||||
case COCKROACHDB_21_1:
|
||||
assertEquals("create index CONCURRENTLY IDX_ANINDEX on SOMETABLE(PID, TEXTCOL)", mySql);
|
||||
break;
|
||||
case ORACLE_12C:
|
||||
|
|
|
@ -159,6 +159,9 @@ public class DropIndexTest extends BaseTest {
|
|||
"alter table SOMETABLE drop constraint if exists IDX_ANINDEX cascade",
|
||||
"drop index if exists IDX_ANINDEX cascade")));
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
assertThat(mySql, equalTo(asList("drop index if exists SOMETABLE@IDX_ANINDEX cascade")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,6 +190,9 @@ public class DropIndexTest extends BaseTest {
|
|||
case POSTGRES_9_4:
|
||||
assertThat(mySql, equalTo(asList("drop index IDX_ANINDEX")));
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
assertThat(mySql, equalTo(asList("drop index SOMETABLE@IDX_ANINDEX")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,6 +224,9 @@ public class DropIndexTest extends BaseTest {
|
|||
"alter table SOMETABLE drop constraint if exists IDX_ANINDEX cascade",
|
||||
"drop index CONCURRENTLY if exists IDX_ANINDEX cascade")));
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
assertThat(mySql, equalTo(asList("drop index if exists SOMETABLE@IDX_ANINDEX cascade")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,6 +256,9 @@ public class DropIndexTest extends BaseTest {
|
|||
case POSTGRES_9_4:
|
||||
assertThat(mySql, equalTo(asList("drop index CONCURRENTLY IDX_ANINDEX")));
|
||||
break;
|
||||
case COCKROACHDB_21_1:
|
||||
assertThat(mySql, equalTo(asList("drop index SOMETABLE@IDX_ANINDEX")));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue