diff options
author | Oleksandr Byelkin <sanja@mariadb.com> | 2022-02-04 14:50:25 +0100 |
---|---|---|
committer | Oleksandr Byelkin <sanja@mariadb.com> | 2022-02-04 14:50:25 +0100 |
commit | 4fb2cb1a30fc188682ae4dbda2f975213e5c3adf (patch) | |
tree | 522b2dc8096cc37ace66686de36b486b73a352f5 /sql/item_strfunc.cc | |
parent | c0f5fd27549c84607defa64c5b651343dd29e0ee (diff) | |
parent | 9ed8deb656d9378fc9c1c7fb12c15674b6323ab0 (diff) | |
download | mariadb-git-4fb2cb1a30fc188682ae4dbda2f975213e5c3adf.tar.gz |
Merge branch '10.7' into 10.8
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 962c0e291b5..b8c01e5af41 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -749,7 +749,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 */ @@ -952,7 +952,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++) { @@ -1103,7 +1103,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; @@ -1773,7 +1773,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; @@ -1817,7 +1817,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 */ @@ -1859,7 +1859,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. */ @@ -1870,12 +1870,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; @@ -1945,7 +1945,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); @@ -2355,7 +2355,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; @@ -2363,7 +2363,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; @@ -2402,13 +2402,15 @@ char *Item_func_password::alloc(THD *thd, const char *password, String *Item_func_encrypt::val_str(String *str) { DBUG_ASSERT(fixed()); + #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(); @@ -2706,8 +2708,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 */ @@ -2731,7 +2733,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; @@ -3032,7 +3034,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)) @@ -3056,7 +3058,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; } } @@ -3066,11 +3068,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); } } } @@ -3211,7 +3213,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. */ @@ -3276,7 +3278,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. @@ -3443,7 +3445,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. */ @@ -3535,7 +3537,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. */ @@ -3906,7 +3908,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; } @@ -3917,7 +3919,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; } @@ -3926,7 +3928,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; } |