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
nullif
on two identical subselects produces non null value
#52986
Comments
The error.sql.txt query's plan looks incorrect:
|
/sig planner |
/remove-sig execution |
The core issue here is the > select variance(c_k6tgklu10) from t_rl02;
+-----------------------+
| variance(c_k6tgklu10) |
+-----------------------+
| 0.24595041322314046 |
+-----------------------+
1 row in set (0.00 sec)
> select variance(c_k6tgklu10) from t_rl02;
+-----------------------+
| variance(c_k6tgklu10) |
+-----------------------+
| 0.24595041322314048 |
+-----------------------+
1 row in set (0.00 sec)
> select variance(c_k6tgklu10) from t_rl02;
+-----------------------+
| variance(c_k6tgklu10) |
+-----------------------+
| 0.24595041322314043 |
+-----------------------+
1 row in set (0.00 sec) That makes the two same subqueries in the SQL may have different results. Then the MySQL document (B.3.4.8 Problems with Floating-Point Values) also has descriptions on this issue and suggestions that resolve this issue by rewriting the SQL. |
Currently, we'd like to consider this as the expected behavior and close this issue later. |
1. Minimal reproduce step (Required)
Firstly, execute
init.sql
to create the table. Then executingerror.sql
yields unexpected results. Note that reproducing these results might not be entirely stable. Typically, it can be completed within three attempts. You can try executingerror.sql
multiple times or executeinit.sql
again to rebuild the table.init.sql.txt
error.sql.txt
2. What did you expect to see? (Required)
The SQL statement applies
nullif
to two identical expressionsselect variance(c_k6tgklu10) from t_rl02
, then counts the results. Since the result is NULL, the count should be 0.3. What did you see instead (Required)
In the multi-node version, the count is 1.
output_re_main2.log
output_re_single2.log
4. What is your TiDB version? (Required)
topology:
distributed.yaml:
single.yaml
about us
We are the BASS team from the School of Cyber Science and Technology at Beihang University. Our main focus is on system software security, operating systems, and program analysis research, as well as the development of automated program testing frameworks for detecting software defects. Using our self-developed database vulnerability testing tool, we have identified the above-mentioned vulnerabilities in TiDB that may lead to database logic error.
The text was updated successfully, but these errors were encountered: