forked from vitessio/vitess
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
vexec for schema-migrations, major refactor
Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
- Loading branch information
1 parent
a237ba0
commit c22146e
Showing
21 changed files
with
635 additions
and
284 deletions.
There are no files selected for viewing
367 changes: 224 additions & 143 deletions
367
go/vt/proto/tabletmanagerdata/tabletmanagerdata.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
181 changes: 110 additions & 71 deletions
181
go/vt/proto/tabletmanagerservice/tabletmanagerservice.pb.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
Copyright 2019 The Vitess Authors. | ||
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 tabletmanager | ||
|
||
import ( | ||
"fmt" | ||
|
||
querypb "vitess.io/vitess/go/vt/proto/query" | ||
"vitess.io/vitess/go/vt/sqlparser" | ||
"vitess.io/vitess/go/vt/vttablet/onlineddl" | ||
|
||
"golang.org/x/net/context" | ||
) | ||
|
||
func (tm *TabletManager) extractTableName(stmt sqlparser.Statement) (string, error) { | ||
switch stmt := stmt.(type) { | ||
case *sqlparser.Update: | ||
return sqlparser.String(stmt.TableExprs), nil | ||
case *sqlparser.Delete: | ||
return sqlparser.String(stmt.TableExprs), nil | ||
case *sqlparser.Select: | ||
return sqlparser.String(stmt.From), nil | ||
} | ||
return "", fmt.Errorf("query not supported by vexec: %+v", sqlparser.String(stmt)) | ||
} | ||
|
||
// VExec executes a generic VExec command. | ||
func (tm *TabletManager) VExec(ctx context.Context, query string) (*querypb.QueryResult, error) { | ||
stmt, err := sqlparser.Parse(query) | ||
if err != nil { | ||
return nil, err | ||
} | ||
tableName, err := tm.extractTableName(stmt) | ||
if err != nil { | ||
return nil, err | ||
} | ||
// TODO(shlomi) do something here!!! | ||
fmt.Printf("======= VExec query: %x, table: %s \n", query, tableName) | ||
switch tableName { | ||
case onlineddl.SchemaMigrationsTableName: | ||
return tm.QueryServiceControl.OnlineDDLExecutor().VExec(ctx, query, stmt) | ||
default: | ||
return nil, fmt.Errorf("table not supported by vexec: %v", tableName) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.