Commit ac0194bd authored by Sergei Petrunia's avatar Sergei Petrunia

MDEV-26892: JSON histograms become invalid with a specific (corrupt) value ..

Handle the case where the last value in the table cannot be represented
in utf8mb4.
parent 05877df4
...@@ -7534,7 +7534,6 @@ drop table t1; ...@@ -7534,7 +7534,6 @@ drop table t1;
# #
# MDEV-26849: JSON Histograms: point selectivity estimates are off for non-existent values # MDEV-26849: JSON Histograms: point selectivity estimates are off for non-existent values
# #
#
create table t0(a int); create table t0(a int);
insert into t0 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t0 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
create table t1(a int); create table t1(a int);
...@@ -7632,3 +7631,17 @@ analyze select * from t1 where a=200; ...@@ -7632,3 +7631,17 @@ analyze select * from t1 where a=200;
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra 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 1000 1000.00 10.00 10.00 Using where 1 SIMPLE t1 ALL NULL NULL NULL NULL 1000 1000.00 10.00 10.00 Using where
drop table t0,t1; drop table t0,t1;
#
# MDEV-26892: JSON histograms become invalid with a specific (corrupt) value in t
#
create table t1 (a varchar(32)) DEFAULT CHARSET=cp1257;
set histogram_type= JSON_HB, histogram_size= 1;
insert into t1 values ('foo'),(unhex('9C'));
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Operation failed
select * from t1;
a
foo
?
drop table t1;
...@@ -298,7 +298,6 @@ drop table t1; ...@@ -298,7 +298,6 @@ drop table t1;
--echo # --echo #
--echo # MDEV-26849: JSON Histograms: point selectivity estimates are off for non-existent values --echo # MDEV-26849: JSON Histograms: point selectivity estimates are off for non-existent values
--echo # --echo #
--echo #
create table t0(a int); create table t0(a int);
insert into t0 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9); insert into t0 (a) values (0),(1),(2),(3),(4),(5),(6),(7),(8),(9);
...@@ -317,3 +316,14 @@ analyze select * from t1 where a=200; ...@@ -317,3 +316,14 @@ analyze select * from t1 where a=200;
drop table t0,t1; drop table t0,t1;
--echo #
--echo # MDEV-26892: JSON histograms become invalid with a specific (corrupt) value in t
--echo #
create table t1 (a varchar(32)) DEFAULT CHARSET=cp1257;
set histogram_type= JSON_HB, histogram_size= 1;
insert into t1 values ('foo'),(unhex('9C'));
analyze table t1 persistent for all;
select * from t1;
drop table t1;
...@@ -326,7 +326,10 @@ class Histogram_json_builder : public Histogram_builder ...@@ -326,7 +326,10 @@ class Histogram_json_builder : public Histogram_builder
{ {
// This is the final value group. // This is the final value group.
if (!bucket_is_empty()) if (!bucket_is_empty())
finalize_bucket_with_end_value(elem); {
if (finalize_bucket_with_end_value(elem))
return 1;
}
} }
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment