-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feature: support shentongdatabase xa mode #7664
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 shentongdatabase xa mode #7664
Conversation
2. Upgrade depends on druid version 1.2.25 3. Modify test cases that fail after upgrading druid
There was a problem hiding this 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.
...druid/src/main/java/org/apache/seata/sqlparser/druid/oscar/OscarOperateRecognizerHolder.java
Outdated
Show resolved
Hide resolved
Codecov Report❌ Patch coverage is
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
🚀 New features to boost your workflow:
|
…/sqlparser/druid/oscar/OscarOperateRecognizerHolder.java Co-authored-by: Copilot <[email protected]>
funky-eyes
left a comment
There was a problem hiding this 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()); |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
…_xa_mode' into feature_support_shentongdatabase_xa_mode
…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
funky-eyes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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()); |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
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.
| if (wrappedPhysicalConn instanceof DruidStatementConnection) { | ||
| wrappedPhysicalConn = ((DruidStatementConnection) wrappedPhysicalConn).getConnection(); | ||
| } |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
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.
| 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; |
Copilot
AI
Sep 30, 2025
There was a problem hiding this comment.
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.
| 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); |
Ⅰ. Describe what this PR did
Ⅱ. 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