Bug #118949 | MySQL 9.2.0: Complex CASE in JOIN makes INNER vs INTERSECT yield different rows | ||
---|---|---|---|
Submitted: | 5 Sep 13:57 | Modified: | 8 Sep 6:49 |
Reporter: | 策 吕 | Email Updates: | |
Status: | Verified | Impact on me: | |
Category: | MySQL Server: Optimizer | Severity: | S2 (Serious) |
Version: | 9.2.0 | OS: | Linux (ubuntu 20.04) |
Assigned to: | CPU Architecture: | Any |
[5 Sep 13:57]
策 吕
[5 Sep 19:45]
Filipe Silva
Hi 策 吕, Thank you for the report. Could you please provide clearer, more descriptive and accurate bug title (synopsis) in the bugs you report? Thank you—we appreciate your help improving the quality of our reports.
[6 Sep 12:20]
策 吕
Hi developers, Title now shortened to: MySQL 9.2.0: Complex CASE in JOIN makes INNER vs INTERSECT yield different rows Here are my findings in more detail: First of all I found this result on MySQL version 9.2.0 when using the test sample above: mysql> SELECT DISTINCT t70.c0 FROM t70 INNER JOIN t0 ON (CASE t0.c0 WHEN (((BINARY (false)))NOT LIKE(RADIANS(979536240))) THEN BIN(((((t70.c0)|(t70.c0)))<=(''))) WHEN CAST('(S/]Cf\nI|' AS DATE) THEN t0.c0 ELSE ((((-1.93103105E8)<(t70.c0)))<(BIN(t70.c0))) END ); +----+ | c0 | +----+ | 0 | +----+ mysql> (SELECT DISTINCT t70.c0 FROM t70 LEFT JOIN t0 ON (CASE t0.c0 WHEN (((BINARY (false)))NOT LIKE(RADIANS(979536240))) THEN BIN(((((t70.c0)|(t70.c0)))<=(''))) WHEN CAST('(S/]Cf\nI|' AS DATE) THEN t0.c0 ELSE ((((-1.93103105E8)<(t70.c0)))<(BIN(t70.c0))) END )) INTERSECT (SELECT DISTINCT t70.c0 FROM t70 RIGHT JOIN t0 ON (CASE t0.c0 WHEN (((BINARY (false)))NOT LIKE(RADIANS(979536240))) THEN BIN(((((t70.c0)|(t70.c0)))<=(''))) WHEN CAST('(S/]Cf\nI|' AS DATE) THEN t0.c0 ELSE ((((-1.93103105E8)<(t70.c0)))<(BIN(t70.c0))) END )); +----+ | c0 | +----+ | 0 | | 1 | +----+ Obviously, in my design, the results returned by the first query should be consistent with the results returned by the second query, with this in mind I ran the same test sample on MariaDB again, and found that MariaDB returned consistent results, ie: mariadb> SELECT DISTINCT t70.c0 FROM t70 INNER JOIN t0 ON (CASE t0.c0 WHEN (((BINARY (false)))NOT LIKE(RADIANS(979536240))) THEN BIN(((((t70.c0)|(t70.c0)))<=(''))) WHEN CAST('(S/]Cf\nI|' AS DATE) THEN t0.c0 ELSE ((((-1.93103105E8)<(t70.c0)))<(BIN(t70.c0))) END ); +----+ | c0 | +----+ | 0 | +----+ mariadb> (SELECT DISTINCT t70.c0 FROM t70 LEFT JOIN t0 ON (CASE t0.c0 WHEN (((BINARY (false)))NOT LIKE(RADIANS(979536240))) THEN BIN(((((t70.c0)|(t70.c0)))<=(''))) WHEN CAST('(S/]Cf\nI|' AS DATE) THEN t0.c0 ELSE ((((-1.93103105E8)<(t70.c0)))<(BIN(t70.c0))) END )) INTERSECT (SELECT DISTINCT t70.c0 FROM t70 RIGHT JOIN t0 ON (CASE t0.c0 WHEN (((BINARY (false)))NOT LIKE(RADIANS(979536240))) THEN BIN(((((t70.c0)|(t70.c0)))<=(''))) WHEN CAST('(S/]Cf\nI|' AS DATE) THEN t0.c0 ELSE ((((-1.93103105E8)<(t70.c0)))<(BIN(t70.c0))) END )); +----+ | c0 | +----+ | 0 | +----+ What's more,I tested it on MySQL version 8.0.36 (windows) and found that it is also all 0, which is consistent with the performance of MariaDB's results, and I also tested it on the latest version of TiDB and also found that the final results are all 0.
[8 Sep 6:49]
MySQL Verification Team
Thanks for the report. Verified as described.