diff --git a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java index b6f2f39a794af..0b464cd1da704 100644 --- a/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java +++ b/jdbc/src/main/java/org/apache/shardingsphere/driver/executor/DriverExecutor.java @@ -261,6 +261,7 @@ private List 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 */ @@ -268,12 +269,11 @@ private List getResultSets() throws SQLException { public int executeAdvanceUpdate(final ShardingSphereMetaData metaData, final ShardingSphereDatabase database, final QueryContext queryContext, final DriverExecutionPrepareEngine prepareEngine, final TrafficExecutorCallback trafficCallback, final ExecuteUpdateCallback updateCallback, final boolean isNeedImplicitCommitTransaction, - final StatementReplayCallback statementReplayCallback) throws SQLException { + final StatementReplayCallback statementReplayCallback, final ExecutionContext executionContext) throws SQLException { Optional 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())); diff --git a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java index 67f5ab7e98deb..f185ba74bc9c1 100644 --- a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java +++ b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSpherePreparedStatement.java @@ -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) this::replay); + (statement, sql) -> ((PreparedStatement) statement).executeUpdate(), null, isNeedImplicitCommitTransaction, (StatementReplayCallback) 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) { diff --git a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java index 7ab7a2792bb2b..3486275a6efad 100644 --- a/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java +++ b/jdbc/src/main/java/org/apache/shardingsphere/driver/jdbc/core/statement/ShardingSphereStatement.java @@ -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) (statements, parameterSets) -> replay(statements)); + (StatementReplayCallback) (statements, parameterSets) -> replay(statements), executionContext); statements.addAll(executor.getStatements()); replay(statements); return result;