Skip to content

Commit

Permalink
clisqlshell: hide debug mode behind --debug-sql-cli
Browse files Browse the repository at this point in the history
Release note (cli change): The interactive SQL shell now supports an
advanced debug mode for troubleshooting when `--debug-sql-cli` is
specified on the command line. The debug mode can be enabled with
Ctrl+@ or Ctrl+_ (Ctrl+space on macOS).
  • Loading branch information
knz committed Nov 20, 2022
1 parent 710147f commit 55e793c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions pkg/cli/clisqlshell/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ type editor interface {
}

type sqlShell interface {
enableDebug() bool
inCopy() bool
runShowCompletions(sql string, offset int) (rows [][]string, err error)
serverSideParse(sql string) (string, error)
Expand Down
4 changes: 3 additions & 1 deletion pkg/cli/clisqlshell/editor_bubbline.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ func (b *bubblineReader) init(
cleanupFn = func() { b.ins.Close() }

b.ins.MaxHistorySize = maxHistEntries
b.ins.SetDebugEnabled(true)
if sqlS.enableDebug() {
b.ins.SetDebugEnabled(true)
}
b.ins.Reflow = sqlS.reflow
b.ins.AutoComplete = b.getCompletions
b.ins.CheckInputComplete = b.checkInputComplete
Expand Down
5 changes: 5 additions & 0 deletions pkg/cli/clisqlshell/sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -2277,6 +2277,11 @@ func (c *cliState) runStatements(stmts []string) error {
return c.exitErr
}

// enableDebug implements the sqlShell interface (to support the editor).
func (c *cliState) enableDebug() bool {
return c.sqlConnCtx.DebugMode
}

// serverSideParse implements the sqlShell interface (to support the editor).
// It uses the SHOW SYNTAX statement to analyze the given string.
// If the syntax is correct, the function returns the statement
Expand Down

0 comments on commit 55e793c

Please sign in to comment.