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:
Joe Shook 2022-05-18 07:02:11 -07:00 committed by GitHub
parent 3a286c306f
commit 4b638bbfee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 37 additions and 0 deletions

View File

@ -404,6 +404,7 @@
</dialects> </dialects>
<customDialects> <customDialects>
<customDialect>ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect</customDialect> <customDialect>ca.uhn.fhir.jpa.model.dialect.HapiFhirPostgres94Dialect</customDialect>
<customDialect>org.hibernate.dialect.CockroachDB201Dialect</customDialect>
</customDialects> </customDialects>
<outputDirectory>${project.build.directory}/classes/ca/uhn/hapi/fhir/jpa/docs/database</outputDirectory> <outputDirectory>${project.build.directory}/classes/ca/uhn/hapi/fhir/jpa/docs/database</outputDirectory>
<packages> <packages>

View File

@ -54,6 +54,8 @@ public enum DriverTypeEnum {
MSSQL_2012("com.microsoft.sqlserver.jdbc.SQLServerDriver", false), MSSQL_2012("com.microsoft.sqlserver.jdbc.SQLServerDriver", false),
COCKROACHDB_21_1("org.postgresql.Driver", false),
; ;
private static final Logger ourLog = LoggerFactory.getLogger(DriverTypeEnum.class); private static final Logger ourLog = LoggerFactory.getLogger(DriverTypeEnum.class);
@ -103,6 +105,9 @@ public enum DriverTypeEnum {
case MSSQL_2012: case MSSQL_2012:
retval = "sqlserver2012.sql"; retval = "sqlserver2012.sql";
break; break;
case COCKROACHDB_21_1:
retval = "cockroachdb201.sql";
break;
default: default:
throw new ConfigurationException(Msg.code(45) + "No schema initialization script available for driver " + this); throw new ConfigurationException(Msg.code(45) + "No schema initialization script available for driver " + this);
} }

View File

