diff --git a/utils/funcexp/func_insert.cpp b/utils/funcexp/func_insert.cpp index a869ef4bf..8e5864433 100644 --- a/utils/funcexp/func_insert.cpp +++ b/utils/funcexp/func_insert.cpp @@ -73,8 +73,6 @@ std::string Func_insert::getStrVal(rowgroup::Row& row, if (isNull) return ""; - start--; // Because SQL syntax is 1 based and we want 0 based. - CHARSET_INFO* cs = fp[0]->data()->resultType().getCharset(); // binLen represents the number of bytes @@ -91,6 +89,8 @@ std::string Func_insert::getStrVal(rowgroup::Row& row, if ((length < 0) || (length > strLen)) length = strLen; + start--; // Because SQL syntax is 1 based and we want 0 based. + // Convert start and length from characters to bytes. start = cs->charpos(pos, end, start); length = cs->charpos(pos+start, end, length);