From d4d539803b5e7e70ce633cc3ea9a78677a7cddb1 Mon Sep 17 00:00:00 2001 From: Michael Okoko Date: Fri, 2 Jul 2021 10:50:51 +0100 Subject: [PATCH] Fix garbage null values at end of histogram json Signed-off-by: Michael Okoko --- mysql-test/main/statistics_json.result | 30 +++++++++++++------------- sql/sql_statistics.cc | 3 ++- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result index 7164198f2ae..e53a6f72f12 100644 --- a/mysql-test/main/statistics_json.result +++ b/mysql-test/main/statistics_json.result @@ -30,7 +30,7 @@ test t1 a 1 25 0.0000 4.0000 1.0000 10 JSON [ "19", "21", "23" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯΅ +] test t1 b 1 9 0.0000 1.6400 1.0000 10 JSON [ "11", "13", @@ -42,7 +42,7 @@ test t1 b 1 9 0.0000 1.6400 1.0000 10 JSON [ "3", "5", "7" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯΅ +] test t1 c 1 9 0.0000 2.0000 1.0000 10 JSON [ "11", "13", @@ -54,7 +54,7 @@ test t1 c 1 9 0.0000 2.0000 1.0000 10 JSON [ "3", "5", "7" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯΅ +] test t1 d 1 25 0.0000 8.0000 1.0000 10 JSON [ "3", "5", @@ -66,7 +66,7 @@ test t1 d 1 25 0.0000 8.0000 1.0000 10 JSON [ "19", "21", "23" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯e +] DELETE FROM mysql.column_stats; DROP TABLE t1; create schema world; @@ -102,7 +102,7 @@ Code ABW ZWE 25 JSON [ "TMP", "UKR", "VIR" -]0 +] Name Afghanistan Zimbabwe 25 JSON [ "Argentina", "Barbados", @@ -129,7 +129,7 @@ Name Afghanistan Zimbabwe 25 JSON [ "Togo", "Uganda", "Venezuela" -]a +] SurfaceArea 0.40 17075400.00 25 JSON [ "36.00", "151.00", @@ -156,7 +156,7 @@ SurfaceArea 0.40 17075400.00 25 JSON [ "1104300.00", "1648195.00", "2724900.00" -]΅ +] Population 0 1277558000 25 JSON [ "1000", "8000", @@ -183,7 +183,7 @@ Population 0 1277558000 25 JSON [ "40377000", "61399000", "111506000" -]΅ +] Capital 1 4074 25 JSON [ "62", "149", @@ -210,7 +210,7 @@ Capital 1 4074 25 JSON [ "3336", "3426", "3538" -]± +] ID 1 4079 10 JSON [ "371", "742", @@ -222,7 +222,7 @@ ID 1 4079 10 JSON [ "2967", "3338", "3709" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯΅ +] Name A Coruña (La Coruña) Ã…rhus 10 JSON [ "BerdytΓ‚Ε‘iv", "Clermont-Ferrand", @@ -234,7 +234,7 @@ Name A Coruña (La Coruña) Ã…rhus 10 JSON [ "Roanoke", "Split", "Ulsan" -]΅ +] Country ABW ZWE 10 JSON [ "BRA", "CHN", @@ -246,7 +246,7 @@ Country ABW ZWE 10 JSON [ "PHL", "RUS", "USA" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯‘ +] Population 42 10500000 10 JSON [ "96002", "105819", @@ -258,7 +258,7 @@ Population 42 10500000 10 JSON [ "288173", "398300", "670208" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯‘ +] Country ABW ZWE 10 JSON [ "BGD", "CMR", @@ -270,7 +270,7 @@ Country ABW ZWE 10 JSON [ "PNG", "SVK", "UGA" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯΅ +] Language Abhyasi [South]Mande 10 JSON [ "Bariba", "Creole English", @@ -294,7 +294,7 @@ Percentage 0.0 99.9 10 JSON [ "17.7", "45.5", "87.5" -]₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯₯q +] set histogram_type=@save_histogram_type; set histogram_size=@save_histogram_size; DROP SCHEMA world; diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc index 15736778cc0..85ee5a90609 100644 --- a/sql/sql_statistics.cc +++ b/sql/sql_statistics.cc @@ -1643,7 +1643,8 @@ public: } writer->end_array(); histogram->set_size(bucket_bounds.size()); - histogram->set_values((uchar *) writer->output.get_string()->ptr()); + Binary_string *json_string = (Binary_string *) writer->output.get_string(); + histogram->set_values((uchar *) json_string->c_ptr()); } };