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

release-19.2: sql: allow booleans in SET tracing and friendlier error message #44347

Merged
merged 1 commit into from
Jan 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 14 additions & 5 deletions pkg/sql/conn_executor_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -1131,13 +1131,22 @@ func (ex *connExecutor) runSetTracing(
modes := make([]string, len(n.Values))
for i, v := range n.Values {
v = unresolvedNameToStrVal(v)
strVal, ok := v.(*tree.StrVal)
if !ok {
res.SetError(errors.AssertionFailedf(
"expected string for set tracing argument, not %T", v))
var strMode string
switch val := v.(type) {
case *tree.StrVal:
strMode = val.RawString()
case *tree.DBool:
if *val {
strMode = "on"
} else {
strMode = "off"
}
default:
res.SetError(pgerror.New(pgcode.Syntax,
"expected string or boolean for set tracing argument"))
return
}
modes[i] = strVal.RawString()
modes[i] = strMode
}

if err := ex.enableTracing(modes); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/set
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,12 @@ SET tracing.blah = 123
statement error invalid value for parameter "ssl_renegotiation_limit"
SET ssl_renegotiation_limit = 123

statement ok
SET SESSION tracing=false

statement error pgcode 42601 expected string or boolean for set tracing argument
SET SESSION tracing=1

subtest regression_35109_flowable

statement ok
Expand Down