Skip to content

Commit 12ca026

Browse files
committed
For IBM Db2, change the data type for BLOB column to support storing up to 2GB (#3000)
# Conflicts: # core/src/test/java/com/scalar/db/storage/jdbc/JdbcAdminTestBase.java
1 parent f362b92 commit 12ca026

24 files changed

+558
-118
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
@@ -122,8 +122,8 @@ public void createTable_ForNonExistingNamespace_ShouldThrowIllegalArgumentExcept
122122
}
123123

124124
@Override
125-
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
126-
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
125+
protected boolean isCreateIndexOnTextColumnEnabled() {
126+
// "admin.createIndex()" for TEXT column fails (the "create index" query runs
127127
// indefinitely) on the Db2 community edition docker version which we use for the CI.
128128
// However, the index creation is successful on Db2 hosted on IBM Cloud.
129129
// So we disable these tests until the issue with the Db2 community edition is resolved.
@@ -180,4 +180,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
180180
admin.dropTable(namespace1, TABLE4, true);
181181
}
182182
}
183+
184+
@Override
185+
protected boolean isIndexOnBlobColumnSupported() {
186+
return !JdbcTestUtils.isDb2(rdbEngine);
187+
}
183188
}

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
@@ -106,8 +106,8 @@ public void createTable_ForNonExistingNamespace_ShouldThrowIllegalArgumentExcept
106106
}
107107

108108
@Override
109-
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
110-
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
109+
protected boolean isCreateIndexOnTextColumnEnabled() {
110+
// "admin.createIndex()" for TEXT column fails (the "create index" query runs
111111
// indefinitely) on Db2 community edition version but works on Db2 hosted on IBM Cloud.
112112
// So we disable these tests until the issue is resolved.
113113
return !JdbcTestUtils.isDb2(rdbEngine);
@@ -172,4 +172,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
172172
admin.dropTable(getNamespace1(), getTable4(), true);
173173
}
174174
}
175+
176+
@Override
177+
protected boolean isIndexOnBlobColumnSupported() {
178+
return !JdbcTestUtils.isDb2(rdbEngine);
179+
}
175180
}

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
@@ -105,8 +105,8 @@ public void createTable_ForNonExistingNamespace_ShouldThrowIllegalArgumentExcept
105105
}
106106

107107
@Override
108-
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
109-
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
108+
protected boolean isCreateIndexOnTextColumnEnabled() {
109+
// "admin.createIndex()" for TEXT columns fails (the "create index" query runs
110110
// indefinitely) on Db2 community edition version but works on Db2 hosted on IBM Cloud.
111111
// So we disable these tests until the issue is resolved.
112112
return !JdbcTestUtils.isDb2(rdbEngine);
@@ -171,4 +171,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
171171
admin.dropTable(getNamespace1(), getTable4(), true);
172172
}
173173
}
174+
175+
@Override
176+
protected boolean isIndexOnBlobColumnSupported() {
177+
return !JdbcTestUtils.isDb2(rdbEngine);
178+
}
174179
}

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
@@ -106,8 +106,8 @@ public void createTable_ForNonExistingNamespace_ShouldThrowIllegalArgumentExcept
106106
}
107107

108108
@Override
109-
protected boolean isCreateIndexOnTextAndBlobColumnsEnabled() {
110-
// "admin.createIndex()" for TEXT and BLOB columns fails (the "create index" query runs
109+
protected boolean isCreateIndexOnTextColumnEnabled() {
110+
// "admin.createIndex()" for TEXT column fails (the "create index" query runs
111111
// indefinitely) on the Db2 community edition docker version which we use for the CI.
112112
// However, the index creation is successful on Db2 hosted on IBM Cloud.
113113
// So we disable these tests until the issue with the Db2 community edition is resolved.
@@ -164,4 +164,9 @@ public void renameColumn_Db2_ForPrimaryOrIndexKeyColumn_ShouldThrowUnsupportedOp
164164
admin.dropTable(namespace1, TABLE4, true);
165165
}
166166
}
167+
168+
@Override
169+
protected boolean isIndexOnBlobColumnSupported() {
170+
return !JdbcTestUtils.isDb2(rdbEngine);
171+
}
167172
}

0 commit comments

Comments
 (0)