-
Notifications
You must be signed in to change notification settings - Fork 8.9k
feature: support Oracle Batch Insert #7675
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
base: 2.x
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## 2.x #7675 +/- ##
============================================
- Coverage 61.29% 61.25% -0.04%
Complexity 666 666
============================================
Files 1314 1315 +1
Lines 49853 49957 +104
Branches 5874 5899 +25
============================================
+ Hits 30556 30601 +45
- Misses 16516 16563 +47
- Partials 2781 2793 +12
🚀 New features to boost your workflow:
|
...rser-druid/src/main/java/org/apache/seata/sqlparser/druid/DruidSQLRecognizerFactoryImpl.java
Show resolved
Hide resolved
...druid/src/main/java/org/apache/seata/sqlparser/druid/oracle/OracleMultiInsertRecognizer.java
Outdated
Show resolved
Hide resolved
...druid/src/main/java/org/apache/seata/sqlparser/druid/oracle/OracleMultiInsertRecognizer.java
Outdated
Show resolved
Hide resolved
...druid/src/main/java/org/apache/seata/sqlparser/druid/oracle/OracleMultiInsertRecognizer.java
Show resolved
Hide resolved
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.
By default, only the insert all
syntax of Oracle Batch Insert and the same column situation is supported. The same effect can be achieved by adding multiple values clauses to a normal insert. Are there plans to support more in the future?
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.
Currently, we only support batch insert of multiple columns (same columns) in a single table. We will continue to support this in the future.
First, thanks to @YoWuwuuuw for the bug report.❤️ For now, I think we can start with basic support, like this pull request, which supports batch inserts for multiple columns in a single table. However, for other scenarios, such as support for insert-first syntax and ConditionalInsertClause, further support can be implemented through other pull requests. For multi-table scenarios, I don't think support is necessary at this time. |
Ⅰ. Describe what this PR did
Problem Background
Seata cannot support Oracle's INSERT ALL batch insert statements. For example,
insert all into a (id) values(1) into a (id) values(2) SELECT 1 FROM DUAL
will be parsed asOracleMultiInsertStatement
, butDruidSQLRecognizerFactoryImpl
does not support this statement type.Solution
DruidSQLRecognizerFactoryImpl
to add support forOracleMultiInsertStatement
OracleOperateRecognizerHolder
to add methods specifically for handling multiple insertsOracleMultiInsertRecognizer
and useast.getEntries()
to obtain insert items. It supports parsing multiple INSERT INTO clauses and correctly handles various data types (NULL, parameter placeholders, sequences, etc.)Ⅱ. Does this pull request fix one issue?
fixes #7607
Ⅲ. Why don't you add test cases (unit test/integration test)?
UT have been added
Ⅳ. Describe how to verify it
mvn clean test
Ⅴ. Special notes for reviews
Currently, only single-table Oracle INSERT batching is supported. I don't believe multi-table support is necessary because branching transactions can be useful.❤️