diff --git a/server/handler/util.go b/server/handler/util.go index 3aac81e949802..9039eed667a21 100644 --- a/server/handler/util.go +++ b/server/handler/util.go @@ -17,7 +17,6 @@ package handler import ( "encoding/json" "net/http" - "strings" "github.com/pingcap/errors" "github.com/pingcap/tidb/parser/terror" @@ -52,12 +51,14 @@ const ( //revive:enable +// WriteError writes error to response. func WriteError(w http.ResponseWriter, err error) { w.WriteHeader(http.StatusBadRequest) _, err = w.Write([]byte(err.Error())) terror.Log(errors.Trace(err)) } +// WriteData writes data to response. func WriteData(w http.ResponseWriter, data interface{}) { js, err := json.MarshalIndent(data, "", " ") if err != nil { @@ -70,18 +71,3 @@ func WriteData(w http.ResponseWriter, data interface{}) { _, err = w.Write(js) terror.Log(errors.Trace(err)) } - -// ExtractTableAndPartitionName extracts table name and partition name from a string. -func ExtractTableAndPartitionName(str string) (string, string) { - // extract table name and partition name from this "table(partition)": - // A sane person would not let the the table name or partition name contain '('. - start := strings.IndexByte(str, '(') - if start == -1 { - return str, "" - } - end := strings.IndexByte(str, ')') - if end == -1 { - return str, "" - } - return str[:start], str[start+1 : end] -}