diff --git a/utils/common/collation.h b/utils/common/collation.h index 954141ba5..e5781b8d9 100644 --- a/utils/common/collation.h +++ b/utils/common/collation.h @@ -147,20 +147,25 @@ class Charset { } - bool operator==(const Charset& rhs) + bool operator==(const Charset& rhs) const { - return rhs.getCharset().cs_name.str == getCharset().cs_name.str; + return rhs.getCharset().cs_name.str == getCharset().cs_name.str; + } + + bool operator!=(const Charset& rhs) const + { + return !(*this == rhs); } std::string convert(const std::string& from, const datatypes::Charset& fromCs) const { - std::string result; - uint dummy_errors; - result.resize(from.size() * getCharset().mbmaxlen); - size_t resultingSize = my_convert(const_cast(result.c_str()), result.size(), &getCharset(), from.c_str(), - from.size(), &fromCs.getCharset(), &dummy_errors); - result.resize(resultingSize); - return result; + std::string result; + uint dummy_errors; + result.resize(from.size() * getCharset().mbmaxlen); + size_t resultingSize = my_convert(const_cast(result.c_str()), result.size(), &getCharset(), + from.c_str(), from.size(), &fromCs.getCharset(), &dummy_errors); + result.resize(resultingSize); + return result; } Charset(uint32_t charsetNumber); @@ -187,7 +192,7 @@ class Charset // please note that ConstString has an assertion so that nullptr data has zero length. const char* s1 = str1.str(); const char* s2 = str2.str(); - return mCharset->strnncollsp(s1 ? s1 : "", str1.length(), s2 ? s2 : "" , str2.length()); + return mCharset->strnncollsp(s1 ? s1 : "", str1.length(), s2 ? s2 : "", str2.length()); } int strnncollsp(const char* str1, size_t length1, const char* str2, size_t length2) const { diff --git a/utils/funcexp/func_regexp.cpp b/utils/funcexp/func_regexp.cpp index d21275c9e..4404d7650 100644 --- a/utils/funcexp/func_regexp.cpp +++ b/utils/funcexp/func_regexp.cpp @@ -60,18 +60,19 @@ struct PCREOptions PCREOptions::PCREOptions(execplan::CalpontSystemCatalog::ColType& ct) { datatypes::Charset cs = ct.getCharset(); + datatypes::Charset myCharsetBin = my_charset_bin; // TODO use system variable instead if hardcode default_regex_flags_pcre(_current_thd()); // PCRE2_DOTALL | PCRE2_DUPNAMES | PCRE2_EXTENDED | PCRE2_EXTENDED_MORE | PCRE2_MULTILINE | PCRE2_UNGREEDY; jpcre2::Uint defaultFlags = 0; - flags = (cs != &my_charset_bin ? (PCRE2_UTF | PCRE2_UCP) : 0) | + flags = (cs != myCharsetBin ? (PCRE2_UTF | PCRE2_UCP) : 0) | ((cs.getCharset().state & (MY_CS_BINSORT | MY_CS_CSSORT)) ? 0 : PCRE2_CASELESS) | defaultFlags; // Convert text data to utf-8. dataCharset = cs; - libraryCharset = cs == my_charset_bin ? my_charset_bin : my_charset_utf8mb3_general_ci; + libraryCharset = cs == myCharsetBin ? my_charset_bin : my_charset_utf8mb3_general_ci; } struct RegExpParams