Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error triggered by using keywords such as BIT_LENGTH and right join simultaneously #58960

Open
DBMSTesting opened this issue Jan 15, 2025 · 0 comments
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@DBMSTesting
Copy link

Bug Report

Please answer these questions before submitting your issue. Thanks!

1. Minimal reproduce step (Required)

DROP DATABASE IF EXISTS database4;
CREATE DATABASE database4;
USE database4;
CREATE TABLE t0(c0 DOUBLE ZEROFILL DEFAULT 0.9671166932890627 , c1 CHAR UNIQUE , c2 DECIMAL NOT NULL DEFAULT 336708112 );
CREATE TABLE t1 LIKE t0;
REPLACE INTO t1(c0) VALUES (0.2917483374572829);
INSERT IGNORE INTO t0(c0, c1) VALUES (0.3922811678207798, '菗');
INSERT IGNORE INTO t1(c1, c2, c0) VALUES ('0', 1149258896, 0.055846946503167905) ON DUPLICATE KEY UPDATE c1=((t1.c2)<<('n''));
ANALYZE TABLE t1 WITH 16 BUCKETS;
DELETE FROM t0 WHERE 182905816 LIMIT 1090979072;
INSERT IGNORE INTO t0 VALUES (0.47794277723704015, '3', -837245225), (0.715732957748164, 'F', -1201898917), (0.20812037930326055, 'W', 163062002);
REPLACE LOW_PRIORITY INTO t1 VALUES (3.80907552E8, 'R', -1056769981);
ALTER TABLE t0 CHANGE c0 c0 DOUBLE NOT NULL ;
INSERT INTO t0 VALUES (0.5329751255880734, '&', -1619256348) ON DUPLICATE KEY UPDATE c0=0.1063791671534069;
INSERT INTO t1 VALUES (0.19209470740168522, '', -1541407392), (-0.0, 'd', 1587434259) ON DUPLICATE KEY UPDATE c0=ATAN2((CASE ((t1.c1)NOT REGEXP(((0.673351449902867)REGEXP(t1.c1)))) WHEN (BINARY (((8.56038558E8)<=>(t1.c1)))) THEN true WHEN ( (t1.c1)) THEN t1.c2 ELSE ((((t1.c2)<=(t1.c0))) IS NOT NULL) END ), t1.c2);
ALTER TABLE t0 MODIFY c2 SMALLINT;
ALTER TABLE t0 ADD PRIMARY KEY(c0, c1);
set @@tidb_enable_chunk_rpc=0;
ALTER TABLE t1 DROP c1;
ALTER TABLE t1 ADD PRIMARY KEY(c0);
REPLACE INTO t0 VALUES (0.333763883471196, '3', 2076403267);
INSERT DELAYED INTO t0(c2, c1, c0) VALUES (-683166215, '7', 0.033942758774140214);
INSERT IGNORE INTO t0 VALUES (0.9876478871043636, NULL, NULL);
INSERT IGNORE INTO t0 VALUES (0.3275791546134018, '_', -1914452096) ON DUPLICATE KEY UPDATE c1=(NOT (t0.c2));
ALTER TABLE t1 DROP PRIMARY KEY;
REPLACE INTO t0(c1, c0) VALUES ('0', 0.3394096408015381);
INSERT IGNORE INTO t0 VALUES (0.9552583389527022, ']', 336708112), (0.14605162981619868, '柳', -140220699), (0.7586708441829492, '6', -1797145425) ON DUPLICATE KEY UPDATE c2=true;
REPLACE INTO t1(c2, c0) VALUES (1203072832, 0.3503707542482578);
INSERT IGNORE INTO t0 VALUES (0.29600779971169733, NULL, -931807992) ON DUPLICATE KEY UPDATE c0=(('-1140735954')<<(t0.c1));
set @@tidb_opt_insubq_to_join_and_agg=1;
ALTER TABLE t1 ADD PRIMARY KEY(c0);
REPLACE INTO t1 VALUES (2.038924276E9, 1852381299);
set @@tidb_wait_split_region_finish=1;
ALTER TABLE t0 ORDER BY c1;
UPDATE t0 SET c1=t0.c1, c0=1565273390, c2=1949985978;
INSERT DELAYED INTO t1(c2, c0) VALUES (-1506961830, 7.76659336E8) ON DUPLICATE KEY UPDATE c2=(((CASE DATABASE() WHEN t1.c2 THEN ((336708112)<=>('-')) ELSE DEFAULT(t1.c2) END ))|(208105474));

mysql> SELECT * FROM t0 RIGHT OUTER JOIN t1 ON false;
+------+------+------+--------------------------+-------------+
| c0 | c1 | c2 | c0 | c2 |
+------+------+------+--------------------------+-------------+
| NULL | NULL | NULL | 0.2917483374572829 | 336708112 |
| NULL | NULL | NULL | 0.055846946503167905 | 1149258896 |
| NULL | NULL | NULL | 380907552 | -1056769981 |
| NULL | NULL | NULL | 0.19209470740168522 | -1541407392 |
| NULL | NULL | NULL | 0 | 1587434259 |
| NULL | NULL | NULL | 0.3503707542482578 | 1203072832 |
| NULL | NULL | NULL | 2038924276 | 1852381299 |
| NULL | NULL | NULL | 776659336 | -1506961830 |
+------+------+------+---------------------------+-------------+
8 rows in set (0.01 sec)

mysql> SELECT * FROM t0 RIGHT JOIN t1 ON false WHERE ((-2142110775)AND(BIT_LENGTH(IF(((t0.c0)>=(CAST(434887707 AS SIGNED))), 1292809526, ((t1.c0)AND(NULL)))))) UNION ALL SELECT * FROM t0 RIGHT OUTER JOIN t1 ON false WHERE (NOT (((-2142110775)AND(BIT_LENGTH(IF(((t0.c0)>=(CAST(434887707 AS SIGNED))), 1292809526, ((t1.c0)AND(NULL)))))))) UNION ALL SELECT * FROM t0 RIGHT JOIN t1 ON false WHERE ((((-2142110775)AND(BIT_LENGTH(IF(((t0.c0)>=(CAST(434887707 AS SIGNED))), 1292809526, ((t1.c0)AND(NULL))))))) IS NULL);
+------+------+------+--------------------------+-------------+
| c0 | c1 | c2 | c0 | c2 |
+------+------+------+--------------------------+-------------+
| NULL | NULL | NULL | 0.2917483374572829 | 336708112 |
| NULL | NULL | NULL | 0.055846946503167905 | 1149258896 |
| NULL | NULL | NULL | 380907552 | -1056769981 |
| NULL | NULL | NULL | 0.19209470740168522 | -1541407392 |
| NULL | NULL | NULL | 0.3503707542482578 | 1203072832 |
| NULL | NULL | NULL | 2038924276 | 1852381299 |
| NULL | NULL | NULL | 776659336 | -1506961830 |
+------+------+------+---------------------------+-------------+
7 rows in set (0.00 sec)

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

I think these two query results should be the same. The first query does not have a where condition, and the second query returns union all results for true, false, and unknown under the same condition. According to the three value logic, these two results should be the same, but in fact, they return different amounts of data

3. What did you see instead (Required)

These two results should be the same.

4. What is your TiDB version? (Required)

Release Version: v7.5.1
Edition: Community
Git Commit Hash: 7d16cc7
Git Branch: heads/refs/tags/v7.5.1
UTC Build Time: 2024-02-27 14:28:32
GoVersion: go1.21.6
Race Enabled: false
Check Table Before Drop: false
Store: unistore

@DBMSTesting DBMSTesting added the type/bug The issue is confirmed as a bug. label Jan 15, 2025
@jebter jebter added the sig/planner SIG: Planner label Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

2 participants