-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Online DDL: support 'SHOW VITESS_MIGRATIONS' queries #7638
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
shlomi-noach
merged 26 commits into
vitessio:master
from
planetscale:online-ddl-sql-interface
Mar 10, 2021
Merged
Changes from 17 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
c8d4d4b
Online DDL: support 'SHOW VITESS_MIGRATIONS' queries
shlomi-noach 823d1dc
fulklk parse for 'show vitess_migrations'
shlomi-noach 0b5adde
parser & ast: use ShowBasic instead of ShowLegacy for vitess_migrations
systay ae739f4
use vtgate 'SHOW VITESS_MIGRATIONS'
shlomi-noach 1d112ab
added FROM and build engine primitive
systay 2ddaeb2
Merge branch 'online-ddl-sql-interface' of github.com:planetscale/vit…
systay aab5701
add executor test for show vitess_migrations
systay 7d00e70
use send primitive for show vitess_migrations
harshit-gangal 606807b
fix test setup to use sharded keyspace
harshit-gangal a9a7ee6
stricter SHOW VITESS_MIGRATONS query; formatting improvements
shlomi-noach dad0e47
endtoend online ddl gh-ost tests: fixed sharded keyspace
shlomi-noach 237e223
fixed unit test
shlomi-noach 3896ca8
endtoend online ddl revert tests: using SHOW VITESS_MIGRATIONS
shlomi-noach a420c31
endtoend online ddl stress tests: using SHOW VITESS_MIGRATIONS
shlomi-noach 7227937
refactor: consolidate utility functions
shlomi-noach 4bffce9
fixed vtgate unit test
shlomi-noach 3d570ec
fixed test number of shards
shlomi-noach b2788bd
fixed per review
shlomi-noach fc66891
remove unneeded code
shlomi-noach b0282e3
added go/test/endtoend/onlineddl
shlomi-noach a328a49
general purpose testing package for online-ddl tests
shlomi-noach b228da2
correct package name
shlomi-noach c90ec62
use new shared package
shlomi-noach 38bdc9c
restructure directories
shlomi-noach 86ad32a
rename package names
shlomi-noach cea6361
update paths
shlomi-noach File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,61 @@ | ||
| /* | ||
| 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 cluster | ||
|
|
||
| import ( | ||
| "io" | ||
| "strings" | ||
|
|
||
| "vitess.io/vitess/go/sqltypes" | ||
|
|
||
| "github.com/olekukonko/tablewriter" | ||
| ) | ||
|
|
||
| // printQueryResult will pretty-print a QueryResult to the logger. | ||
|
shlomi-noach marked this conversation as resolved.
Outdated
|
||
| func PrintQueryResult(writer io.Writer, qr *sqltypes.Result) { | ||
| if qr == nil { | ||
| return | ||
| } | ||
| if len(qr.Rows) == 0 { | ||
| return | ||
| } | ||
|
|
||
| table := tablewriter.NewWriter(writer) | ||
| table.SetAutoFormatHeaders(false) | ||
|
|
||
| // Make header. | ||
| header := make([]string, 0, len(qr.Fields)) | ||
| for _, field := range qr.Fields { | ||
| header = append(header, field.Name) | ||
| } | ||
| table.SetHeader(header) | ||
|
|
||
| // Add rows. | ||
| for _, row := range qr.Rows { | ||
| vals := make([]string, 0, len(row)) | ||
| for _, val := range row { | ||
| v := val.ToString() | ||
| v = strings.ReplaceAll(v, "\r", " ") | ||
| v = strings.ReplaceAll(v, "\n", " ") | ||
| vals = append(vals, v) | ||
| } | ||
| table.Append(vals) | ||
| } | ||
|
|
||
| // Print table. | ||
| table.Render() | ||
| } | ||
This file contains hidden or 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,47 @@ | ||
| /* | ||
| Copyright 2019 The Vitess Authors. | ||
|
shlomi-noach marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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 cluster | ||
|
|
||
| import ( | ||
| "context" | ||
| "testing" | ||
|
|
||
| "vitess.io/vitess/go/mysql" | ||
| "vitess.io/vitess/go/sqltypes" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| "github.com/stretchr/testify/require" | ||
| ) | ||
|
|
||
| // VtgateExecQuery runs a query on VTGate using given query params | ||
| func VtgateExecQuery(t *testing.T, vtParams *mysql.ConnParams, query string, expectError string) *sqltypes.Result { | ||
| t.Helper() | ||
|
|
||
| ctx := context.Background() | ||
| conn, err := mysql.Connect(ctx, vtParams) | ||
| require.Nil(t, err) | ||
| defer conn.Close() | ||
|
|
||
| qr, err := conn.ExecuteFetch(query, 1000, true) | ||
| if expectError == "" { | ||
| require.NoError(t, err) | ||
| } else { | ||
| require.Error(t, err, "error should not be nil") | ||
| assert.Contains(t, err.Error(), expectError, "Unexpected error") | ||
| } | ||
| return qr | ||
| } | ||
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.