MCPcopy
hub / github.com/XiaoMi/Gaea / appendSetVariable

Function appendSetVariable

backend/direct_connection.go:1068–1092  ·  view source on GitHub ↗
(buf *bytes.Buffer, key string, value interface{})

Source from the content-addressed store, hash-verified

1066}
1067
1068func appendSetVariable(buf *bytes.Buffer, key string, value interface{}) {
1069 if buf.Len() != 0 {
1070 buf.WriteString(",")
1071 } else {
1072 buf.WriteString("SET ")
1073 }
1074 buf.WriteString(key)
1075 buf.WriteString(" = ")
1076 switch v := value.(type) {
1077 case string:
1078 if strings.ToLower(v) == mysql.KeywordDefault || key == mysql.SQLModeStr {
1079 buf.WriteString(v)
1080 } else {
1081 buf.WriteString("'")
1082 buf.WriteString(v)
1083 buf.WriteString("'")
1084 }
1085 case int, int8, int16, int32, int64, uint, uint8, uint16, uint32, uint64:
1086 buf.WriteString(fmt.Sprintf("%d", v))
1087 default:
1088 buf.WriteString("'")
1089 buf.WriteString(fmt.Sprintf("%v", v))
1090 buf.WriteString("'")
1091 }
1092}
1093
1094func appendSetVariableToDefault(buf *bytes.Buffer, key string) {
1095 if buf.Len() != 0 {

Callers 3

WriteSetStatementMethod · 0.85
TestAppendSetVariableFunction · 0.85
TestAppendSetVariable2Function · 0.85

Calls 2

WriteStringMethod · 0.80
LenMethod · 0.45

Tested by 2

TestAppendSetVariableFunction · 0.68
TestAppendSetVariable2Function · 0.68