github-actions[bot] commented on code in PR #70706:
URL: https://github.com/apache/doris/pull/70706#discussion_r4610419602
##########
fe/fe-core/src/main/java/org/apache/doris/nereids/trees/plans/commands/ShowCharsetCommand.java:
##########
@@ -65,6 +94,36 @@ public ShowResultSet doRun(ConnectContext ctx, StmtExecutor
executor) throws Exc
return new ShowResultSet(getMetaData(), rows);
}
+ private List<List<String>> filterRows(ConnectContext ctx, StmtExecutor
executor) {
+ 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);
+ executor.setCancelDelegate(internalExecutor::cancel);
Review Comment:
[P2] Forward pending cancellation when attaching the internal executor
If `KILL QUERY` reaches the outer executor before this call (for example
while cloning the session/context), `StmtExecutor.cancel` stores the reason but
finds no delegate. `setCancelDelegate` only assigns the consumer, so the
freshly created child never receives that cancellation and can still run `SHOW
CHARSET WHERE sleep(30) = 0` even though KILL succeeded. The child's later
`setCoord` only consults its own pending reason. Register the child with a
handoff that also replays prior cancellation, and cover
cancel-before-registration ordering.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java:
##########
@@ -462,6 +462,38 @@ public ConnectContext(ProtocolAdapter protocolAdapter) {
init();
}
+ /**
+ * 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) {
+ protocolAdapter = new MysqlProtocolAdapter(new DummyMysqlChannel());
+ command = MysqlCommand.COM_QUERY;
+ state = new QueryState();
+ sessionVariable =
VariableMgr.cloneSessionVariable(parent.sessionVariable);
+ userVars.putAll(parent.userVars);
+ env = parent.env;
+ currentUserIdentity = parent.currentUserIdentity;
+ authenticatedPrincipal = parent.authenticatedPrincipal;
+ authenticatedRoles = parent.authenticatedRoles;
Review Comment:
[P2] Preserve the delegated session in the copied context
This copies the user's identity but leaves `sessionContext` at
`SessionContext.empty()`. For a logged-in user with a delegated credential and
an Iceberg REST catalog using `iceberg.rest.session=user`, `SHOW CHARSET WHERE
EXISTS (SELECT 1 FROM rest_catalog.db.t)` analyzes the subquery under this
child context. `ConnectorSessionBuilder` reads the empty session, so
`IcebergSessionCatalogAdapter` throws "Iceberg REST user session requires a
delegated credential", even though the same SELECT works on the caller. Carry
the parent's immutable `SessionContext` into the child and cover this context
inheritance.
--
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]