Skip to content

Join Involving View and ATAN2 function produce wrong result #60093

@TheoristCoder

Description

@TheoristCoder

Bug Report

1. Minimal reproduce step (Required)

CREATE TABLE t0(c0 int);

CREATE TABLE t1(c0 DECIMAL);

INSERT INTO t1(c0) VALUES (1687);
INSERT  INTO t0(c0) VALUES (0);


CREATE VIEW v0(c0) AS SELECT CAST(((t1.c0)DIV(t1.c0)) AS DECIMAL) FROM t1;


SELECT * FROM v0 INNER JOIN t0 ON ( (v0.c0 LIKE CAST(v0.c0 AS CHAR) ) <= (((t0.c0))) AND ((NOT (ATAN2(t0.c0, v0.c0)))) );

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

Empty result

3. What did you see instead (Required)

1.000000000000000000000000000000 , 0

More importantly, if I just create a identical table instead of using view:

CREATE TABLE t0(c0 int);
INSERT  INTO t0(c0) VALUES (0);

CREATE TABLE v0(c0 DECIMAL);
INSERT INTO v0(c0) VALUES (1.00000);

SELECT * FROM v0 INNER JOIN t0 ON ( (v0.c0 LIKE CAST(v0.c0 AS CHAR) ) <= (((t0.c0))) AND ((NOT (ATAN2(t0.c0, v0.c0)))) );

It will produce correct result which is same as that of mysql.

4. What is your TiDB version? (Required)

 Release Version: v9.0.0-beta.1.pre-389-g21f9bb7b7a
Edition: Community
Git Commit Hash: 21f9bb7b7a7478d825c4dee4fbf2ce913e3e7cf1
Git Branch: HEAD
UTC Build Time: 2025-03-11 09:37:34
GoVersion: go1.23.7
Race Enabled: false
Check Table Before Drop: false
Store: tikv |

Metadata

Metadata

Assignees

Labels

affects-7.5This bug affects the 7.5.x(LTS) versions.affects-8.1This bug affects the 8.1.x(LTS) versions.affects-8.5This bug affects the 8.5.x(LTS) versions.severity/majorsig/plannerSIG: Plannertype/bugThe issue is confirmed as a bug.type/regression

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions