MCPcopy Create free account
hub / github.com/pingcap/tidb / writeDatum

Function writeDatum

pkg/ttl/sqlbuilder/sql.go:40–53  ·  view source on GitHub ↗
(restoreCtx *format.RestoreCtx, d types.Datum, ft *types.FieldType)

Source from the content-addressed store, hash-verified

38}
39
40func writeDatum(restoreCtx *format.RestoreCtx, d types.Datum, ft *types.FieldType) error {
41 switch ft.GetType() {
42 case mysql.TypeBit, mysql.TypeBlob, mysql.TypeLongBlob, mysql.TypeTinyBlob:
43 return writeHex(restoreCtx.In, d)
44 case mysql.TypeString, mysql.TypeVarString, mysql.TypeVarchar, mysql.TypeEnum, mysql.TypeSet:
45 if mysql.HasBinaryFlag(ft.GetFlag()) {
46 return writeHex(restoreCtx.In, d)
47 }
48 _, err := fmt.Fprintf(restoreCtx.In, "'%s'", sqlescape.EscapeString(d.GetString()))
49 return err
50 }
51 expr := ast.NewValueExpr(d.GetValue(), ft.GetCharset(), ft.GetCollate())
52 return expr.Restore(restoreCtx)
53}
54
55// FormatSQLDatum formats the datum to a value string in sql
56func FormatSQLDatum(d types.Datum, ft *types.FieldType) (string, error) {

Callers 2

FormatSQLDatumFunction · 0.85
writeDataPointMethod · 0.85

Calls 10

RestoreMethod · 0.95
HasBinaryFlagFunction · 0.92
EscapeStringFunction · 0.92
writeHexFunction · 0.85
GetTypeMethod · 0.65
GetFlagMethod · 0.65
GetStringMethod · 0.65
GetValueMethod · 0.65
GetCharsetMethod · 0.45
GetCollateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…