Skip to content

Commit

Permalink
remove enumToTextMap in onlineddl/vrepl.go since rule.ConvertEnumToTe…
Browse files Browse the repository at this point in the history
…xt is no longer used

Signed-off-by: Shlomi Noach <2607934+shlomi-noach@users.noreply.github.com>
  • Loading branch information
shlomi-noach committed May 1, 2024
1 parent 53b4ab4 commit d2bfdae
Showing 1 changed file with 0 additions and 19 deletions.
19 changes: 0 additions & 19 deletions go/vt/vttablet/onlineddl/vrepl.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ type VRepl struct {

revertibleNotes string
filterQuery string
enumToTextMap map[string]string
intToEnumMap map[string]bool
bls *binlogdatapb.BinlogSource

Expand Down Expand Up @@ -168,7 +167,6 @@ func NewVRepl(
alterQuery: alterQuery,
analyzeTable: analyzeTable,
parser: vrepl.NewAlterTableParser(),
enumToTextMap: map[string]string{},
intToEnumMap: map[string]bool{},
convertCharset: map[string](*binlogdatapb.CharsetConversion){},
}
Expand Down Expand Up @@ -484,7 +482,6 @@ func (v *VRepl) analyzeTables(ctx context.Context, conn *dbconnpool.DBConnection
// that it's part of the PK, but it's still valid), and in that case we must have the string value
// to be able to DELETE the old row
v.targetSharedColumns.SetEnumToTextConversion(mappedColumn.Name, sourcePKColumn.EnumValues)
v.enumToTextMap[sourcePKColumn.Name] = sourcePKColumn.EnumValues
}
}

Expand All @@ -493,20 +490,7 @@ func (v *VRepl) analyzeTables(ctx context.Context, conn *dbconnpool.DBConnection
mappedColumn := v.targetSharedColumns.Columns()[i]
if sourceColumn.Type == vrepl.EnumColumnType {
switch {
// Either this is an ENUM column that stays an ENUM, or it is converted to a textual type.
// We take note of the enum values, and make it available in vreplication's Filter.Rule.ConvertEnumToText.
// This, in turn, will be used by vplayer (in TablePlan) like so:
// - In the binary log, enum values are integers.
// - Upon seeing this map, PlanBuilder will convert said int to the enum's logical string value.
// - And will apply the value as a string (`StringBindVariable`) in the query.
// What this allows is for enum values to have different ordering in the before/after table schema,
// so that for example you could modify an enum column:
// - from `('red', 'green', 'blue')` to `('red', 'blue')`
// - from `('red', 'green', 'blue')` to `('blue', 'red', 'green')`
case mappedColumn.Type == vrepl.EnumColumnType:
v.enumToTextMap[sourceColumn.Name] = sourceColumn.EnumValues
case mappedColumn.Charset != "":
v.enumToTextMap[sourceColumn.Name] = sourceColumn.EnumValues
v.targetSharedColumns.SetEnumToTextConversion(mappedColumn.Name, sourceColumn.EnumValues)
}
}
Expand Down Expand Up @@ -639,9 +623,6 @@ func (v *VRepl) analyzeBinlogSource(ctx context.Context) {
if len(v.convertCharset) > 0 {
rule.ConvertCharset = v.convertCharset
}
if len(v.enumToTextMap) > 0 {
rule.ConvertEnumToText = v.enumToTextMap
}
if len(v.intToEnumMap) > 0 {
rule.ConvertIntToEnum = v.intToEnumMap
}
Expand Down

0 comments on commit d2bfdae

Please sign in to comment.