[Commits] 7b49fb5803e: MDEV-26589: Assertion failure upon DECODE_HISTOGRAM with NULLs
revision-id: 7b49fb5803e4589d4bab2123813784d9ff29018d (mariadb-10.6.1-157-g7b49fb5803e) parent(s): efa79c9082062c3f032f7f3ec12dc0a7a0ed3939 author: Sergei Petrunia committer: Sergei Petrunia timestamp: 2021-10-01 14:24:41 +0300 message: MDEV-26589: Assertion failure upon DECODE_HISTOGRAM with NULLs Item_func_decode_histogram::val_str should correctly set null_value when "decoding" JSON histogram. --- mysql-test/main/statistics_json.result | 29 +++++++++++++++++++++++++++++ mysql-test/main/statistics_json.test | 10 ++++++++++ sql/item_strfunc.cc | 1 + 3 files changed, 40 insertions(+) diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 549b60e1fe6..df59bf37268 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -7841,6 +7841,35 @@ b a 2 bar drop table t1; # +# MDEV-26589: Assertion failure upon DECODE_HISTOGRAM with NULLs in first column +# (Just the testcase) +# +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (NULL,1), (NULL,2); +SET histogram_type = JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +Table Op Msg_type Msg_text +test.t1 analyze status Engine-independent statistics collected +test.t1 analyze status OK +SELECT DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; +DECODE_HISTOGRAM(hist_type, histogram) +NULL +{ + "histogram_hb_v2": [ + { + "start": "1", + "size": 0.5, + "ndv": 1 + }, + { + "start": "2", + "end": "2", + "size": 0.5, + "ndv": 1 + } + ] +} +drop table t1; # MDEV-26711: Values in JSON histograms are not properly quoted # create table t1 (a varchar(32)); diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test index 518044c3343..e7b65e19860 100644 --- a/mysql-test/main/statistics_json.test +++ b/mysql-test/main/statistics_json.test @@ -184,6 +184,16 @@ SELECT * FROM t1; drop table t1; --echo # +--echo # MDEV-26589: Assertion failure upon DECODE_HISTOGRAM with NULLs in first column +--echo # (Just the testcase) +--echo # + +CREATE TABLE t1 (a INT, b INT); +INSERT INTO t1 VALUES (NULL,1), (NULL,2); +SET histogram_type = JSON_HB; +ANALYZE TABLE t1 PERSISTENT FOR ALL; +SELECT DECODE_HISTOGRAM(hist_type, histogram) from mysql.column_stats; +drop table t1; --echo # MDEV-26711: Values in JSON histograms are not properly quoted --echo # create table t1 (a varchar(32)); diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index 9f406a7a1cf..06fb6fc5c51 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -530,6 +530,7 @@ String *Item_func_decode_histogram::val_str(String *str) if (type == JSON_HB) { // It's a JSON histogram. Return it as-is. + null_value= 0; return res; }
participants (1)
-
Sergei Petrunia