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 shentong database #6864

Merged
merged 27 commits into from
Oct 11, 2024

Conversation

dsomehan
Copy link
Contributor

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@xjlgod
Copy link
Contributor

xjlgod commented Sep 18, 2024

Maybe you can provide more detailed changes you made?
也许你可以更详细的列出你的改动点?

@dsomehan
Copy link
Contributor Author

Maybe you can provide more detailed changes you made? 也许你可以更详细的列出你的改动点?

Prerequisites: Oscar database engine is basically compatible with Oracle syntax,

  1. Add Oscar DBType recognition to PageUtil's pageSql, countSql, getTimeStartSql, and getTimeEndSql methods.
  2. Add Oscar enumeration item to DBType.
  3. Add OscarLockStoreSql class for generating Oscar database lock information sql.
  4. Add OscarLogStoreSqls class for generating Oscar database global transaction table related sql.
  5. Use SPI to declare the two classes 3 and 4.
  6. Add logic to obtain Oscar database connection resourceId in DataSourceProxy.
  7. Implement Oscar's BaseInsertExecutor and Sequenceable interfaces, and declare them using SPI.
  8. Add Oscar's keyword checking class, and declare it using SPI.
  9. Add Oscar's table structure cache implementation, and declare it using SPI.
  10. Add Oscar's undo implementation to RM data source, and declare it using SPI.
  11. Add Oscar's SQL parsing implementation, and declare it using SPI.
  12. Add test case code for the above changes.

前提:神通oscar数据库基本兼容oracle语法,

  1. PageUtil中pageSql、countSql、getTimeStartSql、getTimeEndSql方法添加oscar dbtype的识别
  2. DBType添加OSCAR枚举项
  3. 添加OscarLockStoreSql OSCAR数据库锁信息sql生成类
  4. 添加和OscarLogStoreSqls OSCAR数据库全局事务表相关sql生成类
  5. 并将3和4两个类使用spi方式进行声明
  6. 在DataSourceProxy中添加获取OSCAR数据库连接的resourceId的逻辑
  7. 实现OSCAR的BaseInsertExecutor和Sequenceable接口,并通过spi方式声明
  8. 添加OSCAR的关键字检查类,并通过spi方式声明
  9. 添加OSCAR表结构缓存类的实现,并通过spi方式声明
  10. rm数据源中添加oscar的undo实现,并通过spi方式声明
  11. 添加oscar的sql解析实现,并通过spi方式声明
  12. 添加上述改动的测试用例代码

@dsomehan
Copy link
Contributor Author

基本上的改动就是这些,主要是添加了神通数据库支持

@dsomehan
Copy link
Contributor Author

dsomehan commented Sep 19, 2024

客户端的适配我在druid里提供了pr,在合并之前如果需要使用可以参考

import com.alibaba.druid.util.JdbcUtils;
import io.seata.common.loader.LoadLevel;
import io.seata.sqlparser.util.DbTypeParser;


@LoadLevel(name = "druid", order = 1)
public class OscarDbTypeParser implements DbTypeParser {
	public OscarDbTypeParser() {
	}
	@Override
	public String parseFromJdbcUrl(String jdbcUrl) {
		if (jdbcUrl.startsWith("jdbc:oscar:")) {
			return "oscar";
		}
		return JdbcUtils.getDbType(jdbcUrl, null);
	}
}

@dsomehan dsomehan force-pushed the feature_support_shentong_database branch from 0680ac9 to d31610b Compare September 23, 2024 06:06
@funky-eyes funky-eyes added this to the 2.x Backlog milestone Sep 26, 2024
@funky-eyes funky-eyes added first-time contributor first-time contributor module/rm-datasource rm-datasource module module/sqlparser sql-parser module module/common common module labels Sep 26, 2024
@funky-eyes funky-eyes added the mode: AT AT transaction mode label Oct 1, 2024
@funky-eyes funky-eyes removed this from the 2.x Backlog milestone Oct 8, 2024
@funky-eyes funky-eyes added this to the 2.3.0 milestone Oct 8, 2024
dsomehan and others added 10 commits October 9, 2024 09:37
…/sqlparser/druid/oscar/OscarInsertRecognizer.java

