ddl: fix drop column args count for v1 (#58877)

close pingcap/tidb#58863
This commit is contained in:
D3Hunter
2025-01-14 12:26:28 +08:00
committed by GitHub
parent ea5beb8a37
commit 4094726531
2 changed files with 18 additions and 2 deletions

View File

@ -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}
}

View File

@ -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) {