You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: BIT not-equal comparisons panic in the string comparison executor #33136
The <> and != operators on BIT values panic inside the comparison executor. Other BIT comparison operators work on the same data.
Environment
Branch: main
Commit: 07d7baa32a35c2ebf7c5f5a1ef806f1d9815701b
Local mo-service, MySQL protocol
Reproduction
CREATETABLEt (b BIT(8));
INSERT INTO t VALUES (39);
SELECT b = b FROM t; -- returns 1SELECT b <> b FROM t; -- should return 0, but errorsSELECT b != b FROM t; -- same failure
Actual result:
ERROR 20101 (HY000): internal error: panic unsafe slice cast:
from length 8 is not enough for length 24
The same failure reproduces with:
BIT(1), BIT(8), BIT(16), and BIT(64);
column-to-column and column-to-constant comparisons;
comparisons in JOIN / WHERE as well as the select list.
As controls, =, <=>, <, <=, >, >=, IN, and NOT IN completed normally.
Expected behavior
Both b <> b and b != b should return false (0) without an internal error.
Root cause
BIT is represented as fixed-width uint64. Most comparison operators in pkg/sql/plan/function/func_compare.go use opBinaryFixedFixedToFixed[uint64], but notEqualFn handles types.T_bit with opBinaryStrStrToFixed[bool]. The string wrapper then interprets the fixed-width storage as byte slices and panics.
Duplicate check
Searched open and closed issues for BIT not-equal, unsafe slice cast, notEqualFn, and opBinaryStrStrToFixed; no matching report was found.
Activity
fix(sql): use fixed-width comparison for BIT inequality (#33146)
XuPeng-SH commentedon Nov 25, 2026
转 QA:#33146 已合入
main,merge SHAba768818c9f61be24338e223587baeb7c47a3a85。<> / !=共用现有的定长 uint64 比较,不再走字符串向量;同步移除主键分组消除的旧规避分支。Ariznawlll commentedon Nov 25, 2026
已在
main修复 mergeba768818c9f61be24338e223587baeb7c47a3a85上独立复测通过,关闭本 Issue。验证环境:从上述确切 SHA 的源码归档本地构建,单 CN 隔离实例,
git_version()返回ba76881,通过 MySQL 协议执行。b = b返回1,b <> b与b != b均返回0,不再出现 internal error / panic。NULL。WHERE、JOIN 投影及 JOIN 条件中分别核对<>、!=和=;混合 BIT(8)/BIT(64)、BIT(64) 高位值9223372036854775808/18446744073709551615、选择掩码及 NULL 过滤均与独立预期逐行一致。LIMIT 1两种不等写法均返回(3,1);EXPLAIN为Project -> Table Scan,过滤及 Limit 下推且无 Aggregate,确认走到了分组消除路径。Test_NotEqualFn、TestPrimaryKeyGroupEliminationRequiresTotalResolvedComparisons均以-count=3通过。panic:/FATAL。结论仅覆盖
main上述修复版本,不代表4.2-dev或生产环境已经包含该修复。Ariznawlll commentedon Nov 25, 2026
验收通过,按上述复测结果关闭。