Issue
In TencentDB for MySQL, when processing a Window Function query that uses a CASE expression in the ORDER BY clause, and when different branches of the CASE expression return fields with different collations, collation aggregation failure triggers a null pointer dereference, causing the database instance to Crash.
Issue Triggering Scenarios
Typical Triggering Conditions
1. Using window functions: The query contains window functions such as ROW_NUMBER(), RANK(), and DENSE_RANK().
2. ORDER BY contains a CASE expression: The ORDER BY clause of the window function uses a CASE WHEN...END expression.
3. Collation conflict: Different branches of the CASE expression return string-type fields with different collations.
Minimum Reproducible SQL
CREATE TABLE t1 (
id INT PRIMARY KEY,
col_ci VARCHAR(100) COLLATE utf8mb4_general_ci,
col_cs VARCHAR(100) COLLATE utf8mb4_unicode_ci
);
SELECT id, ROW_NUMBER() OVER (
ORDER BY CASE WHEN id = 1 THEN col_ci ELSE col_cs END
) AS rn FROM t1;
Affected Kernel Versions
Versions of MySQL 8.0 prior to 20260430.
Fixed Kernel Versions
MySQL 8.0 version 20260430 and later.
Fix
Upgrade to the fixed version.