executor: LOAD DATA INFILE support asterisk matching (#42050)

ref pingcap/tidb#40499
This commit is contained in:
lance6716
2023-03-13 13:50:39 +08:00
committed by GitHub
parent 34086a43e4
commit fd91259793
11 changed files with 419 additions and 135 deletions

View File

@ -406,3 +406,17 @@ func ConvertPosInUtf8(str *string, pos int64) int64 {
preStrNum := utf8.RuneCountInString(preStr)
return int64(preStrNum + 1)
}
// EscapeGlobExceptAsterisk escapes '?', '[', ']' for a glob path pattern.
func EscapeGlobExceptAsterisk(s string) string {
var buf strings.Builder
buf.Grow(len(s))
for _, c := range s {
switch c {
case '?', '[', ']':
buf.WriteByte('\\')
}
buf.WriteRune(c)
}
return buf.String()
}