Skip to content

Commit f1765d6

Browse files
authored
For IBM Db2, change the data type for BLOB column to support storing up to 2GB (#3000)
1 parent 98ffa4d commit f1765d6

24 files changed

+533
-96
lines changed

core/src/integration-test/java/com/scalar/db/storage/jdbc/ConsensusCommitAdminIntegrationTestWithJdbcDatabase.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ protected AdminTestUtils getAdminTestUtils(String testName) {
3131
}
3232

3333
@Override
34-
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
35-
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
34+
protected boolean isCreateIndexOnTextColumnEnabled() {
35+
// "admin.createIndex()" for TEXT column fails (the "create index" query runs
3636
// indefinitely) on the Db2 community edition docker version which we use for the CI.
3737
// However, the index creation is successful on Db2 hosted on IBM Cloud.
3838
// So we disable these tests until the issue with the Db2 community edition is resolved.
@@ -89,4 +89,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
8989
admin.dropTable(namespace1, TABLE4, true);
9090
}
9191
}
92+
93+
@Override
94+
protected boolean isIndexOnBlobColumnSupported() {
95+
return !JdbcTestUtils.isDb2(rdbEngine);
96+
}
9297
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminCaseSensitivityIntegrationTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ protected AdminTestUtils getAdminTestUtils(String testName) {
3131
}
3232

3333
@Override
34-
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
35-
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
34+
protected boolean isCreateIndexOnTextColumnEnabled() {
35+
// "admin.createIndex()" for TEXT column fails (the "create index" query runs
3636
// indefinitely) on Db2 community edition version but works on Db2 hosted on IBM Cloud.
3737
// So we disable these tests until the issue is resolved.
3838
return !JdbcTestUtils.isDb2(rdbEngine);
@@ -97,4 +97,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
9797
admin.dropTable(getNamespace1(), getTable4(), true);
9898
}
9999
}
100+
101+
@Override
102+
protected boolean isIndexOnBlobColumnSupported() {
103+
return !JdbcTestUtils.isDb2(rdbEngine);
104+
}
100105
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcAdminIntegrationTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ protected AdminTestUtils getAdminTestUtils(String testName) {
3030
}
3131

3232
@Override
33-
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
34-
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
33+
protected boolean isCreateIndexOnTextColumnEnabled() {
34+
// "admin.createIndex()" for TEXT columns fails (the "create index" query runs
3535
// indefinitely) on Db2 community edition version but works on Db2 hosted on IBM Cloud.
3636
// So we disable these tests until the issue is resolved.
3737
return !JdbcTestUtils.isDb2(rdbEngine);
@@ -96,4 +96,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
9696
admin.dropTable(getNamespace1(), getTable4(), true);
9797
}
9898
}
99+
100+
@Override
101+
protected boolean isIndexOnBlobColumnSupported() {
102+
return !JdbcTestUtils.isDb2(rdbEngine);
103+
}
99104
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcDatabaseCrossPartitionScanIntegrationTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,9 @@ protected Stream<Arguments> provideColumnsForCNFConditionsTest() {
8080
}
8181
return Stream.of(Arguments.of(allColumnNames));
8282
}
83+
84+
@Override
85+
protected boolean isOrderingOnBlobColumnSupported() {
86+
return !JdbcTestUtils.isDb2(rdbEngine);
87+
}
8388
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcDatabaseMultipleClusteringKeyScanIntegrationTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,14 @@ protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType)
9494
@Override
9595
protected List<DataType> getDataTypes() {
9696
// TIMESTAMP WITH TIME ZONE type cannot be used as a primary key in Oracle
97+
// BLOB type cannot be used as a clustering key in Db2
9798
return JdbcTestUtils.filterDataTypes(
9899
super.getDataTypes(),
99100
rdbEngine,
100-
ImmutableMap.of(RdbEngineOracle.class, ImmutableList.of(DataType.TIMESTAMPTZ)));
101+
ImmutableMap.of(
102+
RdbEngineOracle.class,
103+
ImmutableList.of(DataType.TIMESTAMPTZ),
104+
RdbEngineDb2.class,
105+
ImmutableList.of(DataType.BLOB)));
101106
}
102107
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcDatabaseMultiplePartitionKeyIntegrationTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,16 @@ protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType)
8888
protected List<DataType> getDataTypes() {
8989
// TIMESTAMP WITH TIME ZONE type cannot be used as a primary key in Oracle
9090
// FLOAT and DOUBLE types cannot be used as partition key in Yugabyte
91+
// BLOB type cannot be used as a partition key in Db2
9192
return JdbcTestUtils.filterDataTypes(
9293
super.getDataTypes(),
9394
rdbEngine,
9495
ImmutableMap.of(
9596
RdbEngineOracle.class,
9697
ImmutableList.of(DataType.TIMESTAMPTZ),
9798
RdbEngineYugabyte.class,
98-
ImmutableList.of(DataType.FLOAT, DataType.DOUBLE)));
99+
ImmutableList.of(DataType.FLOAT, DataType.DOUBLE),
100+
RdbEngineDb2.class,
101+
ImmutableList.of(DataType.BLOB)));
99102
}
100103
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcDatabaseSecondaryIndexIntegrationTest.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
11
package com.scalar.db.storage.jdbc;
22

