diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 501f83fc89..2076aec5e1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1436,7 +1436,7 @@ jobs: uses: gradle/actions/setup-gradle@v4 - name: Execute Gradle 'integrationTestJdbc' task - run: ./gradlew integrationTestJdbc ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }} + run: ./gradlew integrationTestJdbc -Dscalardb.jdbc.url=jdbc:mariadb://localhost:3306 ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }} - name: Upload Gradle test reports if: always() @@ -1496,7 +1496,7 @@ jobs: uses: gradle/actions/setup-gradle@v4 - name: Execute Gradle 'integrationTestJdbc' task - run: ./gradlew integrationTestJdbc ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }} + run: ./gradlew integrationTestJdbc -Dscalardb.jdbc.url=jdbc:mariadb://localhost:3306 ${{ matrix.mode.group_commit_enabled && env.INT_TEST_GRADLE_OPTIONS_FOR_GROUP_COMMIT || '' }} - name: Upload Gradle test reports if: always() diff --git a/build.gradle b/build.gradle index c9ae111114..f62511d210 100644 --- a/build.gradle +++ b/build.gradle @@ -35,9 +35,10 @@ subprojects { sqlserverDriverVersion = '11.2.3.jre8' sqliteDriverVersion = '3.47.1.0' yugabyteDriverVersion = '42.7.3-yb-2' + mariadDbDriverVersion = '3.5.1' picocliVersion = '4.7.6' - commonsTextVersion = '1.12.0' - junitVersion = '5.11.3' + commonsTextVersion = '1.13.0' + junitVersion = '5.11.4' commonsLangVersion = '3.17.0' assertjVersion = '3.26.3' mockitoVersion = '4.11.0' diff --git a/core/build.gradle b/core/build.gradle index a492a4b750..38ff82ad00 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -107,6 +107,7 @@ dependencies { implementation "com.microsoft.sqlserver:mssql-jdbc:${sqlserverDriverVersion}" implementation "org.xerial:sqlite-jdbc:${sqliteDriverVersion}" implementation "com.yugabyte:jdbc-yugabytedb:${yugabyteDriverVersion}" + implementation "org.mariadb.jdbc:mariadb-java-client:${mariadDbDriverVersion}" implementation "org.apache.commons:commons-text:${commonsTextVersion}" testImplementation "org.junit.jupiter:junit-jupiter-api:${junitVersion}" testImplementation "org.junit.jupiter:junit-jupiter-params:${junitVersion}" diff --git a/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineFactory.java b/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineFactory.java index 99facb4357..bbfd1baa53 100644 --- a/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineFactory.java +++ b/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineFactory.java @@ -23,6 +23,8 @@ public static RdbEngineStrategy create(JdbcConfig config) { return new RdbEngineSqlite(); } else if (jdbcUrl.startsWith("jdbc:yugabytedb:")) { return new RdbEngineYugabyte(); + } else if (jdbcUrl.startsWith("jdbc:mariadb:")) { + return new RdbEngineMariaDB(); } else { throw new IllegalArgumentException( CoreError.JDBC_RDB_ENGINE_NOT_SUPPORTED.buildMessage(jdbcUrl)); diff --git a/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineMariaDB.java b/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineMariaDB.java new file mode 100644 index 0000000000..9c3664feba --- /dev/null +++ b/core/src/main/java/com/scalar/db/storage/jdbc/RdbEngineMariaDB.java @@ -0,0 +1,24 @@ +package com.scalar.db.storage.jdbc; + +import com.scalar.db.io.DataType; +import java.sql.Driver; +import java.sql.JDBCType; + +class RdbEngineMariaDB extends RdbEngineMysql { + @Override + public Driver getDriver() { + return new org.mariadb.jdbc.Driver(); + } + + @Override + public DataType getDataTypeForScalarDb( + JDBCType type, String typeName, int columnSize, int digits, String columnDescription) { + if (type == JDBCType.BOOLEAN) { + // MariaDB JDBC driver maps TINYINT(1) type as a BOOLEAN JDBC type which differs from the + // MySQL driver which maps it to a BIT type. + return DataType.BOOLEAN; + } else { + return super.getDataTypeForScalarDb(type, typeName, columnSize, digits, columnDescription); + } + } +}