From 159dc25aa1df6656b053755017308aaefbf8eda8 Mon Sep 17 00:00:00 2001 From: Jordan Lewis Date: Fri, 4 Sep 2020 15:37:24 -0400 Subject: [PATCH] sql: improve error message for search_path with commas 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 --- pkg/sql/vars.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pkg/sql/vars.go b/pkg/sql/vars.go index 5ac648f63f80..311a7c9a10ee 100644 --- a/pkg/sql/vars.go +++ b/pkg/sql/vars.go @@ -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)