Co-authored-by: funkye <[email protected]>
…/sqlparser/druid/oscar/OscarSelectForUpdateRecognizer.java

Co-authored-by: funkye <[email protected]>
…/sqlparser/druid/oscar/OscarSelectForUpdateRecognizer.java

Co-authored-by: funkye <[email protected]>
…o/oscar/OscarUndoExecutorHolder.java

Co-authored-by: funkye <[email protected]>
…/sqlparser/druid/oscar/OscarDeleteRecognizer.java

Co-authored-by: funkye <[email protected]>
…/sqlparser/druid/oscar/OscarUpdateRecognizer.java

Co-authored-by: funkye <[email protected]>
…/sqlparser/druid/oscar/OscarInsertRecognizer.java

Co-authored-by: funkye <[email protected]>
…/sqlparser/druid/oscar/OscarDeleteRecognizer.java

Co-authored-by: funkye <[email protected]>
Copy link

codecov bot commented Oct 11, 2024

Codecov Report

Attention: Patch coverage is 59.71979% with 460 lines in your changes missing coverage. Please review.

Project coverage is 52.53%. Comparing base (3b8ccfc) to head (21c61a7).
Report is 22 commits behind head on 2.x.

Files with missing lines Patch % Lines
...tasource/sql/struct/cache/OscarTableMetaCache.java 0.00% 104 Missing ⚠️
...a/sqlparser/druid/oscar/OscarUpdateRecognizer.java 0.00% 55 Missing ⚠️
...a/sqlparser/druid/oscar/OscarInsertRecognizer.java 0.00% 54 Missing ⚠️
...ata/sqlparser/druid/oscar/BaseOscarRecognizer.java 0.00% 51 Missing ⚠️
...er/druid/oscar/OscarSelectForUpdateRecognizer.java 0.00% 35 Missing ⚠️
.../rm/datasource/undo/oscar/OscarUndoLogManager.java 11.42% 31 Missing ⚠️
...a/sqlparser/druid/oscar/OscarDeleteRecognizer.java 0.00% 28 Missing ⚠️
...tasource/sql/handler/oscar/OscarEscapeHandler.java 95.98% 27 Missing ⚠️
...datasource/undo/oscar/OscarUndoInsertExecutor.java 0.00% 18 Missing ⚠️
...datasource/undo/oscar/OscarUndoDeleteExecutor.java 0.00% 16 Missing ⚠️
... and 6 more
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6864      +/-   ##
============================================
+ Coverage     52.33%   52.53%   +0.19%     
- Complexity     6526     6543      +17     
============================================
  Files          1106     1122      +16     
  Lines         38716    39857    +1141     
  Branches       4586     4668      +82     
============================================
+ Hits          20263    20939     +676     
- Misses        16464    16922     +458     
- Partials       1989     1996       +7     
Files with missing lines Coverage Δ
...in/java/org/apache/seata/common/util/PageUtil.java 45.71% <ø> (ø)
...ql/distributed/lock/DistributedLockSqlFactory.java 0.00% <ø> (ø)
...ta/core/store/db/sql/lock/LockStoreSqlFactory.java 75.00% <ø> (ø)
...eata/core/store/db/sql/lock/OscarLockStoreSql.java 100.00% <100.00%> (ø)
...seata/core/store/db/sql/log/OscarLogStoreSqls.java 100.00% <100.00%> (ø)
...org/apache/seata/sqlparser/util/JdbcConstants.java 0.00% <ø> (ø)
...n/java/org/apache/seata/core/constants/DBType.java 0.00% <0.00%> (ø)
...datasource/undo/oscar/OscarUndoExecutorHolder.java 0.00% <0.00%> (ø)
...rg/apache/seata/rm/datasource/DataSourceProxy.java 67.36% <0.00%> (-2.20%) ⬇️
.../rm/datasource/exec/oscar/OscarInsertExecutor.java 83.78% <83.78%> (ø)
... and 12 more

... and 4 files with indirect coverage changes

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM

@funky-eyes funky-eyes merged commit 5752786 into apache:2.x Oct 11, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time contributor first-time contributor mode: AT AT transaction mode module/common common module module/rm-datasource rm-datasource module module/sqlparser sql-parser module multilingual
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants