Bug #118849 | after add HINT:JOIN_ORDER, the result is wrong. | ||
---|---|---|---|
Submitted: | 18 Aug 12:14 | Modified: | 18 Aug 15:32 |
Reporter: | Alice Alice | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S3 (Non-critical) |
Version: | 8.0.41 | OS: | Any |
Assigned to: | CPU Architecture: | Any |
[18 Aug 12:14]
Alice Alice
[18 Aug 15:28]
MySQL Verification Team
Hi, Had to change it a bit: mysql> INSERT INTO `tbl_1_all_typeindex` VALUES -> (67, _binary 'fff2', 'ccc', '{"key1": 1}', _binary 'ª'), -> (69, _binary 'fff2', 'ccc', '{"key1": 1}', _binary '\0'), -> (85, NULL, NULL, NULL, _binary ''), -> (87, NULL, NULL, NULL, _binary 'ª'), -> (89, NULL, NULL, NULL, _binary '\0'), -> (91, NULL, NULL, NULL, _binary ''), -> (93, NULL, NULL, NULL, _binary ''), -> (95, NULL, NULL, NULL, _binary ''), -> (97, NULL, NULL, NULL, _binary 'ª'), -> (99, NULL, NULL, NULL, _binary '\0'), -> (101, NULL, NULL, NULL, _binary ''), -> (103, NULL, NULL, NULL, _binary ''), -> (105, NULL, NULL, NULL, _binary ''), -> (107, NULL, NULL, NULL, _binary 'ª'), -> (109, NULL, NULL, NULL, _binary '\0'), -> (111, NULL, NULL, NULL, _binary ''), -> (113, NULL, NULL, NULL, _binary ''); ERROR 1406 (22001): Data too long for column 'bit_col' at row 1 mysql> INSERT INTO `tbl_1_all_typeindex` VALUES -> (67, _binary 'fff2', 'ccc', '{"key1": 1}', _binary '\1'), -> (69, _binary 'fff2', 'ccc', '{"key1": 1}', _binary '\0'), -> (85, NULL, NULL, NULL, _binary '\1'), -> (87, NULL, NULL, NULL, _binary '\1'), -> (89, NULL, NULL, NULL, _binary '\0'), -> (91, NULL, NULL, NULL, _binary ''), -> (93, NULL, NULL, NULL, _binary ''), -> (95, NULL, NULL, NULL, _binary '\1'), -> (97, NULL, NULL, NULL, _binary '\1'), -> (99, NULL, NULL, NULL, _binary '\0'), -> (101, NULL, NULL, NULL, _binary ''), -> (103, NULL, NULL, NULL, _binary ''), -> (105, NULL, NULL, NULL, _binary '\1'), -> (107, NULL, NULL, NULL, _binary '\1'), -> (109, NULL, NULL, NULL, _binary '\0'), -> (111, NULL, NULL, NULL, _binary ''), -> (113, NULL, NULL, NULL, _binary ''); Query OK, 17 rows affected (0.001 sec) Records: 17 Duplicates: 0 Warnings: 0 mysql>
[18 Aug 15:29]
MySQL Verification Team
mysql> SELECT col1, col2, ifnull(col2,col3) as col3, col4, col3-col4 col5,if(strcmp(col1,col2),col1,col2) as col6,case when strcmp(col1,col3) then col1 else col3 end as col7 FROM tbl_1_all_typeindex b JOIN (SELECT blob_col col1,json_col col2,bit_col col3,SUM(enum_col) col4 FROM tbl_1_all_type2index GROUP BY 1,2,3 HAVING 0=1 or blob_col not in ('ffffffffff1')) a on 0=0 or (a.col2,a.col3) <= (select json_col,bit_col from tbl_1_all_typeindex order by 1,2 limit 1) where 0=0 and a.col3 = blob_col GROUP BY 1,2,3,4,5,6,7 HAVING 0=1 or col1 not in ('f') ORDER BY 1,2,3,4,5,6,7 limit 10 offset 1; +------------+-------------+--------------------------+------+------+------------+------------+ | col1 | col2 | col3 | col4 | col5 | col6 | col7 | +------------+-------------+--------------------------+------+------+------------+------------+ | 0x66666632 | {"key1": 1} | 0x7B226B657931223A20317D | 3 | -3 | 0x66666632 | 0x66666632 | +------------+-------------+--------------------------+------+------+------------+------------+ 1 row in set, 1 warning (0.006 sec) mysql> SELECT /*+ JOIN_ORDER(b,a) */ col1, col2, ifnull(col2,col3) as col3, col4, col3-col4 col5,if(strcmp(col1,col2),col1,col2) as col6,case when strcmp(col1,col3) then col1 else col3 end as col7 FROM tbl_1_all_typeindex b JOIN (SELECT blob_col col1,json_col col2,bit_col col3,SUM(enum_col) col4 FROM tbl_1_all_type2index GROUP BY 1,2,3 HAVING 0=1 or blob_col not in ('ffffffffff1')) a on 0=0 or (a.col2,a.col3) <= (select json_col,bit_col from tbl_1_all_typeindex order by 1,2 limit 1) where 0=0 and a.col3 = blob_col GROUP BY 1,2,3,4,5,6,7 HAVING 0=1 or col1 not in ('f') ORDER BY 1,2,3,4,5,6,7 limit 10 offset 1; Empty set (0.002 sec) mysql>
[18 Aug 15:32]
MySQL Verification Team
Hi, The result set content (returned rows/columns) should be the same, provided the hint does not cause the optimizer to produce a different execution plan that could change row ordering or tie-breaking for otherwise unordered results. But in your case, since you have an ORDER BY clause, the result order is deterministic. This is a verified bug, thank you for the report.