diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-02-01 20:33:04 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-02-01 20:33:04 +0100 |
commit | cf63eecef44f189ce2d221612dee9dfc1885ba4e (patch) | |
tree | 93b4e6645a1d371bd8012a0aa8e6e3a3d541b2a6 /sql/item_strfunc.cc | |
parent | fb40a2fabf8d8cf765c83a0b8e609dd893c75ec3 (diff) | |
parent | c04a203a10e282e1f33fd04d8a1b7ff0b076bce5 (diff) | |
download | mariadb-git-cf63eecef44f189ce2d221612dee9dfc1885ba4e.tar.gz |
Merge branch '10.4' into 10.5
Diffstat (limited to 'sql/item_strfunc.cc')
-rw-r--r-- | sql/item_strfunc.cc | 54 |
1 files changed, 28 insertions, 26 deletions
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index e7abb51893c..0635556be40 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -734,7 +734,7 @@ String *Item_func_des_encrypt::val_str(String *str) if ((null_value= args[0]->null_value)) return 0; // ENCRYPT(NULL) == NULL if ((res_length=res->length()) == 0) - return make_empty_result(); + return make_empty_result(str); if (arg_count == 1) { /* Protect against someone doing FLUSH DES_KEY_FILE */ @@ -937,7 +937,7 @@ String *Item_func_concat_ws::val_str(String *str) } if (i == arg_count) - return make_empty_result(); + return make_empty_result(str); for (i++; i < arg_count ; i++) { @@ -1088,7 +1088,7 @@ String *Item_func_reverse::val_str(String *str) return 0; /* An empty string is a special case as the string pointer may be null */ if (!res->length()) - return make_empty_result(); + return make_empty_result(str); if (str->alloc(res->length())) { null_value= 1; @@ -1626,7 +1626,7 @@ String *Item_func_left::val_str(String *str) /* if "unsigned_flag" is set, we have a *huge* positive number. */ if ((length <= 0) && (!args[1]->unsigned_flag)) - return make_empty_result(); + return make_empty_result(str); if ((res->length() <= (ulonglong) length) || (res->length() <= (char_pos= res->charpos((int) length)))) return res; @@ -1670,7 +1670,7 @@ String *Item_func_right::val_str(String *str) /* if "unsigned_flag" is set, we have a *huge* positive number. */ if ((length <= 0) && (!args[1]->unsigned_flag)) - return make_empty_result(); /* purecov: inspected */ + return make_empty_result(str); /* purecov: inspected */ if (res->length() <= (ulonglong) length) return res; /* purecov: inspected */ @@ -1712,7 +1712,7 @@ String *Item_func_substr::val_str(String *str) /* Negative or zero length, will return empty string. */ if ((arg_count == 3) && (length <= 0) && (length == 0 || !args[2]->unsigned_flag)) - return make_empty_result(); + return make_empty_result(str); /* Assumes that the maximum length of a String is < INT_MAX32. */ /* Set here so that rest of code sees out-of-bound value as such. */ @@ -1723,12 +1723,12 @@ String *Item_func_substr::val_str(String *str) /* Assumes that the maximum length of a String is < INT_MAX32. */ if ((!args[1]->unsigned_flag && (start < INT_MIN32 || start > INT_MAX32)) || (args[1]->unsigned_flag && ((ulonglong) start > INT_MAX32))) - return make_empty_result(); + return make_empty_result(str); start= ((start < 0) ? res->numchars() + start : start - 1); start= res->charpos((int) start); if ((start < 0) || ((uint) start + 1 > res->length())) - return make_empty_result(); + return make_empty_result(str); length= res->charpos((int) length, (uint32) start); tmp_length= res->length() - start; @@ -1798,7 +1798,7 @@ String *Item_func_substr_index::val_str(String *str) null_value=0; uint delimiter_length= delimiter->length(); if (!res->length() || !delimiter_length || !count) - return make_empty_result(); // Wrong parameters + return make_empty_result(str); // Wrong parameters res->set_charset(collation.collation); @@ -2208,7 +2208,7 @@ String *Item_func_password::val_str_ascii(String *str) switch (alg){ case NEW: if (args[0]->null_value || res->length() == 0) - return make_empty_result(); + return make_empty_result(str); my_make_scrambled_password(tmp_value, res->ptr(), res->length()); str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH, &my_charset_latin1); break; @@ -2216,7 +2216,7 @@ String *Item_func_password::val_str_ascii(String *str) if ((null_value=args[0]->null_value)) return 0; if (res->length() == 0) - return make_empty_result(); + return make_empty_result(str); my_make_scrambled_password_323(tmp_value, res->ptr(), res->length()); str->set(tmp_value, SCRAMBLED_PASSWORD_CHAR_LENGTH_323, &my_charset_latin1); break; @@ -2255,13 +2255,15 @@ char *Item_func_password::alloc(THD *thd, const char *password, String *Item_func_encrypt::val_str(String *str) { DBUG_ASSERT(fixed == 1); + #ifdef HAVE_CRYPT String *res =args[0]->val_str(str); + char salt[3],*salt_ptr; if ((null_value=args[0]->null_value)) return 0; if (res->length() == 0) - return make_empty_result(); + return make_empty_result(str); if (arg_count == 1) { // generate random salt time_t timestamp=current_thd->query_start(); @@ -2556,8 +2558,8 @@ String *Item_func_soundex::val_str(String *str) for ( ; ; ) /* Skip pre-space */ { if ((rc= cs->mb_wc(&wc, (uchar*) from, (uchar*) end)) <= 0) - return make_empty_result(); /* EOL or invalid byte sequence */ - + return make_empty_result(str); /* EOL or invalid byte sequence */ + if (rc == 1 && cs->m_ctype) { /* Single byte letter found */ @@ -2581,7 +2583,7 @@ String *Item_func_soundex::val_str(String *str) { /* Extra safety - should not really happen */ DBUG_ASSERT(false); - return make_empty_result(); + return make_empty_result(str); } to+= rc; break; @@ -2882,7 +2884,7 @@ String *Item_func_make_set::val_str(String *str) ulonglong bits; bool first_found=0; Item **ptr=args+1; - String *result= make_empty_result(); + String *result= make_empty_result(str); bits=args[0]->val_int(); if ((null_value=args[0]->null_value)) @@ -2906,7 +2908,7 @@ String *Item_func_make_set::val_str(String *str) else { if (tmp_str.copy(*res)) // Don't use 'str' - return make_empty_result(); + return make_empty_result(str); result= &tmp_str; } } @@ -2916,11 +2918,11 @@ String *Item_func_make_set::val_str(String *str) { // Copy data to tmp_str if (tmp_str.alloc(result->length()+res->length()+1) || tmp_str.copy(*result)) - return make_empty_result(); + return make_empty_result(str); result= &tmp_str; } if (tmp_str.append(STRING_WITH_LEN(","), &my_charset_bin) || tmp_str.append(*res)) - return make_empty_result(); + return make_empty_result(str); } } } @@ -3061,7 +3063,7 @@ String *Item_func_repeat::val_str(String *str) null_value= 0; if (count <= 0 && (count == 0 || !args[1]->unsigned_flag)) - return make_empty_result(); + return make_empty_result(str); /* Assumes that the maximum length of a String is < INT_MAX32. */ /* Bounds check on count: If this is triggered, we will error. */ @@ -3126,7 +3128,7 @@ String *Item_func_space::val_str(String *str) null_value= 0; if (count <= 0 && (count == 0 || !args[0]->unsigned_flag)) - return make_empty_result(); + return make_empty_result(str); /* Assumes that the maximum length of a String is < INT_MAX32. Bounds check on count: If this is triggered, we will error. @@ -3292,7 +3294,7 @@ String *Item_func_rpad::val_str(String *str) null_value=0; if (count == 0) - return make_empty_result(); + return make_empty_result(str); /* Assumes that the maximum length of a String is < INT_MAX32. */ /* Set here so that rest of code sees out-of-bound value as such. */ @@ -3384,7 +3386,7 @@ String *Item_func_lpad::val_str(String *str) null_value=0; if (count == 0) - return make_empty_result(); + return make_empty_result(str); /* Assumes that the maximum length of a String is < INT_MAX32. */ /* Set here so that rest of code sees out-of-bound value as such. */ @@ -3733,7 +3735,7 @@ String *Item_func_hex::val_str_ascii_from_val_real(String *str) dec= ~(longlong) 0; else dec= (ulonglong) (val + (val > 0 ? 0.5 : -0.5)); - return str->set_hex(dec) ? make_empty_result() : str; + return str->set_hex(dec) ? make_empty_result(str) : str; } @@ -3744,7 +3746,7 @@ String *Item_func_hex::val_str_ascii_from_val_str(String *str) DBUG_ASSERT(res != str); if ((null_value= (res == NULL))) return NULL; - return str->set_hex(res->ptr(), res->length()) ? make_empty_result() : str; + return str->set_hex(res->ptr(), res->length()) ? make_empty_result(str) : str; } @@ -3753,7 +3755,7 @@ String *Item_func_hex::val_str_ascii_from_val_int(String *str) ulonglong dec= (ulonglong) args[0]->val_int(); if ((null_value= args[0]->null_value)) return 0; - return str->set_hex(dec) ? make_empty_result() : str; + return str->set_hex(dec) ? make_empty_result(str) : str; } |