- 
                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
Conversation
| Codecov Report❌ Patch coverage is  Additional details and impacted files@@             Coverage Diff              @@
##                2.x    #7675      +/-   ##
============================================
+ Coverage     61.38%   61.53%   +0.15%     
+ Complexity      684      680       -4     
============================================
  Files          1323     1324       +1     
  Lines         49943    50047     +104     
  Branches       5885     5910      +25     
============================================
+ Hits          30657    30796     +139     
+ Misses        16524    16447      -77     
- Partials       2762     2804      +42     
 🚀 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. | 
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 Oracle's INSERT ALL (multi-insert) batch statements in Seata. The implementation extends the SQL parser to handle Oracle-specific bulk insert syntax that was previously unsupported.
- Added Oracle multi-insert recognizer to parse and validate INSERT ALL statements
- Extended factory and holder classes to support the new statement type
- Enforced single-table constraint with consistent column definitions for transaction safety
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description | 
|---|---|
| OracleMultiInsertRecognizer.java | New recognizer class implementing SQLInsertRecognizer interface for Oracle INSERT ALL statements | 
| OracleOperateRecognizerHolder.java | Added method to create multi-insert recognizers | 
| DruidSQLRecognizerFactoryImpl.java | Extended factory to handle OracleMultiInsertStatement AST nodes | 
| OracleMultiInsertRecognizerTest.java | Comprehensive test suite with 11 test cases covering functionality and edge cases | 
| DruidSQLRecognizerFactoryTest.java | Updated factory tests with multi-insert and INSERT FIRST scenarios | 
| changes files | Documentation updates for the new feature | 
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
        
          
                ...d/src/test/java/org/apache/seata/sqlparser/druid/oracle/OracleMultiInsertRecognizerTest.java
          
            Show resolved
            Hide resolved
        
      | @funky-eyes PTAL❤️ If you have any further questions please let me know | 
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 7 out of 7 changed files in this pull request and generated 2 comments.
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| // 1.sql | ||
| String sql = "INSERT ALL INTO a(id) VALUES(1) INTO a(id) VALUES(2) SELECT 1 FROM dual"; | ||
|  | ||
| SQLStatement stmt = SQLUtils.parseSingleStatement(sql, "oracle"); | ||
| assertTrue(stmt instanceof OracleMultiInsertStatement); | ||
|  | ||
| // 2. mock recognizerHolder and recognizer | 
    
      
    
      Copilot
AI
    
    
    
      Oct 17, 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.
Comment formatting inconsistency: '1.sql' should be '1. SQL' to match the style of '2. mock recognizerHolder and recognizer' and '3. stub getMultiInsertRecognizer'.
        
          
                ...druid/src/main/java/org/apache/seata/sqlparser/druid/oracle/OracleMultiInsertRecognizer.java
              
                Outdated
          
            Show resolved
            Hide resolved
        
      …/sqlparser/druid/oracle/OracleMultiInsertRecognizer.java Co-authored-by: Copilot <[email protected]>
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
| Well done. The code format verification failed due to other PR(#7643 ) and will be fixed later. | 
| LGTM | 
Ⅰ. 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 DUALwill be parsed asOracleMultiInsertStatement, butDruidSQLRecognizerFactoryImpldoes not support this statement type.Solution
DruidSQLRecognizerFactoryImplto add support forOracleMultiInsertStatementOracleOperateRecognizerHolderto add methods specifically for handling multiple insertsOracleMultiInsertRecognizerand 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.❤️