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

sql: improve error message for search_path with commas #53974

Merged
merged 1 commit into from
Jan 22, 2021

Conversation

jordanlewis
Copy link
Member

It's easy to accidentally surround your search path with quotes when
setting it, because you'd think that most things in SET syntax are
quoted. But you are not supposed to quote things in set search_path, and
it can lead to confusing scenarios. Now, if you try to set search_path
to a string containing a comma, which we don't support anyway, the error
message will be a bit friendlier.

Release note (sql change): improve error message when people use set
search_path incorrectly, or with a schema that legitimately has a comma
in its name

Release justification: error-message-only change

@jordanlewis jordanlewis requested a review from a team September 4, 2020 19:53
@cockroach-teamcity
Copy link
Member

This change is Reviewable

pkg/sql/vars.go Outdated
"schema name %q not supported in search_path", s)
return "", unimplemented.NewWithIssuef(53971,
`schema name %q has commas so is not supported in search_path.
Did you mean to omit quotes? SET search_path = %s`, s, s)
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be nicer to make this a hint via errors.WithHint.

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought about that, but the unimplemented error type already uses a hint... I guess I could use two, or just not make it an unimplemented error, but this way we get telemetry on this hilarious situation.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hints are made to be chained / combined. We do this in other places too.

Copy link
Member Author

Choose a reason for hiding this comment

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

Coming back to this several months later - thanks for the suggestion! Done.

It's easy to accidentally surround your search path with quotes when
setting it, because you'd think that most things in `SET` syntax are
quoted. But you are not supposed to quote things in set search_path, and
it can lead to confusing scenarios. Now, if you try to set search_path
to a string containing a comma, which we don't support anyway, the error
message will be a bit friendlier.

Release note (sql change): improve error message when people use set
search_path incorrectly, or with a schema that legitimately has a comma
in its name

Release justification: error-message-only change
@jordanlewis jordanlewis force-pushed the fix-search-path-error branch from 159dc25 to 73d3246 Compare January 22, 2021 20:55
@jordanlewis
Copy link
Member Author

bors r+

@craig
Copy link
Contributor

craig bot commented Jan 22, 2021

Build succeeded:

@craig craig bot merged commit 3593655 into cockroachdb:master Jan 22, 2021
@jordanlewis jordanlewis deleted the fix-search-path-error branch January 22, 2021 21:58
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.

4 participants