Skip to content

Commit

Permalink
tls(dm): support init tls without client key/certs (#5393) (#5626)
Browse files Browse the repository at this point in the history
ref #5335, close #5391
  • Loading branch information
ti-chi-bot authored May 29, 2022
1 parent 8394e79 commit 8b7808f
Show file tree
Hide file tree
Showing 30 changed files with 901 additions and 990 deletions.
20 changes: 10 additions & 10 deletions cdc/entry/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,24 +247,24 @@ func unflatten(datum types.Datum, ft *types.FieldType, loc *time.Location) (type
if datum.IsNull() {
return datum, nil
}
switch ft.Tp {
switch ft.GetType() {
case mysql.TypeFloat:
datum.SetFloat32(float32(datum.GetFloat64()))
return datum, nil
case mysql.TypeVarchar, mysql.TypeString, mysql.TypeVarString, mysql.TypeTinyBlob,
mysql.TypeMediumBlob, mysql.TypeBlob, mysql.TypeLongBlob:
datum.SetString(datum.GetString(), ft.Collate)
datum.SetString(datum.GetString(), ft.GetCollate())
case mysql.TypeTiny, mysql.TypeShort, mysql.TypeYear, mysql.TypeInt24,
mysql.TypeLong, mysql.TypeLonglong, mysql.TypeDouble:
return datum, nil
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeTimestamp:
t := types.NewTime(types.ZeroCoreTime, ft.Tp, ft.Decimal)
t := types.NewTime(types.ZeroCoreTime, ft.GetType(), ft.GetDecimal())
var err error
err = t.FromPackedUint(datum.GetUint64())
if err != nil {
return datum, cerror.WrapError(cerror.ErrDatumUnflatten, err)
}
if ft.Tp == mysql.TypeTimestamp && !t.IsZero() {
if ft.GetType() == mysql.TypeTimestamp && !t.IsZero() {
err = t.ConvertTimeZone(time.UTC, loc)
if err != nil {
return datum, cerror.WrapError(cerror.ErrDatumUnflatten, err)
Expand All @@ -274,27 +274,27 @@ func unflatten(datum types.Datum, ft *types.FieldType, loc *time.Location) (type
datum.SetMysqlTime(t)
return datum, nil
case mysql.TypeDuration: // duration should read fsp from column meta data
dur := types.Duration{Duration: time.Duration(datum.GetInt64()), Fsp: ft.Decimal}
dur := types.Duration{Duration: time.Duration(datum.GetInt64()), Fsp: ft.GetDecimal()}
datum.SetMysqlDuration(dur)
return datum, nil
case mysql.TypeEnum:
// ignore error deliberately, to read empty enum value.
enum, err := types.ParseEnumValue(ft.Elems, datum.GetUint64())
enum, err := types.ParseEnumValue(ft.GetElems(), datum.GetUint64())
if err != nil {
enum = types.Enum{}
}
datum.SetMysqlEnum(enum, ft.Collate)
datum.SetMysqlEnum(enum, ft.GetCollate())
return datum, nil
case mysql.TypeSet:
set, err := types.ParseSetValue(ft.Elems, datum.GetUint64())
set, err := types.ParseSetValue(ft.GetElems(), datum.GetUint64())
if err != nil {
return datum, cerror.WrapError(cerror.ErrDatumUnflatten, err)
}
datum.SetMysqlSet(set, ft.Collate)
datum.SetMysqlSet(set, ft.GetCollate())
return datum, nil
case mysql.TypeBit:
val := datum.GetUint64()
byteSize := (ft.Flen + 7) >> 3
byteSize := (ft.GetFlen() + 7) >> 3
datum.SetUint64(0)
datum.SetMysqlBit(types.NewBinaryLiteralFromUint(val, byteSize))
}
Expand Down
14 changes: 7 additions & 7 deletions cdc/entry/mounter.go
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,8 @@ func datum2Column(tableInfo *model.TableInfo, datums map[int64]types.Datum, fill
colSize += size
cols[tableInfo.RowColumnsOffset[colInfo.ID]] = &model.Column{
Name: colName,
Type: colInfo.Tp,
Charset: colInfo.Charset,
Type: colInfo.GetType(),
Charset: colInfo.GetCharset(),
Value: colValue,
Default: defaultValue,
Flag: tableInfo.ColumnsFlag[colInfo.ID],
Expand Down Expand Up @@ -395,7 +395,7 @@ func formatColVal(datum types.Datum, col *timodel.ColumnInfo) (
if datum.IsNull() {
return nil, 0, "", nil
}
switch col.Tp {
switch col.GetType() {
case mysql.TypeDate, mysql.TypeDatetime, mysql.TypeNewDate, mysql.TypeTimestamp:
v := datum.GetMysqlTime().String()
return v, sizeOfString(v), "", nil
Expand Down Expand Up @@ -472,24 +472,24 @@ func getDefaultOrZeroValue(col *timodel.ColumnInfo) (interface{}, int, string, e
return d.GetValue(), sizeOfDatum(d), "", nil
}

if !mysql.HasNotNullFlag(col.Flag) {
if !mysql.HasNotNullFlag(col.GetFlag()) {
// NOTICE: NotNullCheck need do after OriginDefaultValue check, as when TiDB meet "amend + add column default xxx",
// ref: https://github.com/pingcap/ticdc/issues/3929
// must use null if TiDB not write the column value when default value is null
// and the value is null, see https://github.com/pingcap/tidb/issues/9304
d = types.NewDatum(nil)
} else {
switch col.Tp {
switch col.GetType() {
case mysql.TypeEnum:
// For enum type, if no default value and not null is set,
// the default value is the first element of the enum list
d = types.NewDatum(col.FieldType.Elems[0])
d = types.NewDatum(col.FieldType.GetElem(0))
case mysql.TypeString, mysql.TypeVarString, mysql.TypeVarchar:
return emptyBytes, sizeOfEmptyBytes, "", nil
default:
d = table.GetZeroValue(col)
if d.IsNull() {
log.Error("meet unsupported column type", zap.String("columnInfo", col.String()))
log.Error("meet unsupported column type", zap.String("columnInfo", col.FieldType.String()))
}
}
}
Expand Down
Loading

0 comments on commit 8b7808f

Please sign in to comment.