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 result by subquery and join #100561
Comments
Hello, I am Blathers. I am here to help you get the issue triaged. Hoot - a bug! Though bugs are the bane of my existence, rest assured the wretched thing will get the best of care here. I was unable to automatically find someone to ping. If we have not gotten back to your issue within a few business days, you can try the following:
🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Thanks for the report! Indeed, both queries seem to be equivalent, and I believe they should return 1 row in the result. I also confirmed that this bug is present on master, 22.2.6, and 22.1.13, so it's not a recent regression. |
Thank you for your confirmation. Very happy this report was helpful to you. |
Here's a simplified reproduction: CREATE TABLE a (a INT);
CREATE TABLE bc (b INT, c INT);
INSERT INTO bc (b) VALUES(1);
SELECT * FROM (
SELECT bc.c + 1 AS y, bc.b + 1 AS x
FROM a FULL OUTER JOIN bc ON true
) tmp, bc
WHERE tmp.x = bc.b + 1; It returns a single row in Postgres but no rows in CRDB. |
The bug is in the I'm still trying to figure out how easy it is to hit this bug. It's been present since the |
This commit fixes a bug in the `RejectNullsProject` rule that pushed null-rejecting filters below a Project expression for _all_ projected columns when _any_ of the projected columns had null-rejecting filters above the projections. In other words, it could incorrectly synthesize a null-rejecting filter for a projected column, causing incorrect results. Fixes cockroachdb#100561 Release note (bug fix): A bug has been fixed that could cause incorrect query results.
This commit fixes a bug in the `RejectNullsProject` rule that pushed null-rejecting filters below a Project expression for _all_ projected columns when _any_ of the projected columns had null-rejecting filters above the projections. In other words, it could incorrectly synthesize a null-rejecting filter for a projected column, causing incorrect results. Fixes cockroachdb#100561 Release note (bug fix): A bug has been fixed that could cause incorrect query results. This bug was present since v20.2.
103531: sql: enable deletes in udfs r=rharding6373 a=rharding6373 This PR enables DELETE statements in UDF bodies and adds logic test coverage of them. Epic: CRDB-19255 Informs: #87289 Release note (sql change): Enables DELETE commands in UDF statement bodies. 103611: opt: fix bug in RejectNullsProject r=mgartner a=mgartner #### opt: fix bug in RejectNullsProject This commit fixes a bug in the `RejectNullsProject` rule that pushed null-rejecting filters below a Project expression for _all_ projected columns when _any_ of the projected columns had null-rejecting filters above the projections. In other words, it could incorrectly synthesize a null-rejecting filter for a projected column, causing incorrect results. Fixes #100561 Release note (bug fix): A bug has been fixed that could cause queries with with joins or subqueries to omit rows where column values are NULL in very rare cases. This bug was present since v20.2. #### opt: add fast-path to HasNullRejectingFilter `HasNullRejectingFilter` now returns `false` immediately if the given column set is empty, rather than unnecessarily extracting null columns from filter constraints. This is valid because the function only returns true if the given column set intersects with another column set, and the empty set never intersects with any other set. Release note: None Co-authored-by: rharding6373 <rharding6373@users.noreply.github.com> Co-authored-by: Marcus Gartner <marcus@cockroachlabs.com>
This commit fixes a bug in the `RejectNullsProject` rule that pushed null-rejecting filters below a Project expression for _all_ projected columns when _any_ of the projected columns had null-rejecting filters above the projections. In other words, it could incorrectly synthesize a null-rejecting filter for a projected column, causing incorrect results. Fixes #100561 Release note (bug fix): A bug has been fixed that could cause queries with with joins or subqueries to omit rows where column values are NULL in very rare cases. This bug was present since v20.2.
This commit fixes a bug in the `RejectNullsProject` rule that pushed null-rejecting filters below a Project expression for _all_ projected columns when _any_ of the projected columns had null-rejecting filters above the projections. In other words, it could incorrectly synthesize a null-rejecting filter for a projected column, causing incorrect results. Fixes #100561 Release note (bug fix): A bug has been fixed that could cause queries with with joins or subqueries to omit rows where column values are NULL in very rare cases. This bug was present since v20.2.
This commit fixes a bug in the `RejectNullsProject` rule that pushed null-rejecting filters below a Project expression for _all_ projected columns when _any_ of the projected columns had null-rejecting filters above the projections. In other words, it could incorrectly synthesize a null-rejecting filter for a projected column, causing incorrect results. Fixes #100561 Release note (bug fix): A bug has been fixed that could cause queries with with joins or subqueries to omit rows where column values are NULL in very rare cases. This bug was present since v20.2.
Describe the problem
consider the following program:
There two queries are equivalent and just put the subquery at different place. but the second query has empty results. I manually analyze it and think it should have the same result with the first query.
Also, if I remove the output column
temp_table3.c0
of the second query, it will have1
as result. This should not affect the result.To Reproduce
this bug can reproduce with the last commit version (07c7d4b) and last release version (v22.2.7).
I run the cockroachdb in a single machine and execute this program with CLI
Expected behavior
The second query has the same results with the first one.
Environment:
Jira issue: CRDB-26494
The text was updated successfully, but these errors were encountered: