forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for executing SQL statements from the command line.
With this patch the user can use "sql -e ..." to execute statements, print their results and exit, without an interactive prompt. Fixes cockroachdb#3817
- Loading branch information
Showing
5 changed files
with
146 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// Author: Raphael 'kena' Poss (knz@cockroachlabs.com) | ||
|
||
package cli | ||
|
||
// Context holds parameters needed to setup a server. | ||
import "github.com/cockroachdb/cockroach/server" | ||
|
||
// Calling "cli".initFlags(ctx *Context) will initialize Context using | ||
// command flags. Keep in sync with "cli/flags.go". | ||
type Context struct { | ||
// Embed the server context. | ||
server.Context | ||
|
||
// OneShotSQL indicates the SQL client should run the command-line | ||
// statement(s) and terminate directly, without presenting a REPL to | ||
// the user. | ||
OneShotSQL bool | ||
} | ||
|
||
// NewContext returns a Context with default values. | ||
func NewContext() *Context { | ||
ctx := &Context{} | ||
ctx.InitDefaults() | ||
return ctx | ||
} | ||
|
||
// InitDefaults sets up the default values for a Context. | ||
func (ctx *Context) InitDefaults() { | ||
ctx.Context.InitDefaults() | ||
ctx.OneShotSQL = false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters