-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
ddl: refactor job args for set-default-value/add column ddl. #56337
Merged
ti-chi-bot
merged 15 commits into
pingcap:master
from
joccau:refactor-SetDefaultValue-bk
Sep 30, 2024
Merged
Changes from 2 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8337779
refactor job args for ActionSetDefaultValue
joccau 9a4153a
refactor the job args for add column ddl.
joccau 17e3006
fill dropColumn args into job when rollback the addColumn ddl
joccau 0a80bc0
merge addColumnArgs and droColumnArgs into tableColumnArgs
joccau b9170e5
Merge remote-tracking branch 'origin/master' into refactor-SetDefault…
joccau 319b08f
make build
joccau 8c727d9
Merge remote-tracking branch 'origin/master' into refactor-SetDefault…
joccau dcd4754
make bazel_build
joccau 986018f
Merge remote-tracking branch 'origin/master' into refactor-SetDefault…
joccau 286c3f5
Merge remote-tracking branch 'origin/master' into refactor-SetDefault…
joccau 616569b
modify code
joccau d894975
deal with comments
joccau d288e17
Merge remote-tracking branch 'origin/master' into refactor-SetDefault…
joccau d757372
update code
joccau 7fe2576
Merge remote-tracking branch 'upstream/master' into refactor-SetDefau…
D3Hunter 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 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 |
---|---|---|
|
@@ -1094,3 +1094,69 @@ func GetPlacementPolicyArgs(job *Job) (*PlacementPolicyArgs, error) { | |
|
||
return getOrDecodeArgsV2[*PlacementPolicyArgs](job) | ||
} | ||
|
||
// SetDefaultValueArgs is the argument for setting default value ddl. | ||
type SetDefaultValueArgs struct { | ||
Col *ColumnInfo `json:"column_info,omitempty"` | ||
} | ||
|
||
func (a *SetDefaultValueArgs) fillJob(job *Job) { | ||
if job.Version == JobVersion1 { | ||
job.Args = []any{a.Col} | ||
} else { | ||
job.Args = []any{a} | ||
} | ||
} | ||
|
||
// GetSetDefaultValueArgs get the args for setting default value ddl. | ||
func GetSetDefaultValueArgs(job *Job) (*SetDefaultValueArgs, error) { | ||
if job.Version == JobVersion1 { | ||
col := &ColumnInfo{} | ||
err := job.DecodeArgs(col) | ||
if err != nil { | ||
return nil, errors.Trace(err) | ||
} | ||
return &SetDefaultValueArgs{Col: col}, nil | ||
} | ||
|
||
return getOrDecodeArgsV2[*SetDefaultValueArgs](job) | ||
} | ||
|
||
// AddColumnArgs is the arguments for adding column ddl. | ||
type AddColumnArgs struct { | ||
joccau marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Col *ColumnInfo `json:"column_info,omitempty"` | ||
Pos *ast.ColumnPosition `json:"position,omitempty"` | ||
Offset int `json:"offset,omitempty"` | ||
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. Seems like |
||
IfNotExists bool `json:"if_not_exists,omitempty"` | ||
} | ||
|
||
func (a *AddColumnArgs) fillJob(job *Job) { | ||
if job.Version == JobVersion1 { | ||
job.Args = []any{a.Col, a.Pos, a.Offset, a.IfNotExists} | ||
} else { | ||
job.Args = []any{a} | ||
} | ||
} | ||
|
||
// GetAddColumnArgs gets the args for adding column ddl. | ||
func GetAddColumnArgs(job *Job) (*AddColumnArgs, error) { | ||
if job.Version == JobVersion1 { | ||
var ( | ||
col = &ColumnInfo{} | ||
pos = &ast.ColumnPosition{} | ||
offset = 0 | ||
ifNotExists = false | ||
) | ||
if err := job.DecodeArgs(col, pos, &offset, &ifNotExists); err != nil { | ||
return nil, errors.Trace(err) | ||
} | ||
return &AddColumnArgs{ | ||
Col: col, | ||
Pos: pos, | ||
Offset: offset, | ||
IfNotExists: ifNotExists, | ||
}, nil | ||
} | ||
|
||
return getOrDecodeArgsV2[*AddColumnArgs](job) | ||
} |
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.
Why do we still use
model.JobVersion1
?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.
multi schema change job types will handle together after they are all refactored
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.
Because the addColumn ddl will be added into multiSchemaChange ddl subjob. The jobVersion of multiSchemaChange is V1, the jobVersion of addColumn ddl is from multiSchemaChange.