Skip to content

HHH-19365 GaussDB Dialect Support #10199

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ jobs:
- rdbms: mysql
- rdbms: mariadb
- rdbms: postgresql
- rdbms: gaussdb
- rdbms: edb
- rdbms: oracle
- rdbms: db2
Expand Down
2 changes: 2 additions & 0 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ elif [ "$RDBMS" == "mariadb" ] || [ "$RDBMS" == "mariadb_10_4" ]; then
goal="-Pdb=mariadb_ci"
elif [ "$RDBMS" == "postgresql" ] || [ "$RDBMS" == "postgresql_13" ]; then
goal="-Pdb=pgsql_ci"
elif [ "$RDBMS" == "gaussdb" ]; then
goal="-Pdb=gaussdb -DdbHost=localhost:8000"
elif [ "$RDBMS" == "edb" ] || [ "$RDBMS" == "edb_13" ]; then
goal="-Pdb=edb_ci -DdbHost=localhost:5444"
elif [ "$RDBMS" == "oracle" ]; then
Expand Down
2 changes: 2 additions & 0 deletions ci/database-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ elif [ "$RDBMS" == 'mariadb' ]; then
bash $DIR/../docker_db.sh mariadb
elif [ "$RDBMS" == 'postgresql' ]; then
bash $DIR/../docker_db.sh postgresql
elif [ "$RDBMS" == 'gaussdb' ]; then
bash $DIR/../docker_db.sh gaussdb
elif [ "$RDBMS" == 'edb' ]; then
bash $DIR/../docker_db.sh edb
elif [ "$RDBMS" == 'db2' ]; then
Expand Down
40 changes: 40 additions & 0 deletions docker_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,45 @@ postgresql_17() {
$CONTAINER_CLI exec postgres bash -c '/usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y && apt install -y postgresql-17-pgvector && psql -U hibernate_orm_test -d hibernate_orm_test -c "create extension vector;"'
}

gaussdb() {
$CONTAINER_CLI rm -f opengauss || true

# config param
CONTAINER_NAME=opengauss
IMAGE=opengauss/opengauss:7.0.0-RC1.B023
PORT=8000
DB_USER=hibernate_orm_test
DB_PASSWORD=Hibernate_orm_test@1234
DB_NAME=hibernate_orm_test
PSQL_IMAGE=postgres:14

echo "start OpenGauss container..."
$CONTAINER_CLI run --name ${CONTAINER_NAME} \
--privileged=true \
-e GS_USERNAME=${DB_USER} \
-e GS_PASSWORD=${DB_PASSWORD} \
-e GS_PORT=${PORT} \
-p ${PORT}:8000 \
-d ${IMAGE}

echo "wait OpenGauss starting..."
sleep 30

echo " Initialize the database using the PostgreSQL client container..."

$CONTAINER_CLI run --rm --network=host ${PSQL_IMAGE} \
bash -c "
PGPASSWORD='${DB_PASSWORD}' psql -h localhost -p ${PORT} -U ${DB_USER} -d postgres -c \"CREATE DATABASE ${DB_NAME} OWNER ${DB_USER};\" &&
PGPASSWORD='${DB_PASSWORD}' psql -h localhost -p ${PORT} -U ${DB_USER} -d ${DB_NAME} -c \"CREATE SCHEMA test AUTHORIZATION ${DB_USER};\"
"

echo "Initialization completed"
echo "connection information"
echo " Host: localhost"
echo " Port: ${PORT}"
echo " Database: ${DB_NAME}"
}

edb() {
edb_17
}
Expand Down Expand Up @@ -1089,6 +1128,7 @@ if [ -z ${1} ]; then
echo -e "\toracle"
echo -e "\toracle_23"
echo -e "\toracle_21"
echo -e "\tgaussdb"
echo -e "\tpostgresql"
echo -e "\tpostgresql_17"
echo -e "\tpostgresql_16"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import org.hibernate.community.dialect.AltibaseDialect;
import org.hibernate.community.dialect.TiDBDialect;
import org.hibernate.community.dialect.GaussDBDialect;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
import org.hibernate.agroal.internal.AgroalConnectionProvider;

Expand All @@ -17,6 +18,7 @@
*/
@SkipForDialect(value = TiDBDialect.class, comment = "Doesn't support SERIALIZABLE isolation")
@SkipForDialect(value = AltibaseDialect.class, comment = "Altibase cannot change isolation level in autocommit mode")
@SkipForDialect(value = GaussDBDialect.class, comment = "GaussDB does not support SERIALIZABLE isolation")
public class AgroalTransactionIsolationConfigTest extends BaseTransactionIsolationConfigTest {
@Override
protected ConnectionProvider getConnectionProviderUnderTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
import org.hibernate.c3p0.internal.C3P0ConnectionProvider;
import org.hibernate.community.dialect.AltibaseDialect;
import org.hibernate.community.dialect.GaussDBDialect;
import org.hibernate.dialect.SybaseASEDialect;
import org.hibernate.community.dialect.TiDBDialect;
import org.hibernate.engine.jdbc.connections.spi.ConnectionProvider;
Expand All @@ -23,6 +24,7 @@
@SkipForDialect(value = TiDBDialect.class, comment = "Doesn't support SERIALIZABLE isolation")
@SkipForDialect(value = AltibaseDialect.class, comment = "Altibase cannot change isolation level in autocommit mode")
@SkipForDialect(value = SybaseASEDialect.class, comment = "JtdsConnection.isValid not implemented")
@SkipForDialect(value = GaussDBDialect.class, comment = "GaussDB does not support SERIALIZABLE isolation")
public class C3p0TransactionIsolationConfigTest extends BaseTransactionIsolationConfigTest {
private StandardServiceRegistry ssr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,21 @@ public String getDriverClassName(String jdbcUrl) {
? "org.apache.derby.jdbc.ClientDriver"
: "org.apache.derby.jdbc.EmbeddedDriver";
}
},

GAUSSDB {
@Override
public Dialect createDialect(DialectResolutionInfo info) {
return new GaussDBDialect(info);
}
@Override
public boolean productNameMatches(String databaseName) {
return "GaussDB".equals( databaseName );
}
@Override
public String getDriverClassName(String jdbcUrl) {
return "com.huawei.gaussdb.jdbc.Driver";
}
};

/**
Expand Down
Loading