Merge branch 'main' into zachmu/multi-db3

This commit is contained in:
Zach Musgrave
2023-04-24 16:42:45 -07:00
111 changed files with 727 additions and 459 deletions
+6 -1
View File
@@ -40,6 +40,11 @@ jobs:
echo "code is formatted"
else
echo "code is not formatted"
if [ "${{ github.repository }}" != "dolthub/dolt" ]; then
echo "Pull requests from forks must be manually formatted."
echo "Please run dolt/go/utils/repofmt/format_repo.sh to format this pull request."
exit 1;
fi
echo "format=true" >> $GITHUB_OUTPUT
fi
env:
@@ -116,7 +121,7 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.ref || github.ref }}
repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }}
token: ${{ secrets.REPO_ACCESS_TOKEN || secrets.GITHUB_TOKEN }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Run go mod tidy
run: go mod tidy
working-directory: ./go
+19
View File
@@ -0,0 +1,19 @@
// Copyright 2023 Dolthub, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package cli
// CliContexct is used to pass top level command information down to subcommands.
type CliContext interface {
}
+6 -6
View File
@@ -64,7 +64,7 @@ type Command interface {
// Description returns a description of the command
Description() string
// Exec executes the command
Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int
Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx CliContext) int
// Docs returns the documentation for this command, or nil if it's undocumented
Docs() *CommandDocumentation
// ArgParser returns the arg parser for this command
@@ -169,7 +169,7 @@ func (hc SubCommandHandler) Hidden() bool {
return hc.hidden
}
func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx CliContext) int {
if len(args) < 1 && hc.Unspecified == nil {
hc.printUsage(commandStr)
return 1
@@ -183,11 +183,11 @@ func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args []
for _, cmd := range hc.Subcommands {
lwrName := strings.ToLower(cmd.Name())
if lwrName == subCommandStr {
return hc.handleCommand(ctx, commandStr+" "+subCommandStr, cmd, args[1:], dEnv)
return hc.handleCommand(ctx, commandStr+" "+subCommandStr, cmd, args[1:], dEnv, cliCtx)
}
}
if hc.Unspecified != nil {
return hc.handleCommand(ctx, commandStr, hc.Unspecified, args, dEnv)
return hc.handleCommand(ctx, commandStr, hc.Unspecified, args, dEnv, cliCtx)
}
if !isHelp(subCommandStr) {
@@ -199,7 +199,7 @@ func (hc SubCommandHandler) Exec(ctx context.Context, commandStr string, args []
return 0
}
func (hc SubCommandHandler) handleCommand(ctx context.Context, commandStr string, cmd Command, args []string, dEnv *env.DoltEnv) int {
func (hc SubCommandHandler) handleCommand(ctx context.Context, commandStr string, cmd Command, args []string, dEnv *env.DoltEnv, cliCtx CliContext) int {
cmdRequiresRepo := true
if rnrCmd, ok := cmd.(RepoNotRequiredCommand); ok {
cmdRequiresRepo = rnrCmd.RequiresRepo()
@@ -234,7 +234,7 @@ func (hc SubCommandHandler) handleCommand(ctx context.Context, commandStr string
return 1
}
ret := cmd.Exec(ctx, commandStr, args, dEnv)
ret := cmd.Exec(ctx, commandStr, args, dEnv, cliCtx)
if evt != nil {
events.GlobalCollector.CloseEventAndAdd(evt)
+2 -2
View File
@@ -68,7 +68,7 @@ func (cmd *trackedCommand) RequiresRepo() bool {
return false
}
func (cmd *trackedCommand) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd *trackedCommand) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx CliContext) int {
cmd.called = true
cmd.cmdStr = commandStr
cmd.args = args
@@ -133,7 +133,7 @@ func runCommand(root Command, commandLine string) int {
panic("Invalid test command line")
}
return root.Exec(context.Background(), appName, tokens[1:], nil)
return root.Exec(context.Background(), appName, tokens[1:], nil, nil)
}
func TestHasHelpFlag(t *testing.T) {
+1 -1
View File
@@ -60,7 +60,7 @@ func (cmd AddCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd AddCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateAddArgParser()
helpPr, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, addDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, helpPr)
+1 -1
View File
@@ -64,7 +64,7 @@ func (cmd SetRefCmd) Hidden() bool {
// Version displays the version of the running dolt client
// Exec executes the command
func (cmd SetRefCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd SetRefCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
usage, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap))
+1 -1
View File
@@ -60,7 +60,7 @@ func (cmd ShowRootCmd) Hidden() bool {
// Version displays the version of the running dolt client
// Exec executes the command
func (cmd ShowRootCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ShowRootCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
usage, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap))
+1 -1
View File
@@ -66,7 +66,7 @@ func (a Assist) Hidden() bool {
return true
}
func (a *Assist) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (a *Assist) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
a.messages = make([]string, 0)
apiKey, ok := os.LookupEnv("OPENAI_API_KEY")
+1 -1
View File
@@ -105,7 +105,7 @@ func (cmd BackupCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd BackupCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd BackupCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, backupDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+2 -2
View File
@@ -79,7 +79,7 @@ func (cmd BlameCmd) EventType() eventsapi.ClientEventType {
//
// When all nodes have blame information, stop iterating through commits and print the blame graph.
// Exec executes the command
func (cmd BlameCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd BlameCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, blameDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
@@ -90,5 +90,5 @@ func (cmd BlameCmd) Exec(ctx context.Context, commandStr string, args []string,
}
args = []string{"--" + QueryFlag, fmt.Sprintf(blameQueryTemplate, apr.Arg(0))}
return SqlCmd{}.Exec(ctx, "sql", args, dEnv)
return SqlCmd{}.Exec(ctx, "sql", args, dEnv, nil)
}
+1 -1
View File
@@ -98,7 +98,7 @@ func (cmd BranchCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd BranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd BranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, branchDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -78,7 +78,7 @@ func (cmd CheckoutCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd CheckoutCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CheckoutCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateCheckoutArgParser()
helpPrt, usagePrt := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, checkoutDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, helpPrt)
+3 -3
View File
@@ -71,7 +71,7 @@ func (cmd CherryPickCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command.
func (cmd CherryPickCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CherryPickCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateCherryPickArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cherryPickDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
@@ -156,13 +156,13 @@ func cherryPick(ctx context.Context, dEnv *env.DoltEnv, cherryStr string) errhan
if err != nil {
return errhand.VerboseErrorFromError(err)
}
res := AddCmd{}.Exec(ctx, "add", []string{"-A"}, dEnv)
res := AddCmd{}.Exec(ctx, "add", []string{"-A"}, dEnv, nil)
if res != 0 {
return errhand.BuildDError("dolt add failed").AddCause(err).Build()
}
commitParams := []string{"-m", commitMsg}
res = CommitCmd{}.Exec(ctx, "commit", commitParams, dEnv)
res = CommitCmd{}.Exec(ctx, "commit", commitParams, dEnv, nil)
if res != 0 {
return errhand.BuildDError("dolt commit failed").AddCause(err).Build()
}
+1 -1
View File
@@ -65,7 +65,7 @@ func (cmd CleanCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd CleanCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CleanCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateCleanArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cleanDocContent, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -81,7 +81,7 @@ func (cmd CloneCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd CloneCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CloneCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cloneDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -75,7 +75,7 @@ func (cmd CatCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, catDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -88,7 +88,7 @@ func (cmd ResolveCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd ResolveCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ResolveCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, resDocumentation, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -62,6 +62,6 @@ func TestCommandsRequireInitializedDir(t *testing.T) {
dEnv := createUninitializedEnv()
for _, test := range tests {
test.comm.Exec(context.Background(), test.cmdStr, test.args, dEnv)
test.comm.Exec(context.Background(), test.cmdStr, test.args, dEnv, nil)
}
}
+2 -2
View File
@@ -76,14 +76,14 @@ func (cmd CommitCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd CommitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CommitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
res := performCommit(ctx, commandStr, args, dEnv)
if res == 1 {
return res
}
// if the commit was successful, print it out using the log command
return LogCmd{}.Exec(ctx, "log", []string{"-n=1"}, dEnv)
return LogCmd{}.Exec(ctx, "log", []string{"-n=1"}, dEnv, nil)
}
func performCommit(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
+1 -1
View File
@@ -116,7 +116,7 @@ func (cmd ConfigCmd) ArgParser() *argparser.ArgParser {
// Exec is used by the config command to allow users to view / edit their global and repository local configurations.
// Exec executes the command
func (cmd ConfigCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ConfigCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cfgDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+8 -8
View File
@@ -280,8 +280,8 @@ func TestConfig(t *testing.T) {
// test setting global config with --add
configCmd := ConfigCmd{}
ret := configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "name", "bheni"}, dEnv)
ret += configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "title", "dufus"}, dEnv)
ret := configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "name", "bheni"}, dEnv, nil)
ret += configCmd.Exec(ctx, "dolt config", []string{"-global", "--add", "title", "dufus"}, dEnv, nil)
expectedGlobal := map[string]string{
"name": "bheni",
@@ -295,7 +295,7 @@ func TestConfig(t *testing.T) {
}
// test setting global config with --set
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--set", "name", "steph"}, dEnv)
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--set", "name", "steph"}, dEnv, nil)
expectedGlobal = map[string]string{
"name": "steph",
@@ -309,7 +309,7 @@ func TestConfig(t *testing.T) {
}
// test setting local config with --add
ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--add", "title", "senior dufus"}, dEnv)
ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--add", "title", "senior dufus"}, dEnv, nil)
expectedLocal := map[string]string{
"title": "senior dufus",
@@ -324,7 +324,7 @@ func TestConfig(t *testing.T) {
}
// test setting local config with --set
ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--set", "name", "steph"}, dEnv)
ret = configCmd.Exec(ctx, "dolt config", []string{"-local", "--set", "name", "steph"}, dEnv, nil)
expectedLocal = map[string]string{
"name": "steph",
@@ -339,7 +339,7 @@ func TestConfig(t *testing.T) {
t.Error("Unexpected value of \"name\" retrieved from the config hierarchy")
}
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--unset", "name"}, dEnv)
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--unset", "name"}, dEnv, nil)
expectedGlobal = map[string]string{
"title": "dufus",
@@ -402,14 +402,14 @@ func TestInvalidConfigArgs(t *testing.T) {
configCmd := ConfigCmd{}
// local and global flags passed together is invalid
ret := configCmd.Exec(ctx, "dolt config", []string{"--global", "--local", "--add", "name", "bheni"}, dEnv)
ret := configCmd.Exec(ctx, "dolt config", []string{"--global", "--local", "--add", "name", "bheni"}, dEnv, nil)
if ret == 0 {
t.Error("Invalid commands should fail. Command has both local and global")
}
// both -add and -get are used
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--get", "--add", "title"}, dEnv)
ret = configCmd.Exec(ctx, "dolt config", []string{"-global", "--get", "--add", "title"}, dEnv, nil)
if ret == 0 {
t.Error("Invalid commands should fail. Command is missing local/global")
+1 -1
View File
@@ -78,7 +78,7 @@ func (cmd CheckCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd CheckCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CheckCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, checkDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -89,7 +89,7 @@ func (cmd ImportCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, importDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -74,7 +74,7 @@ func (cmd LsCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, lsDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -70,7 +70,7 @@ func (cmd NewCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd NewCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd NewCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, newDocs, ap))
cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -67,7 +67,7 @@ func (cmd RmCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, rmDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -73,7 +73,7 @@ func (cmd UseCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd UseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd UseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, useDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
@@ -67,7 +67,7 @@ func (cmd VerifyConstraintsCmd) ArgParser() *argparser.ArgParser {
return cli.CreateVerifyConstraintsArgParser(cmd.Name())
}
func (cmd VerifyConstraintsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd VerifyConstraintsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, verifyConstraintsDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -159,7 +159,7 @@ func (cmd DiffCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, diffDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -66,7 +66,7 @@ func (cmd DiffCmd) ArgParser() *argparser.ArgParser {
}
// Exec implements cli.Command.
func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd DiffCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, diffDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -71,7 +71,7 @@ func (cmd UploadCmd) ArgParser() *argparser.ArgParser {
}
// Exec implements cli.Command.
func (cmd UploadCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd UploadCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, uploadDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -69,7 +69,7 @@ func (cmd PrintCmd) ArgParser() *argparser.ArgParser {
}
// Exec implements cli.Command.
func (cmd PrintCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd PrintCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, printDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -113,7 +113,7 @@ func (cmd DumpCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd DumpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd DumpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, dumpDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -72,7 +72,7 @@ func (cmd *DumpDocsCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd *DumpDocsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd *DumpDocsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap))
+1 -1
View File
@@ -68,7 +68,7 @@ func (cmd FetchCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd FetchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd FetchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateFetchArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, fetchDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -96,7 +96,7 @@ func (cmd FilterBranchCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd FilterBranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd FilterBranchCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, filterBranchDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -81,7 +81,7 @@ func (cmd GarbageCollectionCmd) EventType() eventsapi.ClientEventType {
// Version displays the version of the running dolt client
// Exec executes the command
func (cmd GarbageCollectionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd GarbageCollectionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
var verr errhand.VerboseError
ap := cmd.ArgParser()
+1 -1
View File
@@ -47,7 +47,7 @@ func (z GenZshCompCmd) Description() string {
return "Creates a zsh autocomp file for all dolt commands"
}
func (z GenZshCompCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (z GenZshCompCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := z.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap))
+1 -1
View File
@@ -79,7 +79,7 @@ func (cmd CatCmd) ArgParser() *argparser.ArgParser {
return ap
}
func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CatCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, catDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -55,7 +55,7 @@ func (cmd LsCmd) ArgParser() *argparser.ArgParser {
return ap
}
func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
ap.TooManyArgsErrorFunc = func(receivedArgs []string) error {
args := strings.Join(receivedArgs, ", ")
+1 -1
View File
@@ -58,7 +58,7 @@ func (cmd RebuildCmd) ArgParser() *argparser.ArgParser {
return ap
}
func (cmd RebuildCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd RebuildCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, rebuildDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -86,7 +86,7 @@ func (cmd InitCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd InitCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, initDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+3 -5
View File
@@ -67,7 +67,7 @@ func TestInit(t *testing.T) {
gCfg, _ := dEnv.Config.GetConfig(env.GlobalConfig)
gCfg.SetStrings(test.GlobalConfig)
result := InitCmd{}.Exec(context.Background(), "dolt init", test.Args, dEnv)
result := InitCmd{}.Exec(context.Background(), "dolt init", test.Args, dEnv, nil)
defer dEnv.DoltDB.Close()
require.Equalf(t, test.ExpectSuccess, result == 0, "- Expected success: %t; result: %t;", test.ExpectSuccess, result == 0)
@@ -86,13 +86,11 @@ func TestInit(t *testing.T) {
func TestInitTwice(t *testing.T) {
dEnv := createUninitializedEnv()
result := InitCmd{}.Exec(context.Background(), "dolt init",
[]string{"-name", "Bill Billerson", "-email", "bigbillieb@fake.horse"}, dEnv)
result := InitCmd{}.Exec(context.Background(), "dolt init", []string{"-name", "Bill Billerson", "-email", "bigbillieb@fake.horse"}, dEnv, nil)
require.True(t, result == 0, "First init should succeed")
defer dEnv.DoltDB.Close()
result = InitCmd{}.Exec(context.Background(), "dolt init",
[]string{"-name", "Bill Billerson", "-email", "bigbillieb@fake.horse"}, dEnv)
result = InitCmd{}.Exec(context.Background(), "dolt init", []string{"-name", "Bill Billerson", "-email", "bigbillieb@fake.horse"}, dEnv, nil)
require.True(t, result != 0, "Second init should fail")
}
+1 -1
View File
@@ -73,7 +73,7 @@ func (cmd InspectCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd InspectCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd InspectCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -109,7 +109,7 @@ func (cmd LogCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd LogCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd LogCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
return cmd.logWithLoggerFunc(ctx, commandStr, args, dEnv)
}
+1 -1
View File
@@ -94,7 +94,7 @@ func (cmd LoginCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd LoginCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, loginDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -78,7 +78,7 @@ func (cmd LsCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd LsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, lsDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -77,7 +77,7 @@ func (cmd MergeCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd MergeCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateMergeArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, mergeDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -65,7 +65,7 @@ func (cmd MergeBaseCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd MergeBaseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd MergeBaseCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, mergeBaseDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -75,7 +75,7 @@ func (cmd MigrateCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd MigrateCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd MigrateCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, migrateDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -68,7 +68,7 @@ func (cmd PullCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd PullCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreatePullArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, pullDocs, ap))
+1 -1
View File
@@ -80,7 +80,7 @@ func (cmd PushCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd PushCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd PushCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, pushDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -84,7 +84,7 @@ func (cmd ReadTablesCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd ReadTablesCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ReadTablesCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, readTablesDocs, ap))
+1 -1
View File
@@ -101,7 +101,7 @@ func (cmd RemoteCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd RemoteCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd RemoteCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, remoteDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -81,7 +81,7 @@ func (cmd ResetCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd ResetCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ResetCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateResetArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, resetDocContent, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+3 -3
View File
@@ -64,7 +64,7 @@ func (cmd RevertCmd) ArgParser() *argparser.ArgParser {
}
// Exec implements the interface cli.Command.
func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateRevertArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, revertDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
@@ -144,7 +144,7 @@ func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string,
if err != nil {
return HandleVErrAndExitCode(errhand.VerboseErrorFromError(err), usage)
}
res := AddCmd{}.Exec(ctx, "add", []string{"-A"}, dEnv)
res := AddCmd{}.Exec(ctx, "add", []string{"-A"}, dEnv, nil)
if res != 0 {
return res
}
@@ -156,5 +156,5 @@ func (cmd RevertCmd) Exec(ctx context.Context, commandStr string, args []string,
commitParams = append(commitParams, "--author", authorStr)
}
return CommitCmd{}.Exec(ctx, "commit", commitParams, dEnv)
return CommitCmd{}.Exec(ctx, "commit", commitParams, dEnv, nil)
}
+1 -1
View File
@@ -80,7 +80,7 @@ func (cmd RootsCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd RootsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd RootsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, cli.CommandDocumentationContent{}, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -74,7 +74,7 @@ func (cmd ExportCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, schExportDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -160,7 +160,7 @@ func (cmd ImportCmd) ArgParser() *argparser.ArgParser {
// Exec implements the import schema command that will take a file and infer it's schema, and then create a table matching that schema.
// Exec executes the command
func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, schImportDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
@@ -33,6 +33,6 @@ func TestSchemaExport(t *testing.T) {
args := []string{}
commandStr := "dolt schema export"
result := ExportCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := ExportCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, 0, result)
}
+1 -1
View File
@@ -73,7 +73,7 @@ func (cmd ShowCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblSchemaDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -64,7 +64,7 @@ func (cmd TagsCmd) ArgParser() *argparser.ArgParser {
return ap
}
func (cmd TagsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd TagsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblTagsDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -65,7 +65,7 @@ func (cmd UpdateTagCmd) ArgParser() *argparser.ArgParser {
return ap
}
func (cmd UpdateTagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd UpdateTagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, updateTagDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -74,7 +74,7 @@ func (cmd SendMetricsCmd) ArgParser() *argparser.ArgParser {
// Exec is the implementation of the command that flushes the events to the grpc service
// Exec executes the command
func (cmd SendMetricsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd SendMetricsCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
if dEnv.DoltDB != nil { // see go/cmd/dolt/dolt.go:interceptSendMetrics()
cli.PrintErrln("expected DoltEnv without DoltDB")
return 1
+1 -1
View File
@@ -90,7 +90,7 @@ func (cmd ShowCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ShowCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, showDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -179,7 +179,7 @@ func (cmd SqlCmd) RequiresRepo() bool {
// Exec executes the command
// Unlike other commands, sql doesn't set a new working root directly, as the SQL layer updates the working set as
// necessary when committing work.
func (cmd SqlCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd SqlCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, sqlDocs, ap))
+11 -11
View File
@@ -53,7 +53,7 @@ func TestSqlConsole(t *testing.T) {
args := []string{}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, 0, result)
})
@@ -81,7 +81,7 @@ func TestSqlBatchMode(t *testing.T) {
args := []string{"-b", "-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
})
}
@@ -120,7 +120,7 @@ func TestSqlSelect(t *testing.T) {
args := []string{"-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
})
}
@@ -146,7 +146,7 @@ func TestSqlShow(t *testing.T) {
args := []string{"-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
})
}
@@ -179,7 +179,7 @@ func TestCreateTable(t *testing.T) {
args := []string{"-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
working, err = dEnv.WorkingRoot(context.Background())
@@ -219,7 +219,7 @@ func TestShowTables(t *testing.T) {
args := []string{"-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
})
}
@@ -250,7 +250,7 @@ func TestAlterTable(t *testing.T) {
args := []string{"-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
})
}
@@ -277,7 +277,7 @@ func TestDropTable(t *testing.T) {
args := []string{"-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv)
result := SqlCmd{}.Exec(context.TODO(), commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
})
}
@@ -396,7 +396,7 @@ func TestInsert(t *testing.T) {
args := []string{"-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv)
result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
if result == 0 {
@@ -477,7 +477,7 @@ func TestUpdate(t *testing.T) {
args := []string{"-q", test.query}
commandStr := "dolt sql"
result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv)
result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
if result == 0 {
@@ -552,7 +552,7 @@ func TestDelete(t *testing.T) {
ctx := context.Background()
commandStr := "dolt sql"
result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv)
result := SqlCmd{}.Exec(ctx, commandStr, args, dEnv, nil)
assert.Equal(t, test.expectedRes, result)
if result == 0 {
+7 -4
View File
@@ -66,7 +66,7 @@ func Serve(
}
serverController.StopServer()
serverController.serverStopped(closeError)
sqlserver.SetRunningServer(nil)
sqlserver.UnsetRunningServer()
}()
if startError = ValidateConfig(serverConfig); startError != nil {
@@ -211,7 +211,9 @@ func Serve(
cli.PrintErr(startError)
return
}
sqlserver.SetRunningServer(mySQLServer)
lck := env.NewDBLock(serverConfig.Port())
sqlserver.SetRunningServer(mySQLServer, &lck)
var metSrv *http.Server
if serverConfig.MetricsHost() != "" && serverConfig.MetricsPort() > 0 {
@@ -311,7 +313,8 @@ func Serve(
startError = env.ErrActiveServerLock.New(f)
return
}
if err = mrEnv.Lock(); err != nil {
if err = mrEnv.Lock(lck); err != nil {
startError = err
return
}
@@ -390,7 +393,7 @@ func newSessionBuilder(se *engine.SqlEngine, config ServerConfig) server.Session
dsess, err := se.NewDoltSession(ctx, mysqlBaseSess)
if err != nil {
if goerrors.Is(err, env.ErrFailedToAccessDB) {
if server := sqlserver.GetRunningServer(); server != nil {
if server, _ := sqlserver.GetRunningServer(); server != nil {
_ = server.Close()
}
}
+1 -1
View File
@@ -99,7 +99,7 @@ func (cmd SqlClientCmd) Hidden() bool {
return false
}
func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd SqlClientCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, sqlClientDocs, ap))
+1 -1
View File
@@ -173,7 +173,7 @@ func (cmd SqlServerCmd) RequiresRepo() bool {
}
// Exec executes the command
func (cmd SqlServerCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd SqlServerCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
controller := NewServerController()
newCtx, cancelF := context.WithCancel(context.Background())
go func() {
+1 -1
View File
@@ -63,7 +63,7 @@ func (cmd StashClearCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd StashClearCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd StashClearCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
if !dEnv.DoltDB.Format().UsesFlatbuffers() {
cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error())
return 1
+1 -1
View File
@@ -66,7 +66,7 @@ func (cmd StashDropCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd StashDropCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd StashDropCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
if !dEnv.DoltDB.Format().UsesFlatbuffers() {
cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error())
return 1
+1 -1
View File
@@ -63,7 +63,7 @@ func (cmd StashListCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd StashListCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd StashListCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
if !dEnv.DoltDB.Format().UsesFlatbuffers() {
cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error())
return 1
+2 -2
View File
@@ -70,7 +70,7 @@ func (cmd StashPopCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd StashPopCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd StashPopCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
if !dEnv.DoltDB.Format().UsesFlatbuffers() {
cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error())
return 1
@@ -104,7 +104,7 @@ func (cmd StashPopCmd) Exec(ctx context.Context, commandStr string, args []strin
return handleStashPopErr(usage, err)
}
ret := commands.StatusCmd{}.Exec(ctx, "status", []string{}, dEnv)
ret := commands.StatusCmd{}.Exec(ctx, "status", []string{}, dEnv, nil)
if ret != 0 || !success {
cli.Println("The stash entry is kept in case you need it again.")
return 1
+1 -1
View File
@@ -88,7 +88,7 @@ func (cmd StashCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd StashCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd StashCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
if !dEnv.DoltDB.Format().UsesFlatbuffers() {
cli.PrintErrln(ErrStashNotSupportedForOldFormat.Error())
return 1
+1 -1
View File
@@ -61,7 +61,7 @@ func (cmd StatusCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd StatusCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd StatusCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, _ := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, statusDocs, ap))
cli.ParseArgsOrDie(ap, args, help)
+1 -1
View File
@@ -71,7 +71,7 @@ func (cmd TagCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd TagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd TagCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cli.CreateTagArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tagDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
+2 -2
View File
@@ -70,7 +70,7 @@ func (cmd CpCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd CpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd CpCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblCpDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
@@ -94,5 +94,5 @@ func (cmd CpCmd) Exec(ctx context.Context, commandStr string, args []string, dEn
fmt.Sprintf("--%s", commands.BatchFlag),
fmt.Sprintf(`--%s`, commands.QueryFlag),
queryStr,
}, dEnv)
}, dEnv, nil)
}
+1 -1
View File
@@ -185,7 +185,7 @@ func (cmd ExportCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ExportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
_, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, exportDocs, ap))
+1 -1
View File
@@ -372,7 +372,7 @@ func (cmd ImportCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd ImportCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, importDocs, ap))
+2 -2
View File
@@ -72,7 +72,7 @@ func (cmd MvCmd) EventType() eventsapi.ClientEventType {
}
// Exec executes the command
func (cmd MvCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd MvCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblMvDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
@@ -95,5 +95,5 @@ func (cmd MvCmd) Exec(ctx context.Context, commandStr string, args []string, dEn
fmt.Sprintf("--%s", commands.BatchFlag),
fmt.Sprintf(`--%s`, commands.QueryFlag),
queryStr,
}, dEnv)
}, dEnv, nil)
}
+2 -2
View File
@@ -66,7 +66,7 @@ func (cmd RmCmd) ArgParser() *argparser.ArgParser {
}
// Exec executes the command
func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
ap := cmd.ArgParser()
help, usage := cli.HelpAndUsagePrinters(cli.CommandDocsForCommandString(commandStr, tblRmDocs, ap))
apr := cli.ParseArgsOrDie(ap, args, help)
@@ -93,5 +93,5 @@ func (cmd RmCmd) Exec(ctx context.Context, commandStr string, args []string, dEn
fmt.Sprintf("--%s", commands.BatchFlag),
fmt.Sprintf(`--%s`, commands.QueryFlag),
queryStr,
}, dEnv)
}, dEnv, nil)
}
+1 -1
View File
@@ -60,7 +60,7 @@ func (cmd VersionCmd) ArgParser() *argparser.ArgParser {
// Version displays the version of the running dolt client
// Exec executes the command
func (cmd VersionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv) int {
func (cmd VersionCmd) Exec(ctx context.Context, commandStr string, args []string, dEnv *env.DoltEnv, cliCtx cli.CliContext) int {
cli.Println("dolt version", cmd.VersionStr)
if dEnv.HasDoltDir() && dEnv.RSLoadErr == nil && !cli.CheckEnvIsValid(dEnv) {
+2 -2
View File
@@ -403,7 +403,7 @@ func runMain() int {
start := time.Now()
ctx, stop := context.WithCancel(ctx)
res := doltCommand.Exec(ctx, "dolt", args, dEnv)
res := doltCommand.Exec(ctx, "dolt", args, dEnv, nil)
stop()
if err = dbfactory.CloseAllLocalDatabases(); err != nil {
@@ -464,5 +464,5 @@ func interceptSendMetrics(ctx context.Context, args []string) (bool, int) {
return false, 0
}
dEnv := env.LoadWithoutDB(ctx, env.GetCurrentUserHomeDir, filesys.LocalFS, Version)
return true, doltCommand.Exec(ctx, "dolt", args, dEnv)
return true, doltCommand.Exec(ctx, "dolt", args, dEnv, nil)
}
@@ -58,7 +58,7 @@ func (cmd fvCommand) exec(ctx context.Context, dEnv *env.DoltEnv) int {
// execute the command using |cmd.user|'s Feature Version
doltdb.DoltFeatureVersion = cmd.user.vers
defer func() { doltdb.DoltFeatureVersion = DoltFeatureVersionCopy }()
return cmd.cmd.Exec(ctx, cmd.cmd.Name(), cmd.args, dEnv)
return cmd.cmd.Exec(ctx, cmd.cmd.Name(), cmd.args, dEnv, nil)
}
type fvUser struct {
@@ -49,13 +49,13 @@ func TestForeignKeyErrors(t *testing.T) {
dEnv := dtestutils.CreateTestEnv()
for _, c := range cmds {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
exitCode := commands.SqlCmd{}.Exec(ctx, commands.SqlCmd{}.Name(), []string{"-q", `ALTER TABLE test MODIFY v1 INT;`}, dEnv)
exitCode := commands.SqlCmd{}.Exec(ctx, commands.SqlCmd{}.Name(), []string{"-q", `ALTER TABLE test MODIFY v1 INT;`}, dEnv, nil)
require.Equal(t, 1, exitCode)
exitCode = commands.SqlCmd{}.Exec(ctx, commands.SqlCmd{}.Name(), []string{"-q", `ALTER TABLE test2 MODIFY v1 INT;`}, dEnv)
exitCode = commands.SqlCmd{}.Exec(ctx, commands.SqlCmd{}.Name(), []string{"-q", `ALTER TABLE test2 MODIFY v1 INT;`}, dEnv, nil)
require.Equal(t, 1, exitCode)
}
@@ -96,11 +96,11 @@ func testForeignKeys(t *testing.T, test foreignKeyTest) {
dEnv := dtestutils.CreateTestEnv()
for _, c := range fkSetupCommon {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
for _, c := range test.setup {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
+2 -2
View File
@@ -113,7 +113,7 @@ func testGarbageCollection(t *testing.T, test gcTest) {
defer dEnv.DoltDB.Close()
for _, c := range gcSetupCommon {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
@@ -121,7 +121,7 @@ func testGarbageCollection(t *testing.T, test gcTest) {
for _, stage := range test.stages {
res = stage.preStageFunc(ctx, t, dEnv.DoltDB, res)
for _, c := range stage.commands {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
}
+72 -18
View File
@@ -24,6 +24,7 @@ import (
"strings"
"time"
"github.com/google/uuid"
ps "github.com/mitchellh/go-ps"
goerrors "gopkg.in/src-d/go-errors.v1"
@@ -1195,8 +1196,21 @@ func (dEnv *DoltEnv) IsLocked() bool {
return FsIsLocked(dEnv.FS)
}
// DBLock is a struct that contains the pid of the process that created the lockfile and the port that the server is running on
// The secret is used by dolt to ensure that the contents of the lockfile are required to perform a local server connection
type DBLock struct {
Pid int
Port int
Secret string
}
// DBLock constructor
func NewDBLock(port int) DBLock {
return DBLock{Pid: os.Getpid(), Port: port, Secret: uuid.New().String()}
}
// Lock writes this database's lockfile with the pid of the calling process or errors if it already exists
func (dEnv *DoltEnv) Lock() error {
func (dEnv *DoltEnv) Lock(lock DBLock) error {
if dEnv.IgnoreLockFile {
return nil
}
@@ -1205,31 +1219,49 @@ func (dEnv *DoltEnv) Lock() error {
return ErrActiveServerLock.New(dEnv.LockFile())
}
return WriteLockfile(dEnv.FS)
return WriteLockfile(dEnv.FS, lock)
}
func getProcessFromLockFile(fs filesys.Filesys, lockFile string) (int, error) {
// validate that the pid on the lock file is still active
rd, err := fs.OpenForRead(lockFile)
func LoadDBLockFile(fs filesys.Filesys, lockFilePath string) (lock *DBLock, err error) {
rd, err := fs.OpenForRead(lockFilePath)
if err != nil {
return -1, err
return nil, err
}
// Technically, the max pid is bounded by int types (~32 bits). That gets
// encoded to about 11 bytes. We'll round about just in case.
b := make([]byte, 50)
b := make([]byte, 256)
n, err := rd.Read(b)
if err != nil {
return -1, err
return nil, err
}
data := strings.TrimSpace(string(b[:n]))
pid, err := strconv.Atoi(data)
if err != nil {
return -1, err
parts := strings.Split(data, ":")
if len(parts) == 1 {
// Legacy Lock file. We can remove this code path in a couple of months (6/2023)
pid, err := strconv.Atoi(parts[0])
if err != nil {
return nil, err
}
return &DBLock{Pid: pid, Port: -1, Secret: ""}, nil
}
if len(parts) != 3 {
return nil, fmt.Errorf("invalid lock file format")
}
return pid, nil
pid, err := strconv.Atoi(parts[0])
if err != nil {
return nil, err
}
port := -1
if parts[1] != "-" {
port, err = strconv.Atoi(parts[1])
if err != nil {
return nil, err
}
}
secret := parts[2]
return &DBLock{Pid: pid, Port: port, Secret: secret}, nil
}
// Unlock deletes this database's lockfile
@@ -1242,9 +1274,31 @@ func (dEnv *DoltEnv) Unlock() error {
}
// WriteLockfile writes a lockfile encoding the pid of the calling process.
func WriteLockfile(fs filesys.Filesys) error {
func WriteLockfile(fs filesys.Filesys, lock DBLock) error {
lockFile, _ := fs.Abs(filepath.Join(dbfactory.DoltDir, ServerLockFile))
return fs.WriteFile(lockFile, []byte(fmt.Sprintf("%d", os.Getpid())))
portStr := strconv.Itoa(lock.Port)
if lock.Port < 0 {
portStr = "-"
}
if filesys.LocalFS == fs {
_, err := os.Create(lockFile)
if err != nil {
return err
}
err = os.Chmod(lockFile, 0600)
if err != nil {
return err
}
}
err := fs.WriteFile(lockFile, []byte(fmt.Sprintf("%d:%s:%s", lock.Pid, portStr, lock.Secret)))
if err != nil {
return err
}
return nil
}
// FsIsLocked returns true if a lockFile exists with the same pid as
@@ -1257,13 +1311,13 @@ func FsIsLocked(fs filesys.Filesys) bool {
return false
}
lockFilePid, err := getProcessFromLockFile(fs, lockFile)
loadedLock, err := LoadDBLockFile(fs, lockFile)
if err != nil { // if there's any error assume that env is locked since the file exists
return true
}
// Check whether the pid that spawned the lock file is still running. Ignore it if not.
p, err := ps.FindProcess(lockFilePid)
p, err := ps.FindProcess(loadedLock.Pid)
if err != nil {
return false
}
+3 -4
View File
@@ -282,9 +282,9 @@ func (mrEnv *MultiRepoEnv) IsLocked() (bool, string) {
return false, ""
}
// Lock locks all child envs. If an error is returned, all
// Lock locks all child envs. The DBLock contains the details to write to the lock files. If an error is returned, all
// child envs will be returned with their initial lock state.
func (mrEnv *MultiRepoEnv) Lock() error {
func (mrEnv *MultiRepoEnv) Lock(lck DBLock) (err error) {
if mrEnv.ignoreLockFile {
return nil
}
@@ -293,9 +293,8 @@ func (mrEnv *MultiRepoEnv) Lock() error {
return ErrActiveServerLock.New(f)
}
var err error
for _, e := range mrEnv.envs {
err = e.env.Lock()
err = e.env.Lock(lck)
if err != nil {
mrEnv.Unlock()
return err
@@ -116,7 +116,7 @@ func TestKeylessMerge(t *testing.T) {
require.NoError(t, err)
for _, c := range test.setup {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
@@ -249,7 +249,7 @@ func TestKeylessMergeConflicts(t *testing.T) {
require.NoError(t, err)
for _, c := range cc {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
}
@@ -278,7 +278,7 @@ func TestKeylessMergeConflicts(t *testing.T) {
resolve := cnfcmds.ResolveCmd{}
args := []string{"--ours", tblName}
exitCode := resolve.Exec(ctx, resolve.Name(), args, dEnv)
exitCode := resolve.Exec(ctx, resolve.Name(), args, dEnv, nil)
require.Equal(t, 0, exitCode)
root, err := dEnv.WorkingRoot(ctx)
@@ -296,7 +296,7 @@ func TestKeylessMergeConflicts(t *testing.T) {
resolve := cnfcmds.ResolveCmd{}
args := []string{"--theirs", tblName}
exitCode := resolve.Exec(ctx, resolve.Name(), args, dEnv)
exitCode := resolve.Exec(ctx, resolve.Name(), args, dEnv, nil)
require.Equal(t, 0, exitCode)
root, err := dEnv.WorkingRoot(ctx)
+1 -1
View File
@@ -29,7 +29,7 @@ import (
var ErrFastForward = errors.New("fast forward")
var ErrTableDeletedAndModified = errors.New("conflict: table with same name deleted and modified ")
var ErrSchemaConflict = errors.New("schema conflict found, merge aborted. Please alter schema to prevent schema conflicts before merging")
var ErrSchemaConflict = goerrors.NewKind("schema conflict found, merge aborted. Please alter schema to prevent schema conflicts before merging: %s")
// ErrCantOverwriteConflicts is returned when there are unresolved conflicts
// and the merge produces new conflicts. Because we currently don't have a model
+2 -2
View File
@@ -128,8 +128,8 @@ func (rm *RootMerger) MergeTable(ctx context.Context, tblName string, opts edito
return nil, nil, err
}
if schConflicts.Count() != 0 {
// error on schema conflicts for now
return nil, nil, fmt.Errorf("%w.\n%s", ErrSchemaConflict, schConflicts.AsError().Error())
// error on any schema conflicts that we can't resolve
return nil, nil, ErrSchemaConflict.New(schConflicts.AsError().Error())
}
if types.IsFormat_DOLT(tm.vrw.Format()) {
+247 -76
View File
@@ -33,7 +33,7 @@ type conflictKind byte
const (
TagCollision conflictKind = iota
NameCollision
ColumnCollision
ColumnCheckCollision
InvalidCheckCollision
DeletedCheckCollision
)
@@ -104,7 +104,7 @@ func (c ChkConflict) String() string {
switch c.Kind {
case NameCollision:
return fmt.Sprintf("two checks with the name '%s' but different definitions", c.Ours.Name())
case ColumnCollision:
case ColumnCheckCollision:
return fmt.Sprintf("our check '%s' and their check '%s' both reference the same column(s)", c.Ours.Name(), c.Theirs.Name())
case InvalidCheckCollision:
return fmt.Sprintf("check '%s' references a column that will be deleted after merge", c.Ours.Name())
@@ -282,105 +282,276 @@ func ForeignKeysMerge(ctx context.Context, mergedRoot, ourRoot, theirRoot, ancRo
return common, conflicts, err
}
func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (merged *schema.ColCollection, conflicts []ColConflict, err error) {
var common *schema.ColCollection
common, conflicts = columnsInCommon(ourCC, theirCC, ancCC)
ourNewCols := schema.ColCollectionSetDifference(ourCC, ancCC)
theirNewCols := schema.ColCollectionSetDifference(theirCC, ancCC)
// check for name conflicts between columns added on each branch since the ancestor
_ = ourNewCols.Iter(func(tag uint64, ourCol schema.Column) (stop bool, err error) {
theirCol, ok := theirNewCols.GetByNameCaseInsensitive(ourCol.Name)
if ok && ourCol.Tag != theirCol.Tag {
conflicts = append(conflicts, ColConflict{
Kind: NameCollision,
Ours: ourCol,
Theirs: theirCol,
})
}
return false, nil
})
if len(conflicts) > 0 {
return nil, conflicts, nil
}
// order of args here is important for correct column ordering in sch schema
// to be before any column in the intersection
// TODO: sch column ordering doesn't respect sql "MODIFY ... AFTER ..." statements
merged, err = schema.ColCollUnion(common, ourNewCols, theirNewCols)
// mergeColumns merges the columns from |ourCC|, |theirCC| into a single column collection, using the ancestor column
// definitions in |ancCC| to determine on which side a column has changed. If merging is not possible because of
// conflicting changes to the columns in |ourCC| and |theirCC|, then a set of ColConflict instances are returned
// describing the conflicts. If any other, unexpected error occurs, then that error is returned and the other response
// fields should be ignored.
func mergeColumns(ourCC, theirCC, ancCC *schema.ColCollection) (*schema.ColCollection, []ColConflict, error) {
columnMappings, err := mapColumns(ourCC, theirCC, ancCC)
if err != nil {
return nil, nil, err
}
return merged, conflicts, nil
conflicts, err := checkSchemaConflicts(columnMappings)
if err != nil {
return nil, nil, err
}
// After we've checked for schema conflicts, merge the columns together
// TODO: We don't currently preserve all column position changes; the returned merged columns are always based on
// their position in |ourCC|, with any new columns from |theirCC| added at the end of the column collection.
var mergedColumns []schema.Column
for _, mapping := range columnMappings {
ours := mapping.ours
theirs := mapping.theirs
anc := mapping.anc
switch {
case anc == nil && ours == nil && theirs != nil:
// if an ancestor does not exist, and the column exists only on one side, use that side
// (if an ancestor DOES exist, this means the column was deleted, so it's a no-op)
mergedColumns = append(mergedColumns, *theirs)
case anc == nil && ours != nil && theirs == nil:
// if an ancestor does not exist, and the column exists only on one side, use that side
// (if an ancestor DOES exist, this means the column was deleted, so it's a no-op)
mergedColumns = append(mergedColumns, *ours)
case ours == nil && theirs == nil:
// if the column is deleted on both sides... just let it fall out
case ours != nil && theirs != nil:
// otherwise, we have two valid columns and we need to figure out which one to use
if anc != nil {
oursChanged := !anc.Equals(*ours)
theirsChanged := !anc.Equals(*theirs)
if oursChanged && theirsChanged {
// This is a schema change conflict and has already been handled by checkSchemaConflicts
} else if theirsChanged {
mergedColumns = append(mergedColumns, *theirs)
} else {
mergedColumns = append(mergedColumns, *ours)
}
} else if ours.Equals(*theirs) {
// if the columns are identical, just use ours
mergedColumns = append(mergedColumns, *ours)
}
}
}
// Check that there are no duplicate column names or tags in the merged column set
conflicts = append(conflicts, checkForColumnConflicts(mergedColumns)...)
if conflicts != nil {
return nil, conflicts, nil
}
return schema.NewColCollection(mergedColumns...), nil, nil
}
func columnsInCommon(ourCC, theirCC, ancCC *schema.ColCollection) (common *schema.ColCollection, conflicts []ColConflict) {
common = schema.NewColCollection()
_ = ourCC.Iter(func(tag uint64, ourCol schema.Column) (stop bool, err error) {
theirCol, ok := theirCC.GetByTag(ourCol.Tag)
if !ok {
return false, nil
}
// checkForColumnConflicts iterates over |mergedColumns|, checks for duplicate column names or column tags, and returns
// a slice of ColConflicts for any conflicts found.
func checkForColumnConflicts(mergedColumns []schema.Column) []ColConflict {
columnNameSet := map[string]schema.Column{}
columnTagSet := map[uint64]schema.Column{}
var conflicts []ColConflict
if ourCol.Equals(theirCol) {
common = common.Append(ourCol)
return false, nil
for _, col := range mergedColumns {
normalizedName := strings.ToLower(col.Name)
if _, ok := columnNameSet[normalizedName]; ok {
conflicts = append(conflicts, ColConflict{
Kind: NameCollision,
Ours: col,
Theirs: columnNameSet[normalizedName],
})
}
columnNameSet[normalizedName] = col
ancCol, ok := ancCC.GetByTag(ourCol.Tag)
if !ok {
// col added on our branch and their branch with different def
if _, ok := columnTagSet[col.Tag]; ok {
conflicts = append(conflicts, ColConflict{
Kind: TagCollision,
Ours: ourCol,
Theirs: theirCol,
Ours: col,
Theirs: columnTagSet[col.Tag],
})
return false, nil
}
columnTagSet[col.Tag] = col
}
if ancCol.Equals(theirCol) {
// col modified on our branch
col, ok := common.GetByNameCaseInsensitive(ourCol.Name)
if ok {
return conflicts
}
// checkSchemaConflicts iterates over |columnMappings| and returns any column schema conflicts from column changes
// that can't be automatically merged.
func checkSchemaConflicts(columnMappings columnMappings) ([]ColConflict, error) {
var conflicts []ColConflict
for _, mapping := range columnMappings {
ours := mapping.ours
theirs := mapping.theirs
anc := mapping.anc
// Column exists on our side
if ours != nil {
// If the column is identical on both sides, no need to check any more conflict cases,
// just move on to the next column
if theirs != nil && theirs.Equals(*ours) {
continue
}
switch {
case theirs == nil && anc != nil:
// Column doesn't exist on their side, but does exist in ancestor
// This means the column was deleted on theirs side
if !anc.Equals(*ours) {
// col altered on our branch and deleted on their branch
conflicts = append(conflicts, ColConflict{
Kind: NameCollision,
Ours: *ours,
})
}
case theirs != nil && anc != nil:
// Column exists on their side and in ancestor
// If the column differs from the ancestor on both sides, then we have a conflict
if !anc.Equals(*ours) && !anc.Equals(*theirs) {
conflicts = append(conflicts, ColConflict{
Kind: TagCollision,
Ours: *ours,
Theirs: *theirs,
})
}
case theirs != nil && anc == nil:
// Column exists on both sides, but not in ancestor
// col added on our branch and their branch with different def
conflicts = append(conflicts, ColConflict{
Kind: NameCollision,
Ours: ourCol,
Theirs: col,
Ours: *ours,
Theirs: *theirs,
})
} else {
common = common.Append(ourCol)
case theirs == nil && anc == nil:
// column doesn't exist on theirs or in anc no conflict
}
return false, nil
}
if ancCol.Equals(ourCol) {
// col modified on their branch
col, ok := common.GetByNameCaseInsensitive(theirCol.Name)
if ok {
conflicts = append(conflicts, ColConflict{
Kind: NameCollision,
Ours: col,
Theirs: theirCol,
})
} else {
common = common.Append(theirCol)
// Column does not exist on our side
if ours == nil {
switch {
case theirs == nil && anc != nil:
// Column doesn't exist on their side and our side, but does exist in ancestor
// deleted on both sides no conflict
case theirs != nil && anc != nil:
// Column exists on their side and in ancestor
// If ancs doesn't match theirs, the column was altered on both sides
if !anc.Equals(*theirs) {
// col deleted on our branch and altered on their branch
conflicts = append(conflicts, ColConflict{
Kind: NameCollision,
Theirs: *theirs,
})
}
case theirs != nil && anc == nil:
// Column exists only on theirs; no conflict
case theirs == nil && anc == nil:
// Invalid for anc, ours, and theirs should never happen
return nil, fmt.Errorf("invalid column mapping: %v", mapping)
}
return false, nil
}
}
return conflicts, nil
}
// columnMapping describes the mapping for a column being merged between the two sides of the merge as well as the ancestor.
type columnMapping struct {
anc *schema.Column
ours *schema.Column
theirs *schema.Column
}
// newColumnMapping returns a new columnMapping instance, populated with the specified columns. If |anc|, |ours|,
// or |theirs| is schema.InvalidColumn (checked by looking for schema.InvalidTag), then the returned mapping will
// hold a nil value instead of schema.InvalidColumn.
func newColumnMapping(anc, ours, theirs schema.Column) columnMapping {
var pAnc, pOurs, pTheirs *schema.Column
if anc.Tag != schema.InvalidTag {
pAnc = &anc
}
if ours.Tag != schema.InvalidTag {
pOurs = &ours
}
if theirs.Tag != schema.InvalidTag {
pTheirs = &theirs
}
return columnMapping{pAnc, pOurs, pTheirs}
}
type columnMappings []columnMapping
// DebugString returns a string representation of this columnMappings instance.
func (c columnMappings) DebugString() string {
sb := strings.Builder{}
sb.WriteString("Column Mappings:\n")
for _, mapping := range c {
if mapping.ours != nil {
sb.WriteString(fmt.Sprintf(" %s (%v) ", mapping.ours.Name, mapping.ours.Tag))
} else {
sb.WriteString(" --- ")
}
sb.WriteString(" -> ")
if mapping.theirs != nil {
sb.WriteString(fmt.Sprintf(" %s (%v) ", mapping.theirs.Name, mapping.theirs.Tag))
} else {
sb.WriteString(" --- ")
}
sb.WriteString(" -> ")
if mapping.anc != nil {
sb.WriteString(fmt.Sprintf(" %s (%v) ", mapping.anc.Name, mapping.anc.Tag))
} else {
sb.WriteString(" --- ")
}
sb.WriteString("\n")
}
return sb.String()
}
// mapColumns returns a columnMappings instance that describes how the columns in |ourCC|, |theirCC|, and |ancCC|
// map to each other.
func mapColumns(ourCC, theirCC, ancCC *schema.ColCollection) (columnMappings, error) {
// Make a copy of theirCC so we can modify it to track which their columns we've matched
theirCC = schema.NewColCollection(theirCC.GetColumns()...)
theirTagsToCols := theirCC.TagToCol
columnMappings := make(columnMappings, 0)
_ = ourCC.Iter(func(tag uint64, ourCol schema.Column) (stop bool, err error) {
theirCol, foundTheirByTag := theirCC.GetByTag(ourCol.Tag)
if !foundTheirByTag {
// If we didn't find a column on the other side of the merge that exactly matches this tag, then
// we fallback to looking for a match by name
theirCol, _ = theirCC.GetByNameCaseInsensitive(ourCol.Name)
}
// col modified on our branch and their branch with different def
conflicts = append(conflicts, ColConflict{
Kind: TagCollision,
Ours: ourCol,
Theirs: theirCol,
})
ancCol, foundAncByTag := ancCC.GetByTag(ourCol.Tag)
if !foundAncByTag {
// Ditto for finding the ancestor column
ancCol, _ = ancCC.GetByNameCaseInsensitive(ourCol.Name)
}
delete(theirTagsToCols, theirCol.Tag)
columnMappings = append(columnMappings, newColumnMapping(ancCol, ourCol, theirCol))
return false, nil
})
return common, conflicts
// Handle any remaining columns on the "their" side
for _, theirCol := range theirTagsToCols {
ancCol, foundAncByTag := ancCC.GetByTag(theirCol.Tag)
if !foundAncByTag {
// Ditto for finding the ancestor column
ancCol, _ = ancCC.GetByNameCaseInsensitive(theirCol.Name)
}
columnMappings = append(columnMappings, newColumnMapping(ancCol, schema.InvalidCol, theirCol))
}
return columnMappings, nil
}
// assumes indexes are unique over their column sets
@@ -839,7 +1010,7 @@ func mergeChecks(ctx context.Context, ourChks, theirChks, ancChks schema.CheckCo
if _, ok := theirNewChkColsMap[col][ourChk]; !ok {
for k := range theirNewChkColsMap[col] {
conflicts = append(conflicts, ChkConflict{
Kind: ColumnCollision,
Kind: ColumnCheckCollision,
Ours: ourChk,
Theirs: k,
})
@@ -40,7 +40,7 @@ type testCommand struct {
}
func (tc testCommand) exec(t *testing.T, ctx context.Context, dEnv *env.DoltEnv) {
exitCode := tc.cmd.Exec(ctx, tc.cmd.Name(), tc.args, dEnv)
exitCode := tc.cmd.Exec(ctx, tc.cmd.Name(), tc.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
@@ -290,13 +290,13 @@ var mergeSchemaConflictTests = []mergeSchemaConflictTest{
ColConflicts: []merge.ColConflict{
{
Kind: merge.NameCollision,
Ours: newColTypeInfo("c4", uint64(4696), typeinfo.Int32Type, false),
Theirs: newColTypeInfo("c4", uint64(8539), typeinfo.Int32Type, false),
Ours: newColTypeInfo("C6", uint64(13258), typeinfo.Int32Type, false),
Theirs: newColTypeInfo("c6", uint64(13258), typeinfo.Int32Type, false),
},
{
Kind: merge.NameCollision,
Ours: newColTypeInfo("C6", uint64(13258), typeinfo.Int32Type, false),
Theirs: newColTypeInfo("c6", uint64(13258), typeinfo.Int32Type, false),
Ours: newColTypeInfo("c4", uint64(4696), typeinfo.Int32Type, false),
Theirs: newColTypeInfo("c4", uint64(8539), typeinfo.Int32Type, false),
},
},
},
@@ -569,11 +569,11 @@ func testMergeSchemas(t *testing.T, test mergeSchemaTest) {
}
// assert that we're on main
exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv)
exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv, nil)
require.Equal(t, 0, exitCode)
// merge branches
exitCode = commands.MergeCmd{}.Exec(ctx, "merge", []string{"other"}, dEnv)
exitCode = commands.MergeCmd{}.Exec(ctx, "merge", []string{"other"}, dEnv, nil)
assert.Equal(t, 0, exitCode)
wr, err := dEnv.WorkingRoot(ctx)
@@ -615,12 +615,12 @@ func testMergeSchemasWithConflicts(t *testing.T, test mergeSchemaConflictTest) {
}
// assert that we're on main
exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv)
exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv, nil)
require.Equal(t, 0, exitCode)
mainSch := getSchema(t, dEnv)
exitCode = commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{"other"}, dEnv)
exitCode = commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{"other"}, dEnv, nil)
require.Equal(t, 0, exitCode)
otherSch := getSchema(t, dEnv)
@@ -671,14 +671,14 @@ func testMergeForeignKeys(t *testing.T, test mergeForeignKeyTest) {
}
// assert that we're on main
exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv)
exitCode := commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{env.DefaultInitBranch}, dEnv, nil)
require.Equal(t, 0, exitCode)
mainWS, err := dEnv.WorkingSet(ctx)
require.NoError(t, err)
mainRoot := mainWS.WorkingRoot()
exitCode = commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{"other"}, dEnv)
exitCode = commands.CheckoutCmd{}.Exec(ctx, "checkout", []string{"other"}, dEnv, nil)
require.Equal(t, 0, exitCode)
otherWS, err := dEnv.WorkingSet(ctx)
+105 -158
View File
@@ -36,13 +36,15 @@ import (
)
type schemaMergeTest struct {
name string
ancestor table
left, right table
merged table
conflict bool
skipNewFmt bool
skipOldFmt bool
name string
ancestor table
left, right table
merged table
conflict bool
skipNewFmt bool
skipOldFmt bool
skipFlipOnNewFormat bool
skipFlipOnOldFormat bool
}
type table struct {
@@ -104,20 +106,6 @@ var columnAddDropTests = []schemaMergeTest{
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
},
{
name: "right side column add",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
},
{
name: "right side column drop",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
},
// both sides change columns
{
name: "independent column adds",
@@ -178,28 +166,13 @@ var columnAddDropTests = []schemaMergeTest{
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, nil)),
},
{
name: "left side column drop, right side insert row",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, 22)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)),
skipNewFmt: true,
},
{
name: "right side column add, left side insert row",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, nil)),
},
{
name: "right side column drop, left side insert row",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, 22)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)),
skipNewFmt: true,
skipOldFmt: true,
name: "left side column drop, right side insert row",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int)"), row(1, 2), row(11, 22)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)),
skipNewFmt: true,
skipFlipOnOldFormat: true,
},
// both sides change columns and insert rows
{
@@ -269,20 +242,6 @@ var columnDefaultTests = []schemaMergeTest{
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")),
},
{
name: "right side add default",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")),
},
{
name: "right side drop default",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)")),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")),
},
{
name: "convergent add",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int) ")),
@@ -299,22 +258,14 @@ var columnDefaultTests = []schemaMergeTest{
},
// one side changes columns, the other inserts rows
{
// TODO: this test silently does the wrong thing without erroring
skipNewFmt: true,
skipOldFmt: true,
name: "left side column add, right side insert row",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)"), row(1, 42)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(12)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)"), row(1, 42), row(12, 42)),
skipNewFmt: true, // TODO: this test silently does the wrong thing without erroring
skipOldFmt: true,
},
{
name: "right side column add, left side insert row",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY) "), row(1), row(11)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)"), row(1, 42)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int DEFAULT 42)"), row(1, 42), row(11, 42)),
skipNewFmt: true, // TODO: this test silently does the wrong thing without erroring
skipOldFmt: true,
},
// both sides change columns and insert rows
{
@@ -345,13 +296,6 @@ var typeChangeTests = []schemaMergeTest{
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int, b int) "), row(1, 2, 3)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b int)"), row(1, "2", 3)),
},
{
name: "modify column type on the right side",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int, b int) "), row(1, 2, 3)),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int, b int) "), row(1, 2, 3)),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b int)"), row(1, "2", 3)),
merged: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b int)"), row(1, "2", 3)),
},
{
name: "independently modify column type on the both sides",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a int, b int) "), row(1, 2, 3)),
@@ -379,13 +323,6 @@ var keyChangeTests = []schemaMergeTest{
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
},
{
name: "add a trailing primary key column on right side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
},
{
name: "add a leading primary key column on left side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
@@ -394,26 +331,12 @@ var keyChangeTests = []schemaMergeTest{
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
},
{
name: "add a leading primary key column on right side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
},
{
name: "remove a trailing primary key column on left side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
},
{
name: "remove a trailing primary key column on right side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
skipNewFmt: true,
name: "remove a trailing primary key column on left side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a, b))"), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
skipFlipOnNewFormat: true,
},
{
name: "remove a trailing primary key column on both sides",
@@ -423,19 +346,12 @@ var keyChangeTests = []schemaMergeTest{
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
},
{
name: "remove a leading primary key column on left side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
},
{
name: "remove a leading primary key column on right side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
skipNewFmt: true,
name: "remove a leading primary key column on left side",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (b, a))"), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
skipFlipOnNewFormat: true,
},
{
name: "remove a leading primary key column on both sides",
@@ -445,20 +361,13 @@ var keyChangeTests = []schemaMergeTest{
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a)) "), row(1, "2", float32(3.0))),
},
{
name: "convert left side to a keyless table",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))),
},
{
name: "convert left side to a keyless table",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))),
skipNewFmt: true,
skipOldFmt: true,
skipFlipOnNewFormat: true,
skipFlipOnOldFormat: true,
name: "convert left side to a keyless table",
ancestor: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))),
left: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))),
right: tbl(sch("CREATE TABLE t (a int, b char(20), c float, PRIMARY KEY (a))"), row(1, "2", float32(3.0))),
merged: tbl(sch("CREATE TABLE t (a int, b char(20), c float) "), row(1, "2", float32(3.0))),
},
{
name: "convert both sides to keyless tables",
@@ -504,26 +413,45 @@ var simpleConflictTests = []schemaMergeTest{
conflict: true,
},
{
name: "conflicting index adds: same name and columns, different constraints",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (a)) ")),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, UNIQUE INDEX idx (a))")),
conflict: true,
// TODO: This test case does NOT generate a conflict; the merge gets short circuited, because the table's
// right/left/anc hashes are all the same. This is an issue with the test framework, not with Dolt.
// The code we use in these tests to create a schema (sqlutil.ParseCreateTableStatement) silently
// drops index and check constraint definitions.
skipNewFmt: true,
skipOldFmt: true,
name: "conflicting index adds: same name and columns, different constraints",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (a)) ")),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, UNIQUE INDEX idx (a))")),
conflict: true,
},
{
// TODO: This test case does NOT generate a conflict; the merge gets short circuited, because the table's
// right/left/anc hashes are all the same. This is an issue with the test framework, not with Dolt.
// The code we use in these tests to create a schema (sqlutil.ParseCreateTableStatement) silently
// drops index and check constraint definitions.
skipNewFmt: true,
skipOldFmt: true,
// TODO: multiple indexes can exist for the same column set, so this shouldn't actually be a conflict;
// Dolt does report this as a schema conflict today, but we could merge the two indexes together.
name: "conflicting index adds: same column different names",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX a_idx (a))")),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX key_a (a))")),
// todo: is it allowed to define multiple indexes over the same column?
conflict: true,
},
{
name: "conflicting index adds: same name different definitions",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (a))")),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (b))")),
conflict: true,
// TODO: This test case does NOT generate a conflict; the merge gets short circuited, because the table's
// right/left/anc hashes are all the same. This is an issue with the test framework, not with Dolt.
// The code we use in these tests to create a schema (sqlutil.ParseCreateTableStatement) silently
// drops index and check constraint definitions.
skipNewFmt: true,
skipOldFmt: true,
name: "conflicting index adds: same name different definitions",
ancestor: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float) ")),
left: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (a))")),
right: tbl(sch("CREATE TABLE t (id int PRIMARY KEY, a char(20), b float, INDEX idx (b))")),
conflict: true,
},
{
name: "add primary key columns at different key positions on left and right sides",
@@ -542,7 +470,22 @@ var simpleConflictTests = []schemaMergeTest{
}
func testSchemaMerge(t *testing.T, tests []schemaMergeTest) {
t.Run("merge left to right", func(t *testing.T) {
testSchemaMergeHelper(t, tests, false)
})
t.Run("merge right to left", func(t *testing.T) {
testSchemaMergeHelper(t, tests, true)
})
}
func testSchemaMergeHelper(t *testing.T, tests []schemaMergeTest, flipSides bool) {
for _, test := range tests {
if flipSides {
tmp := test.left
test.left = test.right
test.right = tmp
}
t.Run(test.name, func(t *testing.T) {
a, l, r, m := setupSchemaMergeTest(t, test)
@@ -552,18 +495,24 @@ func testSchemaMerge(t *testing.T, tests []schemaMergeTest) {
eo = eo.WithDeaf(editor.NewInMemDeaf(a.VRW()))
// attempt merge before skipping to assert no panics
root, _, err := merge.MergeRoots(ctx, l, r, a, rootish{r}, rootish{a}, eo, mo)
maybeSkip(t, a.VRW().Format(), test)
require.NoError(t, err)
exp, err := m.MapTableHashes(ctx)
assert.NoError(t, err)
act, err := root.MapTableHashes(ctx)
assert.NoError(t, err)
maybeSkip(t, a.VRW().Format(), test, flipSides)
assert.Equal(t, len(exp), len(act))
for name, addr := range exp {
a, ok := act[name]
assert.True(t, ok)
assert.Equal(t, addr, a)
if test.conflict {
// TODO: Test the conflict error message more deeply
require.Error(t, err)
} else {
require.NoError(t, err)
exp, err := m.MapTableHashes(ctx)
assert.NoError(t, err)
act, err := root.MapTableHashes(ctx)
assert.NoError(t, err)
assert.Equal(t, len(exp), len(act))
for name, addr := range exp {
a, ok := act[name]
assert.True(t, ok)
assert.Equal(t, addr, a)
}
}
})
}
@@ -586,16 +535,13 @@ func setupSchemaMergeTest(t *testing.T, test schemaMergeTest) (anc, left, right,
return
}
func maybeSkip(t *testing.T, nbf *types.NomsBinFormat, test schemaMergeTest) {
if test.conflict {
t.Skip("TODO: test conflict state")
}
func maybeSkip(t *testing.T, nbf *types.NomsBinFormat, test schemaMergeTest, flipSides bool) {
if types.IsFormat_DOLT(nbf) {
if test.skipNewFmt {
t.Skip("")
if test.skipNewFmt || flipSides && test.skipFlipOnNewFormat {
t.Skip()
}
} else {
if test.skipOldFmt {
if test.skipOldFmt || flipSides && test.skipFlipOnOldFormat {
t.Skip()
}
}
@@ -611,6 +557,7 @@ func sch(definition string) namedSchema {
ns := denv.DoltDB.NodeStore()
ctx := context.Background()
root, _ := doltdb.EmptyRootValue(ctx, vrw, ns)
// TODO: ParseCreateTableStatement silently drops any indexes or check constraints in the definition
name, s, err := sqlutil.ParseCreateTableStatement(ctx, root, definition)
if err != nil {
panic(err)
@@ -173,7 +173,7 @@ func setupMigrationTest(t *testing.T, ctx context.Context, test migrationTest) *
cmd := commands.SqlCmd{}
for _, query := range test.setup {
code := cmd.Exec(ctx, cmd.Name(), []string{"-q", query}, dEnv)
code := cmd.Exec(ctx, cmd.Name(), []string{"-q", query}, dEnv, nil)
require.Equal(t, 0, code)
}
return dEnv
@@ -203,7 +203,7 @@ func setupFilterBranchTests(t *testing.T) *env.DoltEnv {
ctx := context.Background()
dEnv := dtestutils.CreateTestEnv()
for _, c := range setupCommon {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
@@ -215,13 +215,13 @@ func testFilterBranch(t *testing.T, test filterBranchTest) {
dEnv := setupFilterBranchTests(t)
defer dEnv.DoltDB.Close()
for _, c := range test.setup {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
for _, a := range test.asserts {
for _, c := range a.setup {
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv)
exitCode := c.cmd.Exec(ctx, c.cmd.Name(), c.args, dEnv, nil)
require.Equal(t, 0, exitCode)
}
@@ -177,7 +177,7 @@ func runTestSql(t *testing.T, ctx context.Context, setup []string) (*doltdb.Dolt
dEnv := dtestutils.CreateTestEnv()
cmd := commands.SqlCmd{}
for _, query := range setup {
code := cmd.Exec(ctx, cmd.Name(), []string{"-q", query}, dEnv)
code := cmd.Exec(ctx, cmd.Name(), []string{"-q", query}, dEnv, nil)
require.Equal(t, 0, code)
}
root, err := dEnv.WorkingRoot(ctx)
@@ -26,7 +26,7 @@ import (
// persistReplicationConfiguration saves the specified |replicaSourceInfo| to disk; if any problems are encountered
// while saving to disk, an error is returned.
func persistReplicationConfiguration(ctx *sql.Context, replicaSourceInfo *mysql_db.ReplicaSourceInfo) error {
server := sqlserver.GetRunningServer()
server, _ := sqlserver.GetRunningServer()
if server == nil {
return fmt.Errorf("no SQL server running; " +
"replication commands may only be used when running from dolt sql-server, and not from dolt sql")
@@ -43,7 +43,7 @@ func persistReplicationConfiguration(ctx *sql.Context, replicaSourceInfo *mysql_
// loadReplicationConfiguration loads the replication configuration for default channel ("").
func loadReplicationConfiguration(_ *sql.Context) (*mysql_db.ReplicaSourceInfo, error) {
server := sqlserver.GetRunningServer()
server, _ := sqlserver.GetRunningServer()
if server == nil {
return nil, fmt.Errorf("no SQL server running; " +
"replication commands may only be used when running from dolt sql-server, and not from dolt sql")
@@ -66,7 +66,7 @@ func loadReplicationConfiguration(_ *sql.Context) (*mysql_db.ReplicaSourceInfo,
// deleteReplicationConfiguration deletes all replication configuration for the default channel ("").
func deleteReplicationConfiguration(ctx *sql.Context) error {
server := sqlserver.GetRunningServer()
server, _ := sqlserver.GetRunningServer()
if server == nil {
return fmt.Errorf("no SQL server running; " +
"replication commands may only be used when running from dolt sql-server, and not from dolt sql")
@@ -252,7 +252,7 @@ func (a *binlogReplicaApplier) startReplicationEventStream(ctx *sql.Context, con
// replicaBinlogEventHandler runs a loop, processing binlog events until the applier's stop replication channel
// receives a signal to stop.
func (a *binlogReplicaApplier) replicaBinlogEventHandler(ctx *sql.Context) error {
server := sqlserver.GetRunningServer()
server, _ := sqlserver.GetRunningServer()
if server == nil {
return fmt.Errorf("unable to access a running SQL server")
}
@@ -877,7 +877,7 @@ func convertVitessJsonExpressionString(ctx *sql.Context, value sqltypes.Value) (
return nil, err
}
server := sqlserver.GetRunningServer()
server, _ := sqlserver.GetRunningServer()
if server == nil {
return nil, fmt.Errorf("unable to access running SQL server")
}

Some files were not shown because too many files have changed in this diff Show More