Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@dsomehan
Copy link
Contributor

@dsomehan dsomehan commented Sep 26, 2025

  1. Upgrade depends on druid version 1.2.25
  2. Modify test cases that fail after upgrading druid

Ⅰ. Describe what this PR did

  1. Support shentongdatabase xa mode
  2. Upgrade depends on druid version 1.2.25
  3. Modify test cases that fail after upgrading druid
  1. 支持神通数据库XA模式
  2. 升级依赖druid版本到1.2.25
  3. 修改升级druid导致的测试用例错误

Ⅱ. Does this pull request fix one issue?

fixes #7665

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

2. Upgrade depends on druid version 1.2.25
3. Modify test cases that fail after upgrading druid
@funky-eyes funky-eyes added type: feature Category issues or prs related to feature request. mode: XA XA transaction mode module/rm-datasource rm-datasource module labels Sep 26, 2025
@funky-eyes funky-eyes added this to the 2.6.0 milestone Sep 26, 2025
@funky-eyes funky-eyes requested a review from Copilot September 26, 2025 02:31
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for ShenTong database XA mode and upgrades the Druid dependency to version 1.2.25, with corresponding test case updates to address compatibility issues.

  • Support for ShenTong database XA mode by adding OSCAR database type handling
  • Upgrade Druid dependency from version 1.2.20 to 1.2.25
  • Update test cases to handle changes in Druid API by replacing deprecated classes and adapting to new connection wrapper behavior

Reviewed Changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
dependencies/pom.xml Updates Druid version to 1.2.25 and adds Oscar JDBC dependency
rm-datasource/src/main/java/org/apache/seata/rm/datasource/util/XAUtils.java Adds XA connection support for OSCAR database type
sqlparser/seata-sqlparser-druid/src/main/java/org/apache/seata/sqlparser/druid/oscar/OscarOperateRecognizerHolder.java Updates Oscar select-for-update recognition logic to use new Druid API
Multiple test files Replaces deprecated OracleBinaryDoubleExpr with OracleIntervalExpr and adds handling for DruidStatementConnection wrapper
Distribution files Updates license and notice files to reflect new Druid version

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@funky-eyes funky-eyes changed the title Support shentongdatabase xa mode feature: support shentongdatabase xa mode Sep 26, 2025
@codecov
Copy link

codecov bot commented Sep 26, 2025

Codecov Report

❌ Patch coverage is 76.92308% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.27%. Comparing base (e06d364) to head (bb47ce6).
⚠️ Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...rser/druid/oscar/OscarOperateRecognizerHolder.java 66.66% 0 Missing and 3 partials ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##                2.x    #7664   +/-   ##
=========================================
  Coverage     61.27%   61.27%           
  Complexity      666      666           
=========================================
  Files          1314     1314           
  Lines         49817    49853   +36     
  Branches       5858     5874   +16     
=========================================
+ Hits          30523    30546   +23     
+ Misses        16552    16521   -31     
- Partials       2742     2786   +44     
Files with missing lines Coverage Δ
...a/org/apache/seata/rm/datasource/util/XAUtils.java 48.48% <100.00%> (+3.32%) ⬆️
...rser/druid/oscar/OscarOperateRecognizerHolder.java 78.57% <66.66%> (+7.14%) ⬆️

... and 9 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

…/sqlparser/druid/oscar/OscarOperateRecognizerHolder.java

Co-authored-by: Copilot <[email protected]>
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.

Please register your PR in those two files :
https://github.com/apache/incubator-seata/blob/2.x/changes/zh-cn/2.x.md
https://github.com/apache/incubator-seata/blob/2.x/changes/en-us/2.x.md
and run mvn spotless:apply with JDK 17 or later, then commit the changes to ensure the code style is consistent.

List<SQLStatement> sqlStatements = SQLUtils.parseStatements(s, DB_TYPE);
SQLInsertStatement sqlInsertStatement = (SQLInsertStatement) sqlStatements.get(0);
sqlInsertStatement.getColumns().add(new OracleBinaryDoubleExpr());
sqlInsertStatement.getColumns().add(new OracleIntervalExpr());
Copy link
Contributor

Choose a reason for hiding this comment

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

Why was OracleBinaryDoubleExpr changed to OracleIntervalExpr? Is it because newer versions of Druid return a different Expr?

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.25 修改了OracleBinaryDoubleExpr的继承路径,改为继承了SQLTypeExpr,导致在这个测试用例里无法抛出异常SQLParsingException, 我猜测这个测试用例编写目的是为了输入一个InsertRecognizer解析不了的类型,抛出异常

