Skip to content

Commit

Permalink
Pass connection context to EnumerableScanExecutor to avoid kernel che…
Browse files Browse the repository at this point in the history
…ck exception
  • Loading branch information
strongduanmu committed Dec 7, 2024
1 parent bc2c1e6 commit 87b0f9a
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereStatistics;
import org.apache.shardingsphere.infra.metadata.statistics.ShardingSphereTableData;
import org.apache.shardingsphere.infra.parser.sql.SQLStatementParserEngine;
import org.apache.shardingsphere.infra.session.connection.ConnectionContext;
import org.apache.shardingsphere.infra.session.query.QueryContext;
import org.apache.shardingsphere.sql.parser.statement.core.statement.SQLStatement;
import org.apache.shardingsphere.sqlfederation.executor.constant.EnumerableConstants;
Expand Down Expand Up @@ -135,7 +134,7 @@ public Enumerator<Object> enumerator() {
ShardingSpherePreconditions.checkState(!ProcessRegistry.getInstance().get(federationContext.getProcessId()).isInterrupted(), SQLExecutionInterruptedException::new);
processEngine.executeSQL(executionGroupContext, federationContext.getQueryContext());
List<QueryResult> queryResults = jdbcExecutor.execute(executionGroupContext, callback).stream().map(QueryResult.class::cast).collect(Collectors.toList());
MergeEngine mergeEngine = new MergeEngine(federationContext.getMetaData(), database, executorContext.getProps(), new ConnectionContext(Collections::emptySet));
MergeEngine mergeEngine = new MergeEngine(federationContext.getMetaData(), database, executorContext.getProps(), federationContext.getQueryContext().getConnectionContext());
MergedResult mergedResult = mergeEngine.merge(queryResults, queryContext.getSqlStatementContext());
Collection<Statement> statements = getStatements(executionGroupContext.getInputGroups());
return new JDBCRowEnumerator(mergedResult, queryResults.get(0).getMetaData(), statements);
Expand Down Expand Up @@ -208,7 +207,7 @@ private QueryContext createQueryContext(final ShardingSphereMetaData metaData, f
List<Object> params = getParameters(sqlString.getParamIndexes());
HintValueContext hintValueContext = new HintValueContext();
SQLStatementContext sqlStatementContext = new SQLBindEngine(metaData, executorContext.getDatabaseName(), hintValueContext).bind(sqlStatement, params);
return new QueryContext(sqlStatementContext, sql, params, hintValueContext, new ConnectionContext(Collections::emptySet), metaData, useCache);
return new QueryContext(sqlStatementContext, sql, params, hintValueContext, federationContext.getQueryContext().getConnectionContext(), metaData, useCache);
}

private List<Object> getParameters(final int[] paramIndexes) {
Expand Down

0 comments on commit 87b0f9a

Please sign in to comment.