@ -82,6 +82,7 @@ public class AddForeignKeyTask extends BaseTableColumnTask {
// Quote the column names as "SYSTEM" is a reserved word in MySQL // 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 + "`)"; sql = "alter table " + getTableName() + " add constraint " + myConstraintName + " foreign key (`" + getColumnName() + "`) references " + myForeignTableName + " (`" + myForeignColumnName + "`)";
break; break;
case COCKROACHDB_21_1:
case POSTGRES_9_4: case POSTGRES_9_4:
case DERBY_EMBEDDED: case DERBY_EMBEDDED:
case H2_EMBEDDED: case H2_EMBEDDED:

View File

@ -73,6 +73,7 @@ public class AddIdGeneratorTask extends BaseTask {
case H2_EMBEDDED: case H2_EMBEDDED:
sql = "create sequence " + myGeneratorName + " start with 1 increment by 50"; sql = "create sequence " + myGeneratorName + " start with 1 increment by 50";
break; break;
case COCKROACHDB_21_1:
case POSTGRES_9_4: case POSTGRES_9_4:
sql = "create sequence " + myGeneratorName + " start 1 increment 50"; sql = "create sequence " + myGeneratorName + " start 1 increment 50";
break; break;

View File

@ -105,6 +105,7 @@ public class AddIndexTask extends BaseTableTask {
switch (getDriverType()) { switch (getDriverType()) {
case POSTGRES_9_4: case POSTGRES_9_4:
case MSSQL_2012: case MSSQL_2012:
case COCKROACHDB_21_1:
includeClause = " INCLUDE (" + String.join(", ", myIncludeColumns) + ")"; includeClause = " INCLUDE (" + String.join(", ", myIncludeColumns) + ")";
break; break;
case H2_EMBEDDED: case H2_EMBEDDED:
@ -133,6 +134,7 @@ public class AddIndexTask extends BaseTableTask {
if (myOnline) { if (myOnline) {
switch (getDriverType()) { switch (getDriverType()) {
case POSTGRES_9_4: case POSTGRES_9_4:
case COCKROACHDB_21_1:
postgresOnline = "CONCURRENTLY "; postgresOnline = "CONCURRENTLY ";
// This runs without a lock, and can't be done transactionally. // This runs without a lock, and can't be done transactionally.
setTransactional(false); setTransactional(false);

View File

@ -102,6 +102,7 @@ public class AddTableByColumnTask extends BaseTableTask {
case ORACLE_12C: case ORACLE_12C:
case MSSQL_2012: case MSSQL_2012:
case H2_EMBEDDED: case H2_EMBEDDED:
case COCKROACHDB_21_1:
break; break;
} }

View File

@ -63,6 +63,9 @@ public class DropForeignKeyTask extends BaseTableTask {
case MSSQL_2012: case MSSQL_2012:
sqls.add("alter table " + theTableName + " drop constraint " + theConstraintName); sqls.add("alter table " + theTableName + " drop constraint " + theConstraintName);
break; break;
case COCKROACHDB_21_1:
sqls.add("drop index if exists " + theTableName + "@" + theConstraintName + " cascade");
break;
default: default:
throw new IllegalStateException(Msg.code(59)); throw new IllegalStateException(Msg.code(59));
} }

View File

@ -76,6 +76,7 @@ public class DropIdGeneratorTask extends BaseTask {
sql = "drop sequence " + myGeneratorName; sql = "drop sequence " + myGeneratorName;
break; break;
case POSTGRES_9_4: case POSTGRES_9_4:
case COCKROACHDB_21_1:
sql = "drop sequence " + myGeneratorName; sql = "drop sequence " + myGeneratorName;
break; break;
case ORACLE_12C: case ORACLE_12C:

View File

@ -94,6 +94,9 @@ public class DropIndexTask extends BaseTableTask {
sql.add("drop index " + (myOnline?"CONCURRENTLY ":"") + "if exists " + myIndexName + " cascade"); sql.add("drop index " + (myOnline?"CONCURRENTLY ":"") + "if exists " + myIndexName + " cascade");
setTransactional(!myOnline); setTransactional(!myOnline);
break; break;
case COCKROACHDB_21_1:
sql.add("drop index if exists " + getTableName() + "@" + myIndexName + " cascade");
break;
} }
} else { } else {
// Drop index // Drop index
@ -116,6 +119,9 @@ public class DropIndexTask extends BaseTableTask {
case MSSQL_2012: case MSSQL_2012:
sql.add("drop index " + getTableName() + "." + myIndexName ); sql.add("drop index " + getTableName() + "." + myIndexName );
break; break;
case COCKROACHDB_21_1:
sql.add("drop index " + getTableName() + "@" + myIndexName);
break;
} }
} }
return sql; return sql;

View File

@ -108,6 +108,7 @@ public class ModifyColumnTask extends BaseTableColumnTypeTask {
sql = "alter table " + getTableName() + " modify column `" + getColumnName() + "` " + type + notNull; sql = "alter table " + getTableName() + " modify column `" + getColumnName() + "` " + type + notNull;
break; break;
case POSTGRES_9_4: case POSTGRES_9_4:
case COCKROACHDB_21_1:
if (!alreadyOfCorrectType) { if (!alreadyOfCorrectType) {
sql = "alter table " + getTableName() + " alter column " + getColumnName() + " type " + type; sql = "alter table " + getTableName() + " alter column " + getColumnName() + " type " + type;
} }

View File

@ -147,6 +147,7 @@ public class RenameColumnTask extends BaseTableTask {
break; break;
case POSTGRES_9_4: case POSTGRES_9_4:
case ORACLE_12C: case ORACLE_12C:
case COCKROACHDB_21_1:
sql = "ALTER TABLE " + getTableName() + " RENAME COLUMN " + myOldName + " TO " + myNewName; sql = "ALTER TABLE " + getTableName() + " RENAME COLUMN " + myOldName + " TO " + myNewName;
break; break;
case MSSQL_2012: case MSSQL_2012:

View File

@ -68,6 +68,7 @@ public class RenameIndexTask extends BaseTableTask {
case H2_EMBEDDED: case H2_EMBEDDED:
case POSTGRES_9_4: case POSTGRES_9_4:
case ORACLE_12C: case ORACLE_12C:
case COCKROACHDB_21_1:
sql.add("alter index " + theOldIndexName + " rename to " + theNewIndexName); sql.add("alter index " + theOldIndexName + " rename to " + theNewIndexName);
break; break;
case MSSQL_2012: case MSSQL_2012:

View File

@ -174,6 +174,7 @@ public class AddIndexTest extends BaseTest {
mySql = myTask.generateSql(); mySql = myTask.generateSql();
switch (theDriver) { switch (theDriver) {
case POSTGRES_9_4: case POSTGRES_9_4:
case COCKROACHDB_21_1:
assertEquals("create index CONCURRENTLY IDX_ANINDEX on SOMETABLE(PID, TEXTCOL)", mySql); assertEquals("create index CONCURRENTLY IDX_ANINDEX on SOMETABLE(PID, TEXTCOL)", mySql);
break; break;
case ORACLE_12C: case ORACLE_12C:

View File

@ -159,6 +159,9 @@ public class DropIndexTest extends BaseTest {
"alter table SOMETABLE drop constraint if exists IDX_ANINDEX cascade", "alter table SOMETABLE drop constraint if exists IDX_ANINDEX cascade",
"drop index if exists IDX_ANINDEX cascade"))); "drop index if exists IDX_ANINDEX cascade")));
break; 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: case POSTGRES_9_4:
assertThat(mySql, equalTo(asList("drop index IDX_ANINDEX"))); assertThat(mySql, equalTo(asList("drop index IDX_ANINDEX")));
break; 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", "alter table SOMETABLE drop constraint if exists IDX_ANINDEX cascade",
"drop index CONCURRENTLY if exists IDX_ANINDEX cascade"))); "drop index CONCURRENTLY if exists IDX_ANINDEX cascade")));
break; 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: case POSTGRES_9_4:
assertThat(mySql, equalTo(asList("drop index CONCURRENTLY IDX_ANINDEX"))); assertThat(mySql, equalTo(asList("drop index CONCURRENTLY IDX_ANINDEX")));
break; break;
case COCKROACHDB_21_1:
assertThat(mySql, equalTo(asList("drop index SOMETABLE@IDX_ANINDEX")));
break;
} }
} }
} }