Skip to content
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

feature: support openGuass and GuassDB in AT mode #6020

Open
wants to merge 17 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Add changes here for all PR submitted to the 2.x branch.
<!-- Please add the `changes` to the following location(feature/bugfix/optimize/test) based on the type of PR -->

### feature:
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] A brief and accurate description of PR
- [[#6020](https://github.com/seata/seata/pull/6020)] support openGuass and GuassDB in AT mode

### bugfix:
- [[#6090](https://github.com/seata/seata/pull/6090)] fix the TCC aspect exception handling process, do not wrapping the internal call exceptions
Expand Down Expand Up @@ -36,11 +36,13 @@ Thanks to these contributors for their code commits. Please report an unintended
- [ptyin](https://github.com/ptyin)
- [laywin](https://github.com/laywin)
- [imcmai](https://github.com/imcmai)
- [liuqiufeng](https://github.com/liuqiufeng)
- [DroidEye2ONGU](https://github.com/DroidEye2ONGU)
- [funky-eyes](https://github.com/funky-eyes)
- [Bughue](https://github.com/Bughue)
- [wangliang181230](https://github.com/wangliang181230)
- [ggbocoder](https://github.com/ggbocoder)
- [leezongjie](https://github.com/leezongjie)


Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
4 changes: 3 additions & 1 deletion changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<!-- 请根据PR的类型添加 `变更记录` 到以下对应位置(feature/bugfix/optimize/test) 下 -->

### feature:
- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] 准确简要的PR描述
- [[#6020](https://github.com/seata/seata/pull/6020)] AT模式下支持openGauss和GaussDB

### bugfix:
- [[#6090](https://github.com/seata/seata/pull/6090)] 修复tcc切面异常处理过程,不对内部调用异常做包装处理,直接向外抛出
Expand Down Expand Up @@ -35,11 +35,13 @@
- [ptyin](https://github.com/ptyin)
- [laywin](https://github.com/laywin)
- [imcmai](https://github.com/imcmai)
- [liuqiufeng](https://github.com/liuqiufeng)
- [DroidEye2ONGU](https://github.com/DroidEye2ONGU)
- [funky-eyes](https://github.com/funky-eyes)
- [Bughue](https://github.com/Bughue)
- [wangliang181230](https://github.com/wangliang181230)
- [ggbocoder](https://github.com/ggbocoder)
- [leezongjie](https://github.com/leezongjie)


同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
2 changes: 2 additions & 0 deletions common/src/main/java/io/seata/common/util/PageUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ public static String pageSql(String sourceSql, String dbType, int pageNum, int p
case "postgresql":
case "oceanbase":
case "dm":
case "gaussdb":
return LIMIT_TEMPLATE.replace(SOURCE_SQL_PLACE_HOLD, sourceSql)
.replace(LIMIT_PLACE_HOLD, String.valueOf(pageSize))
.replace(OFFSET_PLACE_HOLD, String.valueOf((pageNum - 1) * pageSize));
Expand Down Expand Up @@ -144,6 +145,7 @@ public static String countSql(String sourceSql, String dbType) {
return sourceSql.replaceAll("(?i)(?<=select)(.*)(?=from)", " count(1) ");
case "postgresql":
case "sqlserver":
case "gaussdb":
int lastIndexOfOrderBy = sourceSql.toLowerCase().lastIndexOf("order by");
if (lastIndexOfOrderBy != -1) {
return sourceSql.substring(0, lastIndexOfOrderBy).replaceAll("(?i)(?<=select)(.*)(?=from)", " count(1) ");
Expand Down
7 changes: 6 additions & 1 deletion core/src/main/java/io/seata/core/constants/DBType.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,12 @@ public enum DBType {
/**
* PolarDB db type.
*/
POLARDB;
POLARDB,

/**
* GaussDB db type.
*/
GAUSSDB;

/**
* Valueof db type.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.seata.core.store.db.sql.lock;

import io.seata.common.loader.LoadLevel;

/**
* the database lock store GaussDB sql
*
* @author liuqiufeng
*/
@LoadLevel(name = "gaussdb")
public class GaussDBLockStoreSql extends PostgresqlLockStoreSql {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.seata.core.store.db.sql.log;

import io.seata.common.loader.LoadLevel;

/**
* Database log store GaussDB sql
*
* @author liuqiufeng
*/
@LoadLevel(name = "gaussdb")
public class GaussDBLogStoreSqls extends PostgresqlLogStoreSqls {
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ io.seata.core.store.db.sql.lock.H2LockStoreSql
io.seata.core.store.db.sql.lock.SqlServerLockStoreSql
io.seata.core.store.db.sql.lock.MariadbLockStoreSql
io.seata.core.store.db.sql.lock.PolarDBXLockStoreSql
io.seata.core.store.db.sql.lock.DmLockStoreSql
io.seata.core.store.db.sql.lock.DmLockStoreSql
io.seata.core.store.db.sql.lock.GaussDBLockStoreSql
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ io.seata.core.store.db.sql.log.H2LogStoreSqls
io.seata.core.store.db.sql.log.SqlServerLogStoreSqls
io.seata.core.store.db.sql.log.MariadbLogStoreSqls
io.seata.core.store.db.sql.log.PolarDBXLogStoreSqls
io.seata.core.store.db.sql.log.DmLogStoreSqls
io.seata.core.store.db.sql.log.DmLogStoreSqls
io.seata.core.store.db.sql.log.GaussDBLogStoreSqls
8 changes: 7 additions & 1 deletion dependencies/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,9 @@
<postgresql.version>42.3.3</postgresql.version>
<h2.version>1.4.181</h2.version>
<mariadb.version>2.7.2</mariadb.version>
<opengauss.version>5.0.0-og</opengauss.version>
<!-- db connection pool -->
<druid.version>1.2.7</druid.version>
<druid.version>1.2.12</druid.version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why upgrade the druid version, Is there any compatibility issue between this database and Druid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Druid 1.2.12 is the lowest supported version of openGauss

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why upgrade the druid version, Is there any compatibility issue between this database and Druid?

<commons-dbcp2.version>2.9.0</commons-dbcp2.version>
<hikari.version>3.4.3</hikari.version>
<!-- sql parser -->
Expand Down Expand Up @@ -221,6 +222,11 @@
<artifactId>DmJdbcDriver18</artifactId>
<version>${dm.version}</version>
</dependency>
<dependency>
<groupId>org.opengauss</groupId>
<artifactId>opengauss-jdbc</artifactId>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check license as `BSD 2-clause’

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

checked

<version>${opengauss.version}</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.seata.rm.datasource.exec.gaussdb;

import io.seata.common.loader.LoadLevel;
import io.seata.common.loader.Scope;
import io.seata.rm.datasource.StatementProxy;
import io.seata.rm.datasource.exec.StatementCallback;
import io.seata.rm.datasource.exec.postgresql.PostgresqlInsertExecutor;
import io.seata.sqlparser.SQLRecognizer;
import io.seata.sqlparser.util.JdbcConstants;

/**
* The type GaussDB insert executor.
*
* @author liuqiufeng
*/
@LoadLevel(name = JdbcConstants.GAUSSDB, scope = Scope.PROTOTYPE)
public class GaussDBInsertExecutor extends PostgresqlInsertExecutor {

/**
* Instantiates a new Abstract dml base executor.
*
* @param statementProxy the statement proxy
* @param statementCallback the statement callback
* @param sqlRecognizer the sql recognizer
*/
public GaussDBInsertExecutor(StatementProxy statementProxy, StatementCallback statementCallback, SQLRecognizer sqlRecognizer) {
super(statementProxy, statementCallback, sqlRecognizer);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.seata.rm.datasource.sql.handler.gaussdb;

import io.seata.common.loader.LoadLevel;
import io.seata.rm.datasource.sql.handler.postgresql.PostgresqlEscapeHandler;
import io.seata.sqlparser.util.JdbcConstants;

/**
* The type GaussDB escape handler.
*
* @author liuqiufeng
*/
@LoadLevel(name = JdbcConstants.GAUSSDB)
public class GaussDBEscapeHandler extends PostgresqlEscapeHandler {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.seata.rm.datasource.sql.struct.cache;

import io.seata.common.loader.LoadLevel;
import io.seata.sqlparser.util.JdbcConstants;

/**
* The type Table meta cache.
*
* @author liuqiufeng
*/
@LoadLevel(name = JdbcConstants.GAUSSDB)
public class GaussDBTableMetaCache extends PostgresqlTableMetaCache {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.seata.rm.datasource.undo.gaussdb;

import io.seata.rm.datasource.undo.SQLUndoLog;
import io.seata.rm.datasource.undo.postgresql.PostgresqlUndoDeleteExecutor;

/**
* The type GaussDB undo delete executor.
*
* @author liuqiufeng
*/
public class GaussDBUndoDeleteExecutor extends PostgresqlUndoDeleteExecutor {

/**
* Instantiates a new GaussDB undo delete executor.
*
* @param sqlUndoLog the sql undo log
*/
public GaussDBUndoDeleteExecutor(SQLUndoLog sqlUndoLog) {
super(sqlUndoLog);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright 1999-2019 Seata.io Group.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package io.seata.rm.datasource.undo.gaussdb;

import io.seata.common.loader.LoadLevel;
import io.seata.rm.datasource.undo.AbstractUndoExecutor;
import io.seata.rm.datasource.undo.SQLUndoLog;
import io.seata.rm.datasource.undo.UndoExecutorHolder;
import io.seata.sqlparser.util.JdbcConstants;

/**
* Undo executor holder for GaussDB
*
* @author liuqiufeng
*/
@LoadLevel(name = JdbcConstants.GAUSSDB)
public class GaussDBUndoExecutorHolder implements UndoExecutorHolder {

@Override
public AbstractUndoExecutor getInsertExecutor(SQLUndoLog sqlUndoLog) {
return new GaussDBUndoInsertExecutor(sqlUndoLog);
}

@Override
public AbstractUndoExecutor getUpdateExecutor(SQLUndoLog sqlUndoLog) {
return new GaussDBUndoUpdateExecutor(sqlUndoLog);
}

@Override
public AbstractUndoExecutor getDeleteExecutor(SQLUndoLog sqlUndoLog) {
return new GaussDBUndoDeleteExecutor(sqlUndoLog);
}
}