Skip to content

Commit

Permalink
Move executeUpdate to DriverExecutor
Browse files Browse the repository at this point in the history
  • Loading branch information
terrymanu committed May 30, 2024
1 parent 6ebcfaf commit 367b079
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -261,19 +261,19 @@ private List<ResultSet> getResultSets() throws SQLException {
* @param updateCallback update callback
* @param isNeedImplicitCommitTransaction is need implicit commit transaction
* @param statementReplayCallback statement replay callback
* @param executionContext execution context
* @return updated row count
* @throws SQLException SQL exception
*/
@SuppressWarnings("rawtypes")
public int executeAdvanceUpdate(final ShardingSphereMetaData metaData, final ShardingSphereDatabase database, final QueryContext queryContext,
final DriverExecutionPrepareEngine<JDBCExecutionUnit, Connection> prepareEngine, final TrafficExecutorCallback<Integer> trafficCallback,
final ExecuteUpdateCallback updateCallback, final boolean isNeedImplicitCommitTransaction,
final StatementReplayCallback statementReplayCallback) throws SQLException {
final StatementReplayCallback statementReplayCallback, final ExecutionContext executionContext) throws SQLException {
Optional<String> trafficInstanceId = connection.getTrafficInstanceId(metaData.getGlobalRuleMetaData().getSingleRule(TrafficRule.class), queryContext);
if (trafficInstanceId.isPresent()) {
return trafficExecutor.execute(connection.getProcessId(), database.getName(), trafficInstanceId.get(), queryContext, prepareEngine, trafficCallback);
}
ExecutionContext executionContext = createExecutionContext(metaData, database, queryContext);
return database.getRuleMetaData().getAttributes(RawExecutionRuleAttribute.class).isEmpty()
? executeUpdate(database, updateCallback, queryContext.getSqlStatementContext(), executionContext, prepareEngine, isNeedImplicitCommitTransaction, statementReplayCallback)
: accumulate(rawExecutor.execute(createRawExecutionGroupContext(metaData, database, executionContext), queryContext, new RawSQLExecutorCallback()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,12 +279,12 @@ public int executeUpdate() throws SQLException {
ExecutionContext executionContext = createExecutionContext(queryContext);
boolean isNeedImplicitCommitTransaction = isNeedImplicitCommitTransaction(connection, sqlStatementContext.getSqlStatement(), executionContext.getExecutionUnits().size() > 1);
final int result = executor.executeAdvanceUpdate(metaDataContexts.getMetaData(), database, queryContext, createDriverExecutionPrepareEngine(database),
(statement, sql) -> ((PreparedStatement) statement).executeUpdate(), null, isNeedImplicitCommitTransaction, (StatementReplayCallback<PreparedStatement>) this::replay);
(statement, sql) -> ((PreparedStatement) statement).executeUpdate(), null, isNeedImplicitCommitTransaction, (StatementReplayCallback<PreparedStatement>) this::replay,
executionContext);
for (Statement each : executor.getStatements()) {
statements.add((PreparedStatement) each);
}
parameterSets.addAll(executor.getParameterSets());
findGeneratedKey().ifPresent(optional -> generatedValues.addAll(optional.getGeneratedValues()));
return result;
// CHECKSTYLE:OFF
} catch (final RuntimeException ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ private int executeUpdate0(final String sql, final ExecuteUpdateCallback updateC
boolean isNeedImplicitCommitTransaction = isNeedImplicitCommitTransaction(connection, sqlStatementContext.getSqlStatement(), executionContext.getExecutionUnits().size() > 1);
int result = executor.executeAdvanceUpdate(
metaDataContexts.getMetaData(), database, queryContext, createDriverExecutionPrepareEngine(database), trafficCallback, updateCallback, isNeedImplicitCommitTransaction,
(StatementReplayCallback<Statement>) (statements, parameterSets) -> replay(statements));
(StatementReplayCallback<Statement>) (statements, parameterSets) -> replay(statements), executionContext);
statements.addAll(executor.getStatements());
replay(statements);
return result;
Expand Down

0 comments on commit 367b079

Please sign in to comment.