Because druid 1.2.25 changed the inheritance path of OracleBinaryDoubleExpr to inherit from SQLTypeExpr, there is no way to throw a SQLParsingException in this test case. My guess is that this test case is written to throw an exception for input of a type that InsertRecognizer can't parse

https://github.com/alibaba/druid/pull/6367/files#diff-fcc11688728fe89390da42807576626d1b4c855875496dd996787932088e5173

Copy link
Contributor Author

Choose a reason for hiding this comment

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

经过测试,testGetInsertColumns是没必要修改的,需要修改的是testGetInsertRows
After testing, testGetInsertColumns is not necessary to change, the need to change is testGetInsertRows

@dsomehan dsomehan requested a review from funky-eyes September 29, 2025 00:58
…ngdatabase_xa_mode

# Conflicts:
#	changes/en-us/2.x.md
#	changes/zh-cn/2.x.md
…ngdatabase_xa_mode

# Conflicts:
#	changes/en-us/2.x.md
#	changes/zh-cn/2.x.md
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 requested a review from Copilot September 30, 2025 08:21
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 38 out of 38 changed files in this pull request and generated 3 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

SQLInsertStatement sqlInsertStatement = (SQLInsertStatement) sqlStatements.get(0);
sqlInsertStatement.getValuesList().get(0).getValues().set(pkIndex, new OracleBinaryDoubleExpr());
SQLInsertStatement sqlInsertStatement = (SQLInsertStatement) getSQLStatement(s);
sqlInsertStatement.getValuesList().get(0).getValues().set(pkIndex, new OracleIntervalExpr());
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The change from OracleBinaryDoubleExpr to OracleIntervalExpr should be consistent across all similar test cases. This appears to be done to fix compatibility issues with the Druid upgrade, but consider using a more generic expression type that's less likely to have compatibility issues in future Druid versions.

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +143
if (wrappedPhysicalConn instanceof DruidStatementConnection) {
wrappedPhysicalConn = ((DruidStatementConnection) wrappedPhysicalConn).getConnection();
}
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

This pattern of unwrapping DruidStatementConnection is repeated across many test files. Consider extracting this logic into a shared utility method in a test base class to reduce code duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Comment on lines +51 to 65
if ((ast instanceof SQLSelectStatement)) {
SQLSelectStatement selectStatement = (SQLSelectStatement) ast;
if (selectStatement.getSelect() != null) {
if (selectStatement.getSelect().getFirstQueryBlock() != null) {
OscarSelectQueryBlock queryBlock =
(OscarSelectQueryBlock) selectStatement.getSelect().getFirstQueryBlock();
if (queryBlock.getForClause() != null) {
if (queryBlock.getForClause().getOption() == OscarSelectQueryBlock.ForClause.Option.UPDATE) {
return new OscarSelectForUpdateRecognizer(sql, ast);
}
}
}
}
}
return null;
Copy link

Copilot AI Sep 30, 2025

Choose a reason for hiding this comment

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

[nitpick] The nested if statements create deep nesting that reduces readability. Consider using early returns or extracting validation logic into separate methods to flatten the structure and improve code clarity.

Suggested change
if ((ast instanceof SQLSelectStatement)) {
SQLSelectStatement selectStatement = (SQLSelectStatement) ast;
if (selectStatement.getSelect() != null) {
if (selectStatement.getSelect().getFirstQueryBlock() != null) {
OscarSelectQueryBlock queryBlock =
(OscarSelectQueryBlock) selectStatement.getSelect().getFirstQueryBlock();
if (queryBlock.getForClause() != null) {
if (queryBlock.getForClause().getOption() == OscarSelectQueryBlock.ForClause.Option.UPDATE) {
return new OscarSelectForUpdateRecognizer(sql, ast);
}
}
}
}
}
return null;
if (!(ast instanceof SQLSelectStatement)) {
return null;
}
SQLSelectStatement selectStatement = (SQLSelectStatement) ast;
if (selectStatement.getSelect() == null) {
return null;
}
if (selectStatement.getSelect().getFirstQueryBlock() == null) {
return null;
}
OscarSelectQueryBlock queryBlock =
(OscarSelectQueryBlock) selectStatement.getSelect().getFirstQueryBlock();
if (queryBlock.getForClause() == null) {
return null;
}
if (queryBlock.getForClause().getOption() != OscarSelectQueryBlock.ForClause.Option.UPDATE) {
return null;
}
return new OscarSelectForUpdateRecognizer(sql, ast);

Copilot uses AI. Check for mistakes.
@funky-eyes funky-eyes merged commit b6af418 into apache:2.x Sep 30, 2025
10 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mode: XA XA transaction mode module/rm-datasource rm-datasource module type: feature Category issues or prs related to feature request.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XA mode for shentongdatabase is not supported

2 participants