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

Ensure all SelectExpressions always have a SqlAliasManager #35570

Merged
merged 1 commit into from
Feb 3, 2025

Conversation

roji
Copy link
Member

@roji roji commented Feb 2, 2025

The SQL alias refactoring work in 9.0 assumed that only mutable SelectExpressions need a SqlAliasManager, which is incorrect: pushdown may be called on immutable SelectExpressions later in the query pipeline (e.g. SqlNullabilityProcessor). This means that even our immutable SelectExpressions aren't really fully immutable (again a blurring of the mutability line which we need to get rid of).

In the meantime, this PR ensures that all SelectExpressions always have SqlAliasManager, regardless of whether they're (supposedly) mutable or not.

/cc @lauxjpn @ChrisJollyAU. As you've worked around this issue in 9 in your providers, and we've gotten only one user report, I'll hold back proposing this for backporting in a patch. But we can revisit that based on user feedback.

Fixes #35507

@roji roji requested a review from a team February 2, 2025 17:14
@ChrisJollyAU
Copy link
Contributor

Quick eyeball looks good. Will probably have a closer look during the week.

Thats fine to keep it to 10.0. It's a rather specific bug that doesn't pop up much. To be honest I actually think those writing ef core providers are the most likely to bump into this especially if they need to do some pushdowns because of any modifications for postprocessing/optimizing.

@roji
Copy link
Member Author

roji commented Feb 2, 2025

Thanks @ChrisJollyAU, a review would definitely be appreciated. Yeah, I wouldn't necessarily have even worked on this at this point if it hadn't been for the user-visible regression it causes (#35507).

@ocdi
Copy link

ocdi commented Feb 3, 2025

As the user who is reported this bug, this is a blocker for us upgrading to 9.x. Once this has been merged to main, is there a way we can get this into a 9.x build?

@roji
Copy link
Member Author

roji commented Feb 3, 2025

@ocdi the bar for patching is usually pretty high, and we haven't got any other reports of users hitting this yet - but I'll discuss with the team.

@roji roji enabled auto-merge (squash) February 3, 2025 10:05
@roji roji merged commit d58959f into dotnet:main Feb 3, 2025
7 checks passed
@roji roji deleted the SqlAliasManager branch February 3, 2025 13:12
@roji
Copy link
Member Author

roji commented Feb 4, 2025

Design decision: as this is a non-trivial and not easily quirkable fix, we'll hold off patching this for now, until we get at least one additional user report. At that point we can consider backporting this fix or a more targeted hack.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Null Reference due to missing sqlAliasManager in SelectExpression
4 participants