924060929 opened a new pull request, #70783: URL: https://github.com/apache/doris/pull/70783
### What problem does this PR solve? Backport of #70706 (related: #43155) to `branch-4.2`. `SHOW CHARACTER SET` and `SHOW CHARSET` reject the optional `WHERE` and `LIKE` clauses used by MySQL clients. Both forms now filter the existing FE row with the character set name, description, default collation and maximum length. - `LIKE` decodes the SQL string literal in the current SQL mode before matching the character set name with the existing case-insensitive pattern matcher. - `WHERE` binds the output column names in Nereids and evaluates the predicate over a typed single-row relation. A scoped internal MySQL text query uses the caller's session settings and prepared bindings. The outer SHOW owns its query state and sends the resulting rows in the client's protocol. - SHOW's internal filter skips SQL result caching and the automatic SELECT limit. The predicate can still read the original session variables. ### Backport adaptation This branch does not have every master-only building block the original PR relied on: - `ConnectContext` still uses `MysqlChannel`: `createInternalQueryContext` builds a `DummyMysqlChannel` (master uses `MysqlProtocolAdapter`). - `StmtExecutor#setCancelDelegate` / `clearCancelDelegate` and the pending cancel reason exist only on master (#70607), so cancelling the client query is not propagated to the internal filter query on this branch, and the pre-check for a cancel that arrived before the filter starts is omitted too. - `ResultRow` is `org.apache.doris.statistics.ResultRow` on this branch, not `org.apache.doris.statistics.repository.ResultRow`. - `branch-4.2` cannot compute one-row-relation plans in the FE (`PhysicalOneRowRelation` does not implement `ComputeResultSet`), so an FE unit test has no backend that can execute the internal filter query. The unit tests that assert `WHERE` row results are `@Disabled` with an explanatory comment; the WHERE semantics are covered by the regression suites `test_show_charset_command` and `test_show_charset_over_arrow_flight` in a real cluster. - The `ConnectContextTest` case for `createInternalQueryContext` is adapted because `ConnectorSessionBuilder` is master-only; it asserts that the child context inherits the `SessionContext` and gets an independent copy of the session variables. ### Testing - Local FE build (`mvn package -pl fe-core -am`) and Checkstyle for `branch-4.2`. - FE unit tests `ShowCharsetCommandTest` and `ConnectContextTest` pass; the three WHERE tests that need a backend are disabled as described above. - Regression suites are the ones validated on master; CI should run them against this branch. ### Release note Support `WHERE` and `LIKE` filters in `SHOW CHARACTER SET` and `SHOW CHARSET`. -- 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]
