pingcap / tidb

TiDB - the open-source, cloud-native, distributed SQL database designed for modern applications.
https://pingcap.com
Apache License 2.0
37.42k stars 5.85k forks source link

Unexpected ExprType MysqlBit and EvalType Int #52664

Open aytrack opened 7 months ago

aytrack commented 7 months ago

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

drop table if exists UK_PRECISION19239;
CREATE TABLE `UK_PRECISION19239` (
  `COL1` bit(16) DEFAULT NULL COMMENT 'NUMERIC WITH PRECISION',
  `COL2` varchar(20) DEFAULT NULL,
  `COL4` datetime DEFAULT NULL,
  `COL3` bigint(20) DEFAULT NULL,
  `COL5` float DEFAULT NULL,
  UNIQUE KEY `UK_COL1` (`COL1`) /*!80000 INVISIBLE */
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

 insert into `UK_PRECISION19239` (`COL1`) values ( 0x0000);

select col1, col2 from UK_PRECISION19239 t1 where (select count(*) from UK_PRECISION19239 t2 where t2.col1 in (t1.col1, 30327)) > 1;

2. What did you expect to see? (Required)

[16:25:04]MySQL root:test> select col1, col2 from UK_PRECISION19239 t1 where (select count(*) from UK_PRECISION19239 t2 where t2.col1 in (t1.col1, 30327)) > 1;
+------+------+
| col1 | col2 |
+------+------+
+------+------+
0 rows in set

3. What did you see instead (Required)

[16:25:24]TiDB root:test>  select col1, col2 from UK_PRECISION19239 t1 where (select count(*) from UK_PRECISION19239 t2 where t2.col1 in (t1.col1, 30327)) > 1;
(1105, 'other error: [components/tidb_query_expr/src/impl_compare_in.rs:68]: Unexpected ExprType MysqlBit and EvalType Int')

4. What is your TiDB version? (Required)

v8.1.0

yibin87 commented 7 months ago

There is no explicit conversion from bit to int, so the expression bit < int will just be lt(bit, int), and this works in tikv. Thus it seems the tikv in function should support mixture of bit, int data types also.