Skip to content

Commit

Permalink
cli/sql: move configurable variables to sqlCtx
Browse files Browse the repository at this point in the history
Ahead of implementing recursive evaluation, we need to ensure that all
variables customizable via `\set` / `\unset` become independent of
`cliState`. This patch does it.

Release note: None
  • Loading branch information
knz committed Sep 29, 2020
1 parent b1756f2 commit 74732dd
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 78 deletions.
19 changes: 18 additions & 1 deletion pkg/cli/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func setCliContextDefaults() {
cliCtx.allowUnencryptedClientPassword = false
}

// sqlCtx captures the command-line parameters of the `sql` command.
// sqlCtx captures the configuration of the `sql` command.
// See below for defaults.
var sqlCtx = struct {
*cliContext
Expand Down Expand Up @@ -238,6 +238,19 @@ var sqlCtx = struct {

// Determine whether to show raw durations.
verboseTimings bool

// Determines whether to stop the client upon encountering an error.
errExit bool

// Determines whether to perform client-side syntax checking.
checkSyntax bool

// autoTrace, when non-empty, encloses the executed statements
// by suitable SET TRACING and SHOW TRACE FOR SESSION statements.
autoTrace string

// The string used to produce the value of fullPrompt.
customPromptPattern string
}{cliContext: &cliCtx}

// setSQLContextDefaults set the default values in sqlCtx. This
Expand All @@ -254,6 +267,10 @@ func setSQLContextDefaults() {
sqlCtx.echo = false
sqlCtx.enableServerExecutionTimings = false
sqlCtx.verboseTimings = false
sqlCtx.errExit = true
sqlCtx.checkSyntax = true
sqlCtx.autoTrace = ""
sqlCtx.customPromptPattern = defaultPromptPattern
}

// zipCtx captures the command-line parameters of the `zip` command.
Expand Down
Loading

0 comments on commit 74732dd

Please sign in to comment.