Skip to content

Commit

Permalink
sql: improve error message for search_path with commas
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jordanlewis committed Sep 4, 2020
1 parent df58be2 commit 159dc25
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/sql/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -847,8 +847,9 @@ var varGen = map[string]sessionVar{
// TODO(knz): if/when we want to support this, we'll need to change
// the interface between GetStringVal() and Set() to take string
// arrays instead of a single string.
return "", unimplemented.Newf("schema names containing commas in search_path",
"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)
}
buf.WriteString(comma)
buf.WriteString(s)
Expand Down

0 comments on commit 159dc25

Please sign in to comment.