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 columns fail in AND/OR/XOR/NOT with 'bad value [BIT BOOL]' #31180
A BIT column used as an operand of the logical operators AND / OR / XOR / NOT (and && / || / !) fails at plan time:
ERROR 20203 (HY000): invalid argument operator and, bad value [BIT BOOL]
ERROR 20203 (HY000): invalid argument operator not, bad value [BIT]
MySQL treats BIT as a number in a boolean context (non-zero = TRUE, 0 = FALSE, NULL = NULL). MatrixOne already does this for WHERE b and IF(b,1,0), and an explicit CAST(b AS BOOL) works. Only the logical operators reject it, because their type check asks whether BIT can be implicitly cast to BOOL, and the T_bit row of implicitCastSupported (pkg/sql/plan/function/type_check.go) lists only INT64/UINT64.
Reported by QA as a follow-up on #30922 (comment); #30922 / PR #30923 only cover DECIMAL. This is the BIT column case; the b'1' AND 1 bit-value literal case goes through a different path and is tracked in #30930 / #30931.
How to reproduce
createtabletb(id intprimary key, b bit(1), w bit(8));
insert into tb values (1,0,0),(2,1,1),(3,1,128),(4,null,null);
select id, b and1, b or0, not b, b xor 1from tb order by id;
select id, w and1, w or0, not w, w xor 0from tb order by id;
select id from tb where not w order by id;
QA handoff for merged #31682 (2fa5b0c945499475e1f2e7c3035a6169f9aa4ce8): this isolated QA run inspected the source and issue history but did not run current-head functional tests or live SQL because the existing resource guard left insufficient headroom. Please verify BIT logical operators, NULL, high bits and conditional result type controls. Author-reported PR tests are separate evidence and are not results of this QA run.
Activity
gouhongshen commentedon Oct 29, 2026
PR #31682 is trying to fix this issue.
sql/plan: support BIT columns in AND/OR/XOR/NOT (#31682)
gouhongshen commentedon Oct 29, 2026
PR #31682 has merged and is awaiting manual validation. The issue remains open.
XuPeng-SH commentedon Oct 29, 2026
QA handoff for merged #31682 (
2fa5b0c945499475e1f2e7c3035a6169f9aa4ce8): this isolated QA run inspected the source and issue history but did not run current-head functional tests or live SQL because the existing resource guard left insufficient headroom. Please verify BIT logical operators, NULL, high bits and conditional result type controls. Author-reported PR tests are separate evidence and are not results of this QA run.Ariznawlll commentedon Oct 30, 2026
结论
测试通过。BIT 列可参与逻辑运算,非零、零与 NULL 的结果符合预期。
关键证据
main@415068ce4d3a9188a8ba82c24742de0f1b1765c0,修复 PR sql/plan: support BIT columns in AND/OR/XOR/NOT #31682 合并提交2fa5b0c945499475e1f2e7c3035a6169f9aa4ce8位于该版本祖先链。实际二进制构建信息与完整 SHA 一致;本地隔离 1 CN / 1 TN / 1 LogService,Python 3.12、PyMySQL 1.2.3。WHERE NOT w仅返回 id=1;另验证&&、||、!、WHERE 和 IF 的结果与逻辑表达式整型协议元数据。待解决点