MDEV-28652 SUBSTRING(str,pos,len) returns incorrect result in view (returns an empty string)
Item_func_substr::fix_length_and_dec() incorrecltly calculated its max_length to 0 when a huge number was passed as the third argument: substring('hello', 1, 4294967295) Fixing this.
This commit is contained in:
parent
09fe74c7fd
commit
74184074a0
@ -5330,5 +5330,13 @@ BIN(c)
|
|||||||
DROP TABLE t1;
|
DROP TABLE t1;
|
||||||
DO OCT(-9223372036854775808);
|
DO OCT(-9223372036854775808);
|
||||||
#
|
#
|
||||||
|
# MDEV-28652 SUBSTRING(str,pos,len) returns incorrect result in view (returns an empty string)
|
||||||
|
#
|
||||||
|
create view v1 as select substring('hello', 1, 4294967295);
|
||||||
|
select * from v1;
|
||||||
|
substring('hello', 1, 4294967295)
|
||||||
|
hello
|
||||||
|
drop view v1;
|
||||||
|
#
|
||||||
# End of 10.5 tests
|
# End of 10.5 tests
|
||||||
#
|
#
|
||||||
|
@ -2370,6 +2370,13 @@ DROP TABLE t1;
|
|||||||
|
|
||||||
DO OCT(-9223372036854775808);
|
DO OCT(-9223372036854775808);
|
||||||
|
|
||||||
|
--echo #
|
||||||
|
--echo # MDEV-28652 SUBSTRING(str,pos,len) returns incorrect result in view (returns an empty string)
|
||||||
|
--echo #
|
||||||
|
|
||||||
|
create view v1 as select substring('hello', 1, 4294967295);
|
||||||
|
select * from v1;
|
||||||
|
drop view v1;
|
||||||
|
|
||||||
--echo #
|
--echo #
|
||||||
--echo # End of 10.5 tests
|
--echo # End of 10.5 tests
|
||||||
|
@ -1773,11 +1773,11 @@ bool Item_func_substr::fix_length_and_dec()
|
|||||||
}
|
}
|
||||||
if (arg_count == 3 && args[2]->const_item())
|
if (arg_count == 3 && args[2]->const_item())
|
||||||
{
|
{
|
||||||
int32 length= (int32) args[2]->val_int();
|
longlong length= args[2]->val_int();
|
||||||
if (args[2]->null_value || length <= 0)
|
if (args[2]->null_value || (length <= 0 && !args[2]->unsigned_flag))
|
||||||
max_length=0; /* purecov: inspected */
|
max_length=0; /* purecov: inspected */
|
||||||
else
|
else if (length < UINT32_MAX)
|
||||||
set_if_smaller(max_length,(uint) length);
|
set_if_smaller(max_length, (uint32) length);
|
||||||
}
|
}
|
||||||
max_length*= collation.collation->mbmaxlen;
|
max_length*= collation.collation->mbmaxlen;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user