-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
bugfix: change column name and type to json #14093
Merged
mattlord
merged 4 commits into
vitessio:main
from
HubSpot:fix-onlineddl-change-col-json
Sep 28, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions
1
go/test/endtoend/onlineddl/vrepl_suite/testdata/rename-retype-json/after_columns
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 @@ | ||
id, c1j |
1 change: 1 addition & 0 deletions
1
go/test/endtoend/onlineddl/vrepl_suite/testdata/rename-retype-json/alter
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 @@ | ||
change column c1 c1j json |
1 change: 1 addition & 0 deletions
1
go/test/endtoend/onlineddl/vrepl_suite/testdata/rename-retype-json/before_columns
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 @@ | ||
id, c1 |
22 changes: 22 additions & 0 deletions
22
go/test/endtoend/onlineddl/vrepl_suite/testdata/rename-retype-json/create.sql
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,22 @@ | ||
drop table if exists onlineddl_test; | ||
create table onlineddl_test ( | ||
id int auto_increment, | ||
c1 int not null, | ||
primary key (id) | ||
) auto_increment=1; | ||
|
||
insert into onlineddl_test values (1, 11); | ||
insert into onlineddl_test values (2, 13); | ||
|
||
drop event if exists onlineddl_test; | ||
delimiter ;; | ||
create event onlineddl_test | ||
on schedule every 1 second | ||
starts current_timestamp | ||
ends current_timestamp + interval 60 second | ||
on completion not preserve | ||
enable | ||
do | ||
begin | ||
insert into onlineddl_test values (null, 17); | ||
end ;; |
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 |
---|---|---|
|
@@ -727,7 +727,26 @@ func (plan *Plan) analyzeExpr(vschema *localVSchema, selExpr sqlparser.SelectExp | |
FixedValue: sqltypes.NewInt64(num), | ||
}, nil | ||
case *sqlparser.ConvertUsingExpr: | ||
colnum, err := findColumn(plan.Table, aliased.As) | ||
// Here we find the actual column name in the convert, in case | ||
// this is a column rename and the AS is the new column. | ||
// For example, in convert(c1 using utf8mb4) as c2, we want to find | ||
// c1, because c1 exists in the current table whereas c2 is the renamed column | ||
// in the desired table. | ||
var colName sqlparser.IdentifierCI | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similarly please add a comment here as well. |
||
err := sqlparser.Walk(func(node sqlparser.SQLNode) (kontinue bool, err error) { | ||
switch node := node.(type) { | ||
case *sqlparser.ColName: | ||
if !node.Qualifier.IsEmpty() { | ||
return false, fmt.Errorf("unsupported qualifier for column: %v", sqlparser.String(node)) | ||
} | ||
colName = node.Name | ||
} | ||
return true, nil | ||
}, aliased.Expr) | ||
if err != nil { | ||
return ColExpr{}, fmt.Errorf("failed to find column name for convert using expression: %v, %v", sqlparser.String(aliased.Expr), err) | ||
} | ||
colnum, err := findColumn(plan.Table, colName) | ||
if err != nil { | ||
return ColExpr{}, err | ||
} | ||
|
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a comment here (a short paragraph) explaining why the following code is necessary.