mirror of
https://github.com/MariaDB/server.git
synced 2025-08-08 11:22:35 +03:00
MDEV-29552 LEFT and RIGHT with big value for parameter 'len' >0 return empty value in view
The code in max_length_for_string() erroneously returned 0 for huge numbers like 4294967295. Rewriting the code in a more straightforward way.
This commit is contained in:
@@ -64,11 +64,14 @@ size_t username_char_length= USERNAME_CHAR_LENGTH;
|
||||
static uint32 max_length_for_string(Item *item)
|
||||
{
|
||||
ulonglong length= item->val_int();
|
||||
/* Note that if value is NULL, val_int() returned 0 */
|
||||
if (item->null_value)
|
||||
return 0;
|
||||
if (length > (ulonglong) LONGLONG_MAX && !item->unsigned_flag)
|
||||
return 0; // Negative
|
||||
if (length > (ulonglong) INT_MAX32)
|
||||
{
|
||||
/* Limit string length to maxium string length in MariaDB (2G) */
|
||||
length= item->unsigned_flag ? (ulonglong) INT_MAX32 : 0;
|
||||
length= (ulonglong) INT_MAX32;
|
||||
}
|
||||
return (uint32) length;
|
||||
}
|
||||
|
Reference in New Issue
Block a user