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

Incorrect Results by REGEXP #38303

Closed
bajinsheng opened this issue Oct 6, 2022 · 1 comment
Closed

Incorrect Results by REGEXP #38303

bajinsheng opened this issue Oct 6, 2022 · 1 comment
Assignees
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 may-affects-4.0 This bug maybe affects 4.0.x versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.

Comments

@bajinsheng
Copy link

Bug Report

Inconsistent results by REGEXP.

1. Minimal reproduce step (Required)

CREATE TABLE t0(c0 INT);
INSERT INTO t0(c0) VALUES (0.01);
CREATE VIEW v0(c0) AS SELECT t0.c0 FROM t0;

SELECT * FROM t0 RIGHT JOIN v0 ON DEFAULT(t0.c0); -- (NULL|0}
SELECT (v0.c0)REGEXP(v0.c0 AND t0.c0) FROM t0 RIGHT JOIN v0 ON DEFAULT(t0.c0); -- {1}
SELECT * FROM t0 RIGHT JOIN v0 ON DEFAULT(t0.c0) WHERE (v0.c0)REGEXP(v0.c0 AND t0.c0); -- Empty set

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

The first SELECT returns non-empty results and the predicate (v0.c0)REGEXP(v0.c0 AND t0.c0) is evaluated TRUE in the second SELECT, but the third SELECT returns nothing.

3. What did you see instead (Required)

4. What is your TiDB version? (Required)

| Release Version: v6.4.0-alpha-12-g51a6684fb
Edition: Community
Git Commit Hash: 51a6684fb767cfd86a8312e0e6447963b927c791
Git Branch: master
UTC Build Time: 2022-10-05 12:40:23
GoVersion: go1.19.1
Race Enabled: false
TiKV Min Version: 6.2.0-alpha
Check Table Before Drop: false
Store: unistore |
@bajinsheng bajinsheng added the type/bug The issue is confirmed as a bug. label Oct 6, 2022
@ti-chi-bot ti-chi-bot added may-affects-4.0 This bug maybe affects 4.0.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.0 may-affects-6.1 may-affects-6.2 may-affects-6.3 labels Oct 8, 2022
@ChenPeng2013 ChenPeng2013 added affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 labels Oct 11, 2022
@ti-chi-bot ti-chi-bot removed may-affects-5.2 This bug maybe affects 5.2.x versions. may-affects-5.0 This bug maybe affects 5.0.x versions. may-affects-5.1 This bug maybe affects 5.1.x versions. may-affects-5.3 This bug maybe affects 5.3.x versions. may-affects-6.0 may-affects-5.4 This bug maybe affects 5.4.x versions. may-affects-6.2 labels Oct 11, 2022
@Yisaer
Copy link
Contributor

Yisaer commented Oct 19, 2022

The issue has the same root cause as #38304 and fixed by #38430

Now this is fixed in master:

mysql> CREATE TABLE t0(c0 INT);
Query OK, 0 rows affected (0.03 sec)

mysql> INSERT INTO t0(c0) VALUES (0.01);
Query OK, 1 row affected (0.00 sec)

mysql> CREATE VIEW v0(c0) AS SELECT t0.c0 FROM t0;
Query OK, 0 rows affected (0.01 sec)

mysql> SELECT * FROM t0 RIGHT JOIN v0 ON DEFAULT(t0.c0);
+------+------+
| c0   | c0   |
+------+------+
| NULL |    0 |
+------+------+
1 row in set (0.01 sec)

mysql> SELECT (v0.c0)REGEXP(v0.c0 AND t0.c0) FROM t0 RIGHT JOIN v0 ON DEFAULT(t0.c0); 
+--------------------------------+
| (v0.c0)REGEXP(v0.c0 AND t0.c0) |
+--------------------------------+
|                              1 |
+--------------------------------+
1 row in set (0.01 sec)

mysql> SELECT * FROM t0 RIGHT JOIN v0 ON DEFAULT(t0.c0) WHERE (v0.c0)REGEXP(v0.c0 AND t0.c0);
+------+------+
| c0   | c0   |
+------+------+
| NULL |    0 |
+------+------+
1 row in set (0.00 sec)

@Yisaer Yisaer closed this as completed Oct 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-5.0 This bug affects 5.0.x versions. affects-5.1 This bug affects 5.1.x versions. affects-5.2 This bug affects 5.2.x versions. affects-5.3 This bug affects 5.3.x versions. affects-5.4 This bug affects 5.4.x versions. affects-6.0 affects-6.1 affects-6.2 affects-6.3 may-affects-4.0 This bug maybe affects 4.0.x versions. severity/major sig/planner SIG: Planner type/bug The issue is confirmed as a bug.
Projects
None yet
Development

No branches or pull requests

4 participants