tidb
tidb copied to clipboard
executor: select agg from json column return wrong result with the MySQL
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
CREATE TABLE `tbl_3` (
`col_15` json DEFAULT NULL,
`col_16` json DEFAULT NULL,
`col_17` json DEFAULT NULL,
`col_18` json DEFAULT NULL,
`col_19` json DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
insert into tbl_3 values("[1,1,1]", "66", "false", "-22", "-44");
insert into tbl_3 values("77", "33", "323232323.3232323", "-22", NULL);
select /*+ agg_to_cop() stream_agg() */ max( col_17 ) aggCol from (select * from tbl_3 where not( tbl_3.col_16 between null and 'piHWbXSXTQVt' ) or tbl_3.col_17 not in ( "[3, 2, 1]" , "false" ) ) ordered_tbl limit 396 for update;
2. What did you expect to see? (Required)
MySQL8
+--------+
| aggCol |
+--------+
| false |
+--------+
1 row in set, 2 warnings (0.00 sec)
3. What did you see instead (Required)
TiDB
+-------------------+
| aggCol |
+-------------------+
| 323232323.3232323 |
+-------------------+
1 row in set, 1 warning (0.00 sec)
4. What is your TiDB version? (Required)
master
mysql> select /*+ agg_to_cop() stream_agg() */ max( col_17 ) aggCol from (select * from tbl_3 where not( tbl_3.col_16 between null and 'piHWbXSXTQVt' ) or tbl_3.col_17 not in ( "[3, 2, 1]" , "false" ) ) ordered_tbl limit 396 for update;
+-------------------+
| aggCol |
+-------------------+
| 323232323.3232323 |
+-------------------+
1 row in set, 3 warnings (0.00 sec)
mysql> select version();
+-----------+
| version() |
+-----------+
| 5.7.23 |
+-----------+
1 row in set (0.01 sec)
confirm it has been fixed