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

Workaround SELECT ... ORDER BY (SELECT 1) related bug in Oracle's MySQL implementation, that can lead to completely wrong data being returned. #1850

Merged
merged 1 commit into from
Feb 27, 2024

Conversation

lauxjpn
Copy link
Collaborator

@lauxjpn lauxjpn commented Feb 27, 2024

The QuerySqlGenerator base implementation translates constant and parameter expressions in an OrderingExpression to (SELECT 1).

This leads to a bug in Oracle's MySQL, where completely wrong data is being returned under certain conditions.

As a workaround, we now just output 1 instead of (SELECT 1) for all database versions and types.

Fixes #1849

@lauxjpn lauxjpn added this to the 9.0.0 milestone Feb 27, 2024
@lauxjpn lauxjpn self-assigned this Feb 27, 2024
…QL implementation, that can lead to completely wrong data being returned.
@lauxjpn lauxjpn merged commit 5a3f9ca into PomeloFoundation:master Feb 27, 2024
21 checks passed
@lauxjpn lauxjpn deleted the fix/issue1849 branch February 27, 2024 19:32
@ChrisJollyAU
Copy link

@lauxjpn Interesting. Had to do the exact same for Jet

@lauxjpn
Copy link
Collaborator Author

lauxjpn commented Feb 28, 2024

I am not yet completely convinced, that this PR fixes the issue completely for Pomelo. I will monitor our CI runs over the coming days to make sure, since the nature of the issue is a bit non-deterministic.

lauxjpn added a commit that referenced this pull request Mar 8, 2024
…le's MySQL implementation, that can lead to completely wrong data being returned. (#1850)"
lauxjpn added a commit that referenced this pull request Mar 8, 2024
… in Oracle's MySQL implementation, that can lead to completely wrong data being returned. (#1850)""

This reverts commit 0f66b72.
lauxjpn added a commit to lauxjpn/Pomelo.EntityFrameworkCore.MySql that referenced this pull request Mar 8, 2024
…le's MySQL implementation, that can lead to completely wrong data being returned. (PomeloFoundation#1850)"

(cherry picked from commit 0f66b72)
@lauxjpn
Copy link
Collaborator Author

lauxjpn commented Mar 8, 2024

This PR does not work as intended, but introduces a query bug. See #1849 (comment) for more information.
Reverted by #1870 for 9.0 and #1871 for 8.0.

/cc @ChrisJollyAU

lauxjpn added a commit to lauxjpn/Pomelo.EntityFrameworkCore.MySql that referenced this pull request Mar 8, 2024
…le's MySQL implementation, that can lead to completely wrong data being returned. (PomeloFoundation#1850)"

(cherry picked from commit 0f66b72)
lauxjpn added a commit that referenced this pull request Mar 8, 2024
…le's MySQL implementation, that can lead to completely wrong data being returned. (#1850)" (#1870)

(cherry picked from commit 0f66b72)
lauxjpn added a commit that referenced this pull request Mar 8, 2024
…le's MySQL implementation, that can lead to completely wrong data being returned. (#1850)" (#1871)

(cherry picked from commit 0f66b72)
@ChrisJollyAU
Copy link

@lauxjpn Actually Jet would not encounter the same problem. It doesn't support positional ORDER BY. Only normal column expressions. Had also forgotten that it had used just SELECT 1 all the way from its early days. My thoughts were actually on a modification I had to do for when it was within an WHERE NOT EXISTS clause (CirrusRedOrg/EntityFrameworkCore.Jet#202 )

@lauxjpn lauxjpn modified the milestones: 9.0.0, 8.0.1 Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using SELECT ... ORDER BY (SELECT 1) can lead to the return of unexpected data using Oracle MySQL releases
2 participants