Skip to content

Commit

Permalink
Merge pull request #44347 from yuzefovich/backport19.2-44260
Browse files Browse the repository at this point in the history
release-19.2: sql: allow booleans in SET tracing and friendlier error message
  • Loading branch information
yuzefovich committed Jan 24, 2020
2 parents 8fa3e90 + 4c50029 commit 4ad4fb8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
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

0 comments on commit 4ad4fb8

Please sign in to comment.