Skip to content

Conversation

@maple525866
Copy link
Contributor

@maple525866 maple525866 commented Sep 29, 2025

Ⅰ. Describe what this PR did

  1. 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 as OracleMultiInsertStatement, but DruidSQLRecognizerFactoryImpl does not support this statement type.

  2. Solution

  • Extend DruidSQLRecognizerFactoryImpl to add support for OracleMultiInsertStatement
  • Extend OracleOperateRecognizerHolder to add methods specifically for handling multiple inserts
  • Create OracleMultiInsertRecognizer and use ast.getEntries() to obtain insert items. It supports parsing multiple INSERT INTO clauses and correctly handles various data types (NULL, parameter placeholders, sequences, etc.)
  1. Verification Functionality -> Created OracleMultiInsertRecognizerTest containing 11 test cases:
  • Basic functional testing: SQL type, table name, table alias
  • Column processing testing: Insert column retrieval, empty column detection
  • Data row testing: Basic data, NULL values, parameter placeholders, primary key processing
  • Complex scenario testing: Multi-table inserts, complex statements, edge cases
  • Interface consistency testing: Ensures compliance with the Seata interface specification

Ⅱ. 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.❤️

@codecov
Copy link

codecov bot commented Sep 29, 2025

Codecov Report

❌ Patch coverage is 66.34615% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.53%. Comparing base (d239a81) to head (d350bf6).
⚠️ Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...rser/druid/oracle/OracleMultiInsertRecognizer.java 68.04% 19 Missing and 12 partials ⚠️
...sqlparser/druid/DruidSQLRecognizerFactoryImpl.java 50.00% 2 Missing and 1 partial ⚠️
...er/druid/oracle/OracleOperateRecognizerHolder.java 0.00% 1 Missing ⚠️
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     
Files with missing lines Coverage Δ
...er/druid/oracle/OracleOperateRecognizerHolder.java 87.50% <0.00%> (-12.50%) ⬇️
...sqlparser/druid/DruidSQLRecognizerFactoryImpl.java 81.81% <50.00%> (-5.03%) ⬇️
...rser/druid/oracle/OracleMultiInsertRecognizer.java 68.04% <68.04%> (ø)

... and 44 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.

Copy link
Contributor

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?

Copy link
Contributor Author

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.

@maple525866
Copy link
Contributor Author

maple525866 commented Oct 2, 2025

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.

@funky-eyes funky-eyes requested a review from Copilot October 10, 2025 02:28
Copy link

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 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.

@maple525866
Copy link
Contributor Author

@funky-eyes PTAL❤️ If you have any further questions please let me know

@YvCeung YvCeung added the DB: Oracle Relate to seata Oracle label Oct 16, 2025
@funky-eyes funky-eyes added mode: AT AT transaction mode module/rm-datasource rm-datasource module module/sqlparser sql-parser module multilingual labels Oct 17, 2025
@funky-eyes funky-eyes added this to the 2.6.0 milestone Oct 17, 2025
@funky-eyes funky-eyes requested a review from Copilot October 17, 2025 05:38
Copy link

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 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.

Comment on lines +242 to +248
// 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
Copy link

Copilot AI Oct 17, 2025

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'.

Copilot uses AI. Check for mistakes.
…/sqlparser/druid/oracle/OracleMultiInsertRecognizer.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.

LGTM

@YvCeung
Copy link
Contributor

YvCeung commented Oct 17, 2025

Well done. The code format verification failed due to other PR(#7643 ) and will be fixed later.

@YvCeung
Copy link
Contributor

YvCeung commented Oct 17, 2025

LGTM

@YvCeung YvCeung merged commit 9b97559 into apache:2.x Oct 17, 2025
14 of 16 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

DB: Oracle Relate to seata Oracle mode: AT AT transaction mode 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.

Oracle Batch Insert Not Support

4 participants