ddl: fix drop column args count for v1 (#58877)
close pingcap/tidb#58863
This commit is contained in:
@ -766,14 +766,21 @@ type TableColumnArgs struct {
|
||||
IgnoreExistenceErr bool `json:"ignore_existence_err,omitempty"`
|
||||
|
||||
// for drop column.
|
||||
// below 2 fields are filled during running.
|
||||
// below 2 fields are filled during running, and PartitionIDs is only effective
|
||||
// when len(IndexIDs) > 0.
|
||||
IndexIDs []int64 `json:"index_ids,omitempty"`
|
||||
PartitionIDs []int64 `json:"partition_ids,omitempty"`
|
||||
}
|
||||
|
||||
func (a *TableColumnArgs) getArgsV1(job *Job) []any {
|
||||
if job.Type == ActionDropColumn {
|
||||
return []any{a.Col.Name, a.IgnoreExistenceErr, a.IndexIDs, a.PartitionIDs}
|
||||
// if this job is submitted by new version node, but run with older version
|
||||
// node, older node will try to append args at runtime, so we check it here
|
||||
// to make sure the appended args can be decoded.
|
||||
if len(a.IndexIDs) > 0 {
|
||||
return []any{a.Col.Name, a.IgnoreExistenceErr, a.IndexIDs, a.PartitionIDs}
|
||||
}
|
||||
return []any{a.Col.Name, a.IgnoreExistenceErr}
|
||||
}
|
||||
return []any{a.Col, a.Pos, a.Offset, a.IgnoreExistenceErr}
|
||||
}
|
||||
|
||||
@ -904,7 +904,16 @@ func TestDropColumnArgs(t *testing.T) {
|
||||
args, err := GetTableColumnArgs(j2)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, inArgs, args)
|
||||
if v == JobVersion1 {
|
||||
require.Len(t, j2.args, 4)
|
||||
}
|
||||
}
|
||||
|
||||
j2 := &Job{}
|
||||
require.NoError(t, j2.Decode(getJobBytes(t, &TableColumnArgs{Col: &ColumnInfo{}}, JobVersion1, ActionDropColumn)))
|
||||
var rawArgs []json.RawMessage
|
||||
require.NoError(t, json.Unmarshal(j2.RawArgs, &rawArgs))
|
||||
require.Len(t, rawArgs, 2)
|
||||
}
|
||||
|
||||
func TestAddColumnArgs(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user