3+
import com.google.common.collect.ImmutableList;
4+
import com.google.common.collect.ImmutableMap;
5+
import com.google.common.collect.Sets;
36
import com.scalar.db.api.DistributedStorageSecondaryIndexIntegrationTestBase;
47
import com.scalar.db.config.DatabaseConfig;
58
import com.scalar.db.io.Column;
69
import com.scalar.db.io.DataType;
710
import com.scalar.db.util.TestUtils;
11+
import java.util.Arrays;
812
import java.util.Properties;
913
import java.util.Random;
14+
import java.util.Set;
1015

1116
public class JdbcDatabaseSecondaryIndexIntegrationTest
1217
extends DistributedStorageSecondaryIndexIntegrationTestBase {
@@ -68,4 +73,14 @@ protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType)
6873
}
6974
return super.getColumnWithMaxValue(columnName, dataType);
7075
}
76+
77+
@Override
78+
protected Set<DataType> getSecondaryIndexTypes() {
79+
// BLOB type cannot be used as a secondary index in Db2
80+
return Sets.newHashSet(
81+
JdbcTestUtils.filterDataTypes(
82+
Arrays.asList(DataType.values()),
83+
rdbEngine,
84+
ImmutableMap.of(RdbEngineDb2.class, ImmutableList.of(DataType.BLOB))));
85+
}
7186
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcDatabaseSingleClusteringKeyScanIntegrationTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,14 @@ protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType)
7070
@Override
7171
protected List<DataType> getClusteringKeyTypes() {
7272
// TIMESTAMP WITH TIME ZONE type cannot be used as a primary key in Oracle
73+
// BLOB type cannot be used as a clustering key in Db2
7374
return JdbcTestUtils.filterDataTypes(
7475
super.getClusteringKeyTypes(),
7576
rdbEngine,
76-
ImmutableMap.of(RdbEngineOracle.class, ImmutableList.of(DataType.TIMESTAMPTZ)));
77+
ImmutableMap.of(
78+
RdbEngineOracle.class,
79+
ImmutableList.of(DataType.TIMESTAMPTZ),
80+
RdbEngineDb2.class,
81+
ImmutableList.of(DataType.BLOB)));
7782
}
7883
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/JdbcDatabaseSinglePartitionKeyIntegrationTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,13 +71,16 @@ protected Column<?> getColumnWithMaxValue(String columnName, DataType dataType)
7171
protected List<DataType> getPartitionKeyTypes() {
7272
// TIMESTAMP WITH TIME ZONE type cannot be used as a primary key in Oracle
7373
// FLOAT and DOUBLE types cannot be used as partition key in Yugabyte
74+
// BLOB type cannot be used as a partition key in Db2
7475
return JdbcTestUtils.filterDataTypes(
7576
super.getPartitionKeyTypes(),
7677
rdbEngine,
7778
ImmutableMap.of(
7879
RdbEngineOracle.class,
7980
ImmutableList.of(DataType.TIMESTAMPTZ),
8081
RdbEngineYugabyte.class,
81-
ImmutableList.of(DataType.FLOAT, DataType.DOUBLE)));
82+
ImmutableList.of(DataType.FLOAT, DataType.DOUBLE),
83+
RdbEngineDb2.class,
84+
ImmutableList.of(DataType.BLOB)));
8285
}
8386
}

core/src/integration-test/java/com/scalar/db/storage/jdbc/SingleCrudOperationTransactionAdminIntegrationTestWithJdbcDatabase.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ protected AdminTestUtils getAdminTestUtils(String testName) {
3131
}
3232

3333
@Override
34-
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
35-
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
34+
protected boolean isCreateIndexOnTextColumnEnabled() {
35+
// "admin.createIndex()" for TEXT column fails (the "create index" query runs
3636
// indefinitely) on the Db2 community edition docker version which we use for the CI.
3737
// However, the index creation is successful on Db2 hosted on IBM Cloud.
3838
// So we disable these tests until the issue with the Db2 community edition is resolved.
@@ -89,4 +89,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
8989
admin.dropTable(namespace1, TABLE4, true);
9090
}
9191
}
92+
93+
@Override
94+
protected boolean isIndexOnBlobColumnSupported() {
95+
return !JdbcTestUtils.isDb2(rdbEngine);
96+
}
9297
}

0 commit comments

Comments
 (0)