[Bug] Left() string function behaves not identically to the mysql implementation (#6811)

See Fix #6810
This commit is contained in:
tianhui5
2021-10-15 10:17:21 +08:00
committed by GitHub
parent 05e59f6487
commit 58440b90f0
2 changed files with 8 additions and 0 deletions

View File

@ -120,6 +120,7 @@ StringVal StringFunctions::substring(FunctionContext* context, const StringVal&
// string left(string input, int len)
// This behaves identically to the mysql implementation.
StringVal StringFunctions::left(FunctionContext* context, const StringVal& str, const IntVal& len) {
if (len.val >= str.len) return str;
return substring(context, str, 1, len);
}