github-actions[bot] commented on code in PR #70782:
URL: https://github.com/apache/doris/pull/70782#discussion_r4638375481
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowCharsetCommand.java:
##########
@@ -65,6 +96,38 @@ public ShowResultSet doRun(ConnectContext ctx, StmtExecutor
executor) throws Exc
return new ShowResultSet(getMetaData(), rows);
}
+ private List<List<String>> filterRows(ConnectContext ctx, StmtExecutor
executor) throws UserException {
+ try (AutoCloseConnectContext scope = new
AutoCloseConnectContext(ctx.createInternalQueryContext());
+ StatementContext statementContext = ctx.getStatementContext()
+ .createShowQueryContext(scope.connectContext)) {
+ ConnectContext internalContext = scope.connectContext;
+ internalContext.setStatementContext(statementContext);
+
+ List<NamedExpression> projects = ImmutableList.of(
+ new Alias(new
StringLiteral(ctx.getSessionVariable().getCharsetServer()), "Charset"),
+ new Alias(new StringLiteral("UTF-8 Unicode"),
"Description"),
+ new Alias(new
StringLiteral(ctx.getSessionVariable().getCollationConnection()),
+ "Default collation"),
+ new Alias(new IntegerLiteral(4), "Maxlen"));
+ LogicalOneRowRelation relation = new LogicalOneRowRelation(
+ StatementScopeIdGenerator.newRelationId(), projects);
+ LogicalFilter<LogicalOneRowRelation> filter = new LogicalFilter<>(
+ ExpressionUtils.extractConjunctionToSet(whereClause),
relation);
+ LogicalPlanAdapter adapter = new LogicalPlanAdapter(new
UnboundResultSink<>(filter), statementContext);
+ adapter.setOrigStmt(executor.getOriginStmt());
+ StmtExecutor internalExecutor = new StmtExecutor(internalContext,
adapter);
+ internalContext.setExecutor(internalExecutor);
+ // Check for cancellation that arrived before the filter started.
+ Status cancelReason = executor.getPendingCancelReason();
+ if (cancelReason != null) {
+ throw new UserException(cancelReason.getErrorMsg());
+ }
+ return internalExecutor.executeInternalQuery().stream()
Review Comment:
[P1] Propagate cancellation to the internal filter query. After the one-time
check at lines 120-124, `executeInternalQuery()` runs a separate coordinator
stored only on `internalExecutor`; `ConnectContext` timeout/KILL calls
`executor.cancel()` on the outer SHOW executor, whose `coord` is still null and
cannot cancel the inner one. A cancellation racing with planning or BE
execution therefore leaves the query running and can still return a result.
Link the inner executor to the outer cancellation lifecycle, including cleanup,
or avoid an unowned nested coordinator.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java:
##########
@@ -538,6 +538,38 @@ public ConnectContext cloneContext() {
return context;
}
+ /**
+ * Isolate a read-only internal query from the client protocol and
statement state while
+ * retaining the caller's session identity, name resolution and variable
values.
+ * The caller still owns the session and its cleanup.
+ */
+ public ConnectContext createInternalQueryContext() {
+ return new ConnectContext(this);
+ }
+
+ private ConnectContext(ConnectContext parent) {
+ connectType = ConnectType.MYSQL;
+ mysqlChannel = new DummyMysqlChannel();
+ command = MysqlCommand.COM_QUERY;
+ state = new QueryState();
+ sessionVariable =
VariableMgr.cloneSessionVariable(parent.sessionVariable);
+ userVars.putAll(parent.userVars);
+ env = parent.env;
Review Comment:
[P2] Preserve the caller's catalog and database in the internal filter
context. `createInternalQueryContext()` leaves `defaultCatalog`, `currentDb`,
and `currentDbId` at the new context's defaults, while Nereids folds
`DATABASE()` and `CURRENT_CATALOG()` from those fields. For example, after `USE
db1`, `SHOW CHARSET WHERE DATABASE() = 'db1'` is evaluated with an empty
database and incorrectly returns no row. Copy the name-resolution state and add
regression coverage for these predicates.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]