mirror of
https://github.com/MariaDB/server.git
synced 2026-10-23 18:49:29 +03:00
MDEV-41603 DECODE_HISTOGRAM crashes when decoding JSON_HB
don't return a pointer to a local buffer
This commit is contained in:
@@ -4482,7 +4482,6 @@ set analyze_sample_percentage=@save_analyze_sample_percentage;
|
||||
set histogram_size=@save_histogram_size;
|
||||
set use_stat_tables=@save_use_stat_tables;
|
||||
set @@global.histogram_size=@save_histogram_size;
|
||||
drop table if exists t1;
|
||||
set @save_histogram_type=@@histogram_type;
|
||||
set @save_histogram_size=@@histogram_size;
|
||||
call mtr.add_suppression("Failed to parse histogram for table .*");
|
||||
@@ -8746,4 +8745,10 @@ analyze select * from t1 where col1 < '"😺';
|
||||
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
|
||||
1 SIMPLE t1 ALL NULL NULL NULL NULL 10 10.00 50.00 50.00 Using where
|
||||
drop table t1;
|
||||
#
|
||||
# MDEV-41603 DECODE_HISTOGRAM crashes when decoding JSON_HB
|
||||
#
|
||||
SELECT DECODE_HISTOGRAM('JSON_HB', REPEAT('A',80));
|
||||
DECODE_HISTOGRAM('JSON_HB', REPEAT('A',80))
|
||||
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
|
||||
# End of 10.11 tests
|
||||
|
||||
@@ -8,9 +8,6 @@ let $histogram_type_override='JSON_HB';
|
||||
--source include/have_innodb.inc
|
||||
--source include/have_stat_tables.inc
|
||||
--source include/have_sequence.inc
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
set @save_histogram_type=@@histogram_type;
|
||||
set @save_histogram_size=@@histogram_size;
|
||||
@@ -684,4 +681,9 @@ analyze select * from t1 where col1 < '"😺';
|
||||
|
||||
drop table t1;
|
||||
|
||||
--echo #
|
||||
--echo # MDEV-41603 DECODE_HISTOGRAM crashes when decoding JSON_HB
|
||||
--echo #
|
||||
SELECT DECODE_HISTOGRAM('JSON_HB', REPEAT('A',80));
|
||||
|
||||
--echo # End of 10.11 tests
|
||||
|
||||
@@ -566,6 +566,13 @@ String *Item_func_decode_histogram::val_str(String *str)
|
||||
}
|
||||
type--;
|
||||
|
||||
if (type == JSON_HB)
|
||||
{
|
||||
res= args[1]->val_str(str);
|
||||
null_value= res == 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
tmp.length(0);
|
||||
if (!(res= args[1]->val_str(&tmp)))
|
||||
{
|
||||
@@ -573,13 +580,6 @@ String *Item_func_decode_histogram::val_str(String *str)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (type == JSON_HB)
|
||||
{
|
||||
// It's a JSON histogram. Return it as-is.
|
||||
null_value= 0;
|
||||
return res;
|
||||
}
|
||||
|
||||
if (type == DOUBLE_PREC_HB && res->length() % 2 != 0)
|
||||
res->length(res->length() - 1); // one byte is unused
|
||||
|
||||
|
||||
Reference in New Issue
Block a user