JacobZheng0927 opened a new pull request, #13035:
URL: https://github.com/apache/seatunnel/pull/13035

   ### Purpose of this pull request
   
   I am glad to contribute this fix to Apache SeaTunnel.
   
   Closes #13033.
   
   `BufferReducedBatchStatementExecutor.prepareStatements` eagerly prepares 
DELETE even when a keyed sink only inserts/updates. Databases that check 
privileges during preparation reject such writers without DELETE permission. A 
buffered DELETE that is later overwritten by an INSERT can cause the same 
unnecessary requirement.
   
   Prepare the DELETE executor only when the first retained DELETE reaches 
`executeBatch`, once per connection. Reset that state when preparing a 
replacement connection, and only clear/close the DELETE delegate when it was 
prepared for that connection. The cleanup guards also prevent accessing a stale 
closed statement after reconnect.
   
   The existing reduction, row-kind handling, key behavior, and execution order 
are unchanged. Initialization uses the existing execution loop, adds no buffer 
scan or database query, and removes one prepared statement from upsert-only 
connections.
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. Upsert-only keyed writers no longer require unused DELETE privileges. 
An actual retained DELETE still requires permission and propagates preparation 
errors. No options, defaults, or public APIs change. English and Chinese JDBC 
sink documentation is updated.
   
   ### How was this patch tested?
   
   - New executor regression cases fail against the original `dev` 
implementation, then pass with the fix.
   - Scoped Maven `verify` passes: 36 JDBC executor/output-format unit tests 
plus the native MySQL integration test below.
   - 
`JdbcMysqlIT#testUpsertWriterDoesNotRequireDeletePrivilegeUntilAnEffectiveDelete`
 passes on MySQL 8.0.43 with server-side preparation and client emulation 
disabled. It verifies that a user with SELECT/INSERT/UPDATE but no DELETE 
cannot directly prepare DELETE, can complete inserts/updates and a reduced-away 
DELETE through the real sink writer, and still fails for an effective DELETE 
without changing target rows.
   - Unit tests cover first/repeated DELETE, preparation retry, new 
connections, mixed execution order, and a real `SimpleBatchStatementExecutor` 
retaining an old closed statement across reconnect.
   - `spotless:apply` and `git diff --check` pass. Based on current `dev` 
(`cec3276740d9`); open and closed PR searches found no same-purpose change. 
#12769 also touches executor cleanup for transaction-conflict handling, but 
addresses a separate problem.
   
   ### Check list
   
   * [x] Updated English and Chinese connector documentation.
   * [x] Extended existing unit and JDBC integration tests.
   * [x] No new dependencies, configuration options, or incompatible changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to