Skip to content

Conversation

nicktobey
Copy link
Contributor

@nicktobey nicktobey commented Apr 12, 2023

This PR is the GMS side of the fix for dolthub/dolt#5656.

Preventing panics from invalid window functions is easy: replace the panic with returning a new kind of error.

The invalid *s were trickier. I added an additional analysis rule that runs immediately after resolving function names. It checks for any uses of "*" in a subexpression (so, not just "SELECT *") that aren't used inside a COUNT, COUNTDISTINCT, or JSONARRAY function.

It's possible that there's other places where *s are allowed that we need to account for. It's also possible that there may be some other disallowed uses of * that will pass this and still cause a panic.

@nicktobey nicktobey requested a review from max-hoffman April 12, 2023 22:55
@nicktobey
Copy link
Contributor Author

The new package analyzererrors was done to prevent a package import cycle. I don't love the name but was trying to be consistent with other multi-word package named while still being illuminating when imported from outside the analyzer package. I'm open to bikeshedding it.

Copy link
Contributor

@max-hoffman max-hoffman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, we do use sql/errors.go pretty heavily if you wanted to group them there. More testing is usually good, even if just to help future refactors. Segmentation/organization of errors into subpackages probably wouldn't hurt. I'd expect the Dolt auto-bump for this to pass, which you should get notified for after merging.

The docstring for transform.Inspect and sql.Inspect requires that the inputs not be nil. If they are, something has gone wrong and we shouldn't be silently ignoring it.

Also removed a call to IsDDLNode that was copied over from validateOperands but doesn't seem to server a purpose.
@nicktobey nicktobey merged commit 3610cac into main Apr 13, 2023
@nicktobey nicktobey deleted the nicktobey/no-panic branch April 13, 2023 21:22
@nicktobey nicktobey restored the nicktobey/no-panic branch April 13, 2023 21:27
@nicktobey nicktobey deleted the nicktobey/no-panic branch April 13, 2023 21:36
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.

2 participants