Skip to content

Commit

Permalink
Backport to branch(3.12) : Remove hard-coded collation in JDBC adapter (
Browse files Browse the repository at this point in the history
  • Loading branch information
brfrn169 authored Feb 22, 2024
1 parent 256d2a6 commit fc542f5
Show file tree
Hide file tree
Showing 9 changed files with 377 additions and 51 deletions.
73 changes: 27 additions & 46 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -227,15 +227,11 @@ jobs:
name: MySQL 5.7 integration test
runs-on: ubuntu-latest

services:
mysql:
image: mysql:5.7
env:
MYSQL_ROOT_PASSWORD: mysql
ports:
- 3306:3306

steps:
- name: Run MySQL 5.7
run: |
docker run -e MYSQL_ROOT_PASSWORD=mysql -p 3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
- uses: actions/checkout@v4

- name: Set up JDK 8
Expand All @@ -260,15 +256,11 @@ jobs:
name: MySQL 8.0 integration test
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.0
env:
MYSQL_ROOT_PASSWORD: mysql
ports:
- 3306:3306

steps:
- name: Run MySQL 8.0
run: |
docker run -e MYSQL_ROOT_PASSWORD=mysql -p 3306:3306 -d mysql:8.0 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
- uses: actions/checkout@v4

- name: Set up JDK 8
Expand All @@ -293,15 +285,11 @@ jobs:
name: MySQL 8.1 integration test
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8.1
env:
MYSQL_ROOT_PASSWORD: mysql
ports:
- 3306:3306

steps:
- name: Run MySQL 8.1
run: |
docker run -e MYSQL_ROOT_PASSWORD=mysql -p 3306:3306 -d mysql:8.1 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
- uses: actions/checkout@v4

- name: Set up JDK 8
Expand Down Expand Up @@ -607,6 +595,7 @@ jobs:
MSSQL_PID: "Express"
SA_PASSWORD: "SqlServer17"
ACCEPT_EULA: "Y"
MSSQL_COLLATION: "Japanese_BIN2"
ports:
- 1433:1433

Expand Down Expand Up @@ -642,6 +631,7 @@ jobs:
MSSQL_PID: "Express"
SA_PASSWORD: "SqlServer19"
ACCEPT_EULA: "Y"
MSSQL_COLLATION: "Japanese_BIN2"
ports:
- 1433:1433

Expand Down Expand Up @@ -677,6 +667,7 @@ jobs:
MSSQL_PID: "Express"
SA_PASSWORD: "SqlServer22"
ACCEPT_EULA: "Y"
MSSQL_COLLATION: "Japanese_BIN2"
ports:
- 1433:1433

Expand Down Expand Up @@ -733,15 +724,11 @@ jobs:
name: MariaDB 10 integration test
runs-on: ubuntu-latest

services:
mariadb:
image: mariadb:10.11
env:
MYSQL_ROOT_PASSWORD: mysql
ports:
- 3306:3306

steps:
- name: Run MariaDB 10.11
run: |
docker run -e MYSQL_ROOT_PASSWORD=mysql -p 3306:3306 -d mariadb:10.11 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
- uses: actions/checkout@v4

- name: Set up JDK 8
Expand Down Expand Up @@ -774,14 +761,12 @@ jobs:
HEAP_NEWSIZE: 512m
ports:
- 9042:9042
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: mysql
ports:
- 3306:3306

steps:
- name: Run MySQL 8
run: |
docker run -e MYSQL_ROOT_PASSWORD=mysql -p 3306:3306 -d mysql:8 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
- uses: actions/checkout@v4

- name: Set up JDK 8
Expand All @@ -806,15 +791,11 @@ jobs:
name: ScalarDB Server integration test
runs-on: ubuntu-latest

services:
mysql:
image: mysql:8
env:
MYSQL_ROOT_PASSWORD: mysql
ports:
- 3306:3306

steps:
- name: Run MySQL 8
run: |
docker run -e MYSQL_ROOT_PASSWORD=mysql -p 3306:3306 -d mysql:8 --character-set-server=utf8mb4 --collation-server=utf8mb4_bin
- uses: actions/checkout@v4

- name: Set up JDK 8
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.scalar.db.storage.cassandra;

import com.scalar.db.api.DistributedStorageJapaneseIntegrationTestBase;
import java.util.Collections;
import java.util.Map;
import java.util.Properties;

public class CassandraJapaneseIntegrationTest
extends DistributedStorageJapaneseIntegrationTestBase {
@Override
protected Properties getProperties(String testName) {
return CassandraEnv.getProperties(testName);
}

@Override
protected Map<String, String> getCreationOptions() {
return Collections.singletonMap(CassandraAdmin.REPLICATION_FACTOR, "1");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.scalar.db.storage.cosmos;

import com.scalar.db.api.DistributedStorageJapaneseIntegrationTestBase;
import java.util.Map;
import java.util.Optional;
import java.util.Properties;

public class CosmosJapaneseIntegrationTest extends DistributedStorageJapaneseIntegrationTestBase {

@Override
protected Properties getProperties(String testName) {
return CosmosEnv.getProperties(testName);
}

@Override
protected String getNamespace() {
String namespace = super.getNamespace();
Optional<String> databasePrefix = CosmosEnv.getDatabasePrefix();
return databasePrefix.map(prefix -> prefix + namespace).orElse(namespace);
}

@Override
protected Map<String, String> getCreationOptions() {
return CosmosEnv.getCreationOptions();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package com.scalar.db.storage.dynamo;

import com.scalar.db.api.DistributedStorageJapaneseIntegrationTestBase;
import java.util.Map;
import java.util.Properties;

public class DynamoJapaneseIntegrationTest extends DistributedStorageJapaneseIntegrationTestBase {

@Override
protected Properties getProperties(String testName) {
return DynamoEnv.getProperties(testName);
}

@Override
protected Map<String, String> getCreationOptions() {
return DynamoEnv.getCreationOptions();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.scalar.db.storage.jdbc;

import com.scalar.db.api.DistributedStorageJapaneseIntegrationTestBase;
import java.util.Properties;

public class JdbcDatabaseJapaneseIntegrationTest
extends DistributedStorageJapaneseIntegrationTestBase {

@Override
protected Properties getProperties(String testName) {
return JdbcEnv.getProperties(testName);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class RdbEngineMysql implements RdbEngineStrategy {

@Override
public String[] createNamespaceSqls(String fullNamespace) {
return new String[] {"CREATE SCHEMA " + fullNamespace + " character set utf8 COLLATE utf8_bin"};
return new String[] {"CREATE SCHEMA " + fullNamespace};
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public String getDataTypeForEngine(DataType scalarDbDataType) {
case INT:
return "INT";
case TEXT:
return "VARCHAR(8000) COLLATE Latin1_General_BIN";
return "VARCHAR(8000)";
default:
throw new AssertionError();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ private void getTableMetadata_MetadataSchemaNotExistsForX_ShouldReturnNull(RdbEn
public void createNamespace_forMysql_shouldExecuteCreateNamespaceStatement()
throws ExecutionException, SQLException {
createNamespace_forX_shouldExecuteCreateNamespaceStatement(
RdbEngine.MYSQL, "CREATE SCHEMA `my_ns` character set utf8 COLLATE utf8_bin");
RdbEngine.MYSQL, "CREATE SCHEMA `my_ns`");
}

@Test
Expand Down Expand Up @@ -436,7 +436,7 @@ public void createTable_forSqlServer_shouldExecuteCreateTableStatement()
throws ExecutionException, SQLException {
createTable_forX_shouldExecuteCreateTableStatement(
RdbEngine.SQL_SERVER,
"CREATE TABLE [my_ns].[foo_table]([c3] BIT,[c1] VARCHAR(8000) COLLATE Latin1_General_BIN,"
"CREATE TABLE [my_ns].[foo_table]([c3] BIT,[c1] VARCHAR(8000),"
+ "[c4] VARBINARY(8000),[c2] BIGINT,[c5] INT,[c6] FLOAT,[c7] FLOAT(24), PRIMARY KEY ([c3],[c1],[c4]))",
"CREATE INDEX [index_my_ns_foo_table_c4] ON [my_ns].[foo_table] ([c4])",
"CREATE INDEX [index_my_ns_foo_table_c1] ON [my_ns].[foo_table] ([c1])",
Expand Down Expand Up @@ -689,7 +689,7 @@ public void createTable_WithClusteringOrderForSqlServer_shouldExecuteCreateTable
throws ExecutionException, SQLException {
createTable_WithClusteringOrderForX_shouldExecuteCreateTableStatement(
RdbEngine.SQL_SERVER,
"CREATE TABLE [my_ns].[foo_table]([c3] BIT,[c1] VARCHAR(8000) COLLATE Latin1_General_BIN,"
"CREATE TABLE [my_ns].[foo_table]([c3] BIT,[c1] VARCHAR(8000),"
+ "[c4] VARBINARY(8000),[c2] BIGINT,[c5] INT,[c6] FLOAT,[c7] FLOAT(24), PRIMARY KEY ([c3] ASC,[c1] DESC,[c4] ASC))",
"CREATE INDEX [index_my_ns_foo_table_c4] ON [my_ns].[foo_table] ([c4])",
"CREATE INDEX [index_my_ns_foo_table_c1] ON [my_ns].[foo_table] ([c1])",
Expand Down
Loading

0 comments on commit fc542f5

Please sign in to comment.