diff --git a/bindinfo/bind_test.go b/bindinfo/bind_test.go index e0e1e37b72015..7394c5efa98d6 100644 --- a/bindinfo/bind_test.go +++ b/bindinfo/bind_test.go @@ -134,6 +134,11 @@ func (s *testSuite) TestBindParse(c *C) { c.Check(bindData.Collation, Equals, "utf8mb4_bin") c.Check(bindData.CreateTime, NotNil) c.Check(bindData.UpdateTime, NotNil) + + // Test fields with quotes or slashes. + sql = `CREATE GLOBAL BINDING FOR select * from t where a BETWEEN "a" and "b" USING select * from t use index(idx) where a BETWEEN "a\nb\rc\td\0e" and "x"` + tk.MustExec(sql) + tk.MustExec(`DROP global binding for select * from t use index(idx) where a BETWEEN "a\nb\rc\td\0e" and "x"`) } func (s *testSuite) TestGlobalBinding(c *C) { diff --git a/bindinfo/handle.go b/bindinfo/handle.go index 5314dbb7a7053..b6978dcf7d5db 100644 --- a/bindinfo/handle.go +++ b/bindinfo/handle.go @@ -14,7 +14,6 @@ package bindinfo import ( - "bytes" "context" "fmt" "go.uber.org/zap" @@ -188,7 +187,6 @@ func (h *BindHandle) AddBindRecord(record *BindRecord) (err error) { } record.UpdateTime = record.CreateTime record.Status = Using - record.BindSQL = h.getEscapeCharacter(record.BindSQL) // insert the BindRecord to the storage. _, err = exec.Execute(context.TODO(), h.insertBindInfoSQL(record)) @@ -446,14 +444,3 @@ func (h *BindHandle) logicalDeleteBindInfoSQL(normdOrigSQL, db string, updateTs normdOrigSQL, db) } - -func (h *BindHandle) getEscapeCharacter(str string) string { - var buffer bytes.Buffer - for _, v := range str { - if v == '\'' || v == '"' || v == '\\' { - buffer.WriteString("\\") - } - buffer.WriteString(string(v)) - } - return buffer.String() -}