[Commits] 2db68f4bc7b: Code cleanup part#2: do not copy key values in xxx_selectivity() functions
by psergey 29 Aug '21
by psergey 29 Aug '21
29 Aug '21
revision-id: 2db68f4bc7b8a3fa578ecd29f6b39a9e762ba85a (mariadb-10.6.1-100-g2db68f4bc7b)
parent(s): 17e6e908cec7544878b78e23985564bd27453c89
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-29 19:32:25 +0300
message:
Code cleanup part#2: do not copy key values in xxx_selectivity() functions
---
mysql-test/main/statistics_json.result | 10 +-
sql/sql_statistics.cc | 191 ++++++++++++++-------------------
sql/sql_statistics.h | 6 +-
3 files changed, 85 insertions(+), 122 deletions(-)
diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result
index 0293030e6a2..4de1b768a1e 100644
--- a/mysql-test/main/statistics_json.result
+++ b/mysql-test/main/statistics_json.result
@@ -2444,15 +2444,15 @@ test t1_json a a-0 a-9 0.0000 3.0000 1.0000 100 JSON_HB {
}
explain extended select * from t1_json where a between 'a-3a' and 'zzzzzzzzz';
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 60.87 Using where
+1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 59.87 Using where
Warnings:
Note 1003 select `test`.`t1_json`.`a` AS `a` from `test`.`t1_json` where `test`.`t1_json`.`a` between 'a-3a' and 'zzzzzzzzz'
analyze select * from t1_json where a between 'a-3a' and 'zzzzzzzzz';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 60.87 60.00 Using where
+1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 59.87 60.00 Using where
explain extended select * from t1_json where a < 'b-1a';
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 100.00 Using where
+1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 99.00 Using where
Warnings:
Note 1003 select `test`.`t1_json`.`a` AS `a` from `test`.`t1_json` where `test`.`t1_json`.`a` < 'b-1a'
analyze select * from t1_json where a > 'zzzzzzzzz';
@@ -2476,12 +2476,12 @@ test.t2 analyze status Engine-independent statistics collected
test.t2 analyze status OK
explain extended select * from t2 where city = 'Moscow';
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 101 98.04 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 101 96.08 Using where
Warnings:
Note 1003 select `test`.`t2`.`city` AS `city` from `test`.`t2` where `test`.`t2`.`city` = 'Moscow'
analyze select * from t2 where city = 'Moscow';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t2 ALL NULL NULL NULL NULL 101 101.00 98.04 98.02 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 101 101.00 96.08 98.02 Using where
explain extended select * from t2 where city = 'Helsinki';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 101 2.00 Using where
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index af884fdd6e8..18a9d093ca2 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -63,16 +63,7 @@
equal to "never".
*/
-/*
- * json_get_array_items expects a JSON array as argument,
- * and pushes the elements of the array into the `container` vector.
- * It only works if all the elements in the original JSON array
- * are scalar values (i.e., strings, numbers, true or false),
- * else, the JSON type encountered is stored in value_type and the function returns false.
- */
-bool json_get_array_items(const char *json, const char *json_end, int *value_type, std::vector<std::string> &container);
-
-Histogram_base *create_histogram(Histogram_type hist_type);
+Histogram_base *create_histogram(MEM_ROOT *mem_root, Histogram_type hist_type);
/* Currently there are only 3 persistent statistical tables */
static const uint STATISTICS_TABLES= 3;
@@ -1235,18 +1226,9 @@ class Column_stat: public Stat_table
Field *stat_field= stat_table->field[fldno];
table_field->read_stats->set_not_null(fldno);
stat_field->val_str(&val);
- switch (table_field->read_stats->histogram_type_on_disk)
- {
- case SINGLE_PREC_HB:
- case DOUBLE_PREC_HB:
- hist = new (mem_root) Histogram_binary();
- break;
- case JSON_HB:
- hist = new (mem_root) Histogram_json();
- break;
- default:
+ hist= create_histogram(mem_root, table_field->read_stats->histogram_type_on_disk);
+ if (!hist)
return NULL;
- }
if (!hist->parse(mem_root, table_field,
table_field->read_stats->histogram_type_on_disk,
val.ptr(), val.length()))
@@ -1415,7 +1397,6 @@ double pos_in_interval_through_val_real(Field *field,
uchar *max_val,
uchar *midpoint_val)
{
-
// For each passed value: unpack it into Field's current value. Then, we can
// get the value as double.
@@ -1526,114 +1507,105 @@ double Histogram_json::point_selectivity(Field *field, key_range *endpoint, doub
const uchar *min_key = endpoint->key;
if (field->real_maybe_null())
min_key++;
- uint min_idx= find_bucket(field, min_key);
-
- uint max_idx= min_idx;
+ uint min_idx= find_bucket(field, min_key, false);
+ uint max_idx= find_bucket(field, min_key, true);
+#if 0
// find how many buckets this value occupies
while ((max_idx + 1 < get_width() ) &&
(field->key_cmp((uchar *)histogram_bounds[max_idx + 1].data(), min_key) == 0)) {
max_idx++;
}
-
+#endif
if (max_idx > min_idx)
{
// value spans multiple buckets
double bucket_sel= 1.0/(get_width() + 1);
sel= bucket_sel * (max_idx - min_idx + 1);
- } else
+ }
+ else
{
// the value fits within a single bucket
- sel = MY_MIN(avg_sel, (1.0/get_width()));
+ sel = MY_MIN(avg_sel, 1.0/get_width());
}
return sel;
}
/*
- @param field The table field histogram is for. We don't care about the
- field's current value, we only need its virtual functions to
- perform various operations
+ @param field The table field histogram is for. We don't care about the
+ field's current value, we only need its virtual functions to
+ perform various operations
- @param min_endp, max_endp - this specifies the range.
+ @param min_endp Left endpoint, or NULL if there is none
+ @param max_endp Right endpoint, or NULL if there is none
*/
double Histogram_json::range_selectivity(Field *field, key_range *min_endp,
- key_range *max_endp)
+ key_range *max_endp)
{
- double min = 0.0, max = 1.0;
- double width = 1.0/(int)histogram_bounds.size();
- if (min_endp)
+ double min, max;
+ double width= 1.0 / histogram_bounds.size();
+
+ if (min_endp && !(field->null_ptr && min_endp->key[0]))
{
- double min_sel = 0.0;
+ bool exclusive_endp= (min_endp->flag == HA_READ_AFTER_KEY)? true: false;
const uchar *min_key= min_endp->key;
- // GSOC-TODO: properly handle SQL NULLs.
- // in this test patch, we just assume the values are not SQL NULLs.
if (field->real_maybe_null())
min_key++;
- int min_bucket_idx, max_bucket_idx;
- min_bucket_idx= find_bucket(field, min_key);
- std::string min_bucket, max_bucket;
-
- max_bucket_idx= min_bucket_idx + 1;
- if (min_bucket_idx != -1)
+ // Find the leftmost bucket that contains the lookup value.
+ // (If the lookup value is to the left of all buckets, find bucket #0)
+ int idx= find_bucket(field, min_key, exclusive_endp);
+ double min_sel;
{
- min_bucket= histogram_bounds[min_bucket_idx];
- max_bucket= (max_bucket_idx < (int) histogram_bounds.size())
- ? histogram_bounds[max_bucket_idx]
- : "";
-
+ std::string &left= histogram_bounds[idx];
+ std::string &right= histogram_bounds[idx+1];
if (field->pos_through_val_str())
min_sel= pos_in_interval_through_strxfrm(
- field, (uchar *) min_bucket.data(), (uchar *) max_bucket.data(),
- (uchar *) min_key);
+ field, (uchar*) left.data(), (uchar*) right.data(),
+ (uchar*) min_key);
else
min_sel= pos_in_interval_through_val_real(
- field, (uchar *) min_bucket.data(), (uchar *) max_bucket.data(),
- (uchar *) min_key);
+ field, (uchar *) left.data(), (uchar*) right.data(),
+ (uchar*) min_key);
}
- min = min_bucket_idx * (width) + min_sel * (width);
- //fprintf(stderr, "min pos_in_interval =%g\n", min_sel);
- //fprintf(stderr, "min =%g\n", min);
+ min= idx*width + min_sel*width;
}
+ else
+ min= 0.0;
+
if (max_endp)
{
- double max_sel = 1.0;
+ // The right endpoint cannot be NULL
+ DBUG_ASSERT(!(field->null_ptr && max_endp->key[0]));
+ bool inclusive_endp= (max_endp->flag == HA_READ_AFTER_KEY)? true: false;
const uchar *max_key= max_endp->key;
if (field->real_maybe_null())
max_key++;
- int min_bucket_idx, max_bucket_idx;
- min_bucket_idx= find_bucket(field, max_key);
- std::string min_bucket, max_bucket;
-
- max_bucket_idx= min_bucket_idx + 1;
- if (min_bucket_idx != -1)
+ int idx= find_bucket(field, max_key, inclusive_endp);
+ double max_sel;
{
- min_bucket= histogram_bounds[min_bucket_idx];
- max_bucket= (max_bucket_idx < (int) histogram_bounds.size())
- ? histogram_bounds[max_bucket_idx]
- : "";
+ std::string &left= histogram_bounds[idx];
+ std::string &right= histogram_bounds[idx+1];
if (field->pos_through_val_str())
max_sel= pos_in_interval_through_strxfrm(
- field, (uchar *) min_bucket.data(), (uchar *) max_bucket.data(),
+ field, (uchar *) left.data(), (uchar *) right.data(),
(uchar *) max_key);
else
max_sel= pos_in_interval_through_val_real(
- field, (uchar *) min_bucket.data(), (uchar *) max_bucket.data(),
+ field, (uchar *) left.data(), (uchar *) right.data(),
(uchar *) max_key);
}
- max = min_bucket_idx * (width) + max_sel * (width);
- //fprintf(stderr, "max pos_in_interval =%g\n", max_sel);
- //fprintf(stderr, "max =%g\n", max);
+ max= idx*width + max_sel*width;
}
+ else
+ max= 1.0;
double sel = max - min;
- //fprintf(stderr, "final selection = %g\n", sel);
- //fprintf(stderr, "Histogram_json::range_selectivity ends\n");
return sel;
}
@@ -1644,34 +1616,33 @@ void Histogram_json::serialize(Field *field)
}
-int Histogram_json::find_bucket(Field *field, const uchar *endpoint)
+/*
+ Find the histogram bucket that contains the value.
+
+ @param equal_is_less Controls what to do if a histogram bound is equal to the
+ lookup_val.
+*/
+
+int Histogram_json::find_bucket(Field *field, const uchar *lookup_val,
+ bool equal_is_less)
{
- int low = 0;
- int high = (int)histogram_bounds.size()-1;
- int mid;
- int min_bucket_index = -1;
- std::string mid_val; // GSOC-todo: don't copy strings
-
- while(low <= high) {
- // c++ gives us the floor of integer divisions by default, below we get the ceiling (round-up).
- // it works but it doesn't feel so readable, maybe we could make improvements?
- int sum = (low+high);
- mid = sum/2 + (sum % 2 != 0);
-
- mid_val = histogram_bounds[mid];
-
- int res = field->key_cmp((uchar*) mid_val.data(), endpoint);
- if (res < 0) {
- low = mid + 1;
- min_bucket_index = mid;
- } else if (res >= 0) {
- high = mid - 1;
- }
+ int low= 0;
+ int high= histogram_bounds.size() - 1;
+ int middle;
+
+ while (low + 1 < high)
+ {
+ middle= (low + high) / 2;
+ int res= field->key_cmp((uchar*)histogram_bounds[middle].data(), lookup_val);
+ if (!res)
+ res= equal_is_less? -1: 1;
+ if (res < 0)
+ low= middle;
+ else //res > 0
+ high= middle;
}
- if (min_bucket_index == -1)
- min_bucket_index = high;
- return min_bucket_index;
+ return low;
}
/*
@@ -2114,14 +2085,14 @@ class Histogram_builder_json : public Histogram_builder
};
-Histogram_base *create_histogram(Histogram_type hist_type)
+Histogram_base *create_histogram(MEM_ROOT *mem_root, Histogram_type hist_type)
{
switch (hist_type) {
case SINGLE_PREC_HB:
case DOUBLE_PREC_HB:
- return new Histogram_binary();
+ return new (mem_root) Histogram_binary();
case JSON_HB:
- return new Histogram_json();
+ return new (mem_root) Histogram_json();
default:
DBUG_ASSERT(0);
}
@@ -2963,7 +2934,7 @@ void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows, doubl
if (hist_size != 0 && hist_type != INVALID_HISTOGRAM)
{
have_histogram= true;
- histogram_= create_histogram(hist_type);
+ histogram_= create_histogram(mem_root, hist_type);
histogram_->init_for_collection(mem_root, hist_type, hist_size);
}
@@ -4530,9 +4501,10 @@ double Histogram_binary::point_selectivity(Field *field, key_range *min_endp, do
return sel;
}
+
double Histogram_binary::range_selectivity(Field *field,
- key_range *min_endp,
- key_range *max_endp)
+ key_range *min_endp,
+ key_range *max_endp)
{
double sel, min_mp_pos, max_mp_pos;
Column_statistics *col_stats= field->read_stats;
@@ -4561,13 +4533,6 @@ double Histogram_binary::range_selectivity(Field *field,
uint max= find_bucket(max_mp_pos, FALSE);
sel= bucket_sel * (max - min + 1);
- /*fprintf(stderr, "bucket_sel =%g\n", bucket_sel);
- fprintf(stderr, "min pos_in_interval =%g\n", min_mp_pos);
- fprintf(stderr, "max pos_in_interval =%g\n", max_mp_pos);
- fprintf(stderr, "min =%d\n", min);
- fprintf(stderr, "max =%d\n", max);*/
- /*fprintf(stderr, "final sel =%g\n", sel);
- fprintf(stderr, "Histogram_binary::range_selectivity ends\n");*/
return sel;
}
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index eb982f9c4b3..aade713ba6c 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -400,10 +400,8 @@ class Histogram_json : public Histogram_base
double avg_selection) override;
double range_selectivity(Field *field, key_range *min_endp,
key_range *max_endp) override;
- /*
- * Returns the index of the biggest histogram value that is smaller than endpoint
- */
- int find_bucket(Field *field, const uchar *endpoint);
+private:
+ int find_bucket(Field *field, const uchar *lookup_val, bool equal_is_less);
};
class Columns_statistics;
1
0
[Commits] 17e6e908cec: Fix JSON parsing: future-proof data representation in JSON, code cleanup
by psergey 29 Aug '21
by psergey 29 Aug '21
29 Aug '21
revision-id: 17e6e908cec7544878b78e23985564bd27453c89 (mariadb-10.6.1-99-g17e6e908cec)
parent(s): 02ca278e695535fbd2a43e392276f030c3617207
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-29 14:37:45 +0300
message:
Fix JSON parsing: future-proof data representation in JSON, code cleanup
---
include/json_lib.h | 13 +-
mysql-test/main/statistics_json.result | 2407 ++++++++++++++++----------------
mysql-test/main/statistics_json.test | 22 +-
sql/share/errmsg-utf8.txt | 2 +-
sql/sql_statistics.cc | 177 +--
sql/sql_statistics.h | 16 +-
6 files changed, 1349 insertions(+), 1288 deletions(-)
diff --git a/include/json_lib.h b/include/json_lib.h
index 2248b1a9388..e9f3deea415 100644
--- a/include/json_lib.h
+++ b/include/json_lib.h
@@ -283,12 +283,13 @@ int json_key_matches(json_engine_t *je, json_string_t *k);
int json_read_value(json_engine_t *j);
/*
- * json_smart_read_value() reads parses a scalar value and value length from the json engine,
- * and copies them into `value` and `value_length` respectively.
- * It should only be called when the json_engine state is JST_VALUE.
- * If it encounters a non-scalar value (say object or array) before getting to value_len,
- * such value is also read and copied into value.
- */
+ json_smart_read_value() reads a JSON value. Pointer to value is stored in
+ *value and its length in *value_len.
+
+ if the value is non a scalar, it returns pointers to its JSON
+ representation.
+ The function should only be called when je->state==JST_VALUE.
+*/
enum json_types json_smart_read_value(json_engine_t *je, const char **value, int *value_len);
/*
diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result
index 97931026690..0293030e6a2 100644
--- a/mysql-test/main/statistics_json.result
+++ b/mysql-test/main/statistics_json.result
@@ -232,12 +232,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 0 49 0.0000 1.0000 4 JSON_HB 5B0A20202239222C0A2020223139222C0A2020223331222C0A2020223430220A5D
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON_HB 5B0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
-test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON_HB 5B0A20202261616161222C0A202022626262626262222C0A202022636363636363636363222C0A2020226464646464646464220A5D
-test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON_HB 5B0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233220A5D
-test t1 e 0.01 0.112 0.2250 6.2000 4 JSON_HB 5B0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31220A5D
-test t1 f 1 5 0.2000 6.4000 4 JSON_HB 5B0A20202202222C0A20202203222C0A20202204222C0A20202204220A5D
+test t1 a 0 49 0.0000 1.0000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2239222C20223139222C20223331222C20223430225D0A7D
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202276767676767676767676767676222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A2020202022797979222C0A20202020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A20205D0A7D
+test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2261616161222C2022626262626262222C2022636363636363636363222C20226464646464646464225D0A7D
+test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B22313938392D30332D3132222C2022313939302D30352D3135222C2022313939302D30352D3135222C2022313939392D30372D3233225D0A7D
+test t1 e 0.01 0.112 0.2250 6.2000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B22302E3031222C2022302E303132222C2022302E3035222C2022302E31225D0A7D
+test t1 f 1 5 0.2000 6.4000 4 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2202222C202203222C202204222C202204225D0A7D
DELETE FROM mysql.column_stats;
set histogram_size=8;
set histogram_type=@DOUBLE_PREC_TYPE;
@@ -251,12 +251,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 0 49 0.0000 1.0000 8 JSON_HB 5B0A20202234222C0A20202239222C0A2020223135222C0A2020223231222C0A2020223239222C0A2020223333222C0A2020223339222C0A2020223433220A5D
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 JSON_HB 5B0A20202276767676767676767676767676222C0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A20202277777777777777777777777777777777777777777777777777777777222C0A2020227878787878787878787878787878787878787878787878787878222C0A202022797979222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
-test t1 c aaaa dddddddd 0.1250 7.0000 8 JSON_HB 5B0A20202261616161222C0A20202261616161222C0A202022626262626262222C0A202022626262626262222C0A202022636363636363636363222C0A202022636363636363636363222C0A2020226464646464646464222C0A2020226464646464646464220A5D
-test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 JSON_HB 5B0A202022313938392D30332D3132222C0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233222C0A202022313939392D30372D3233220A5D
-test t1 e 0.01 0.112 0.2250 6.2000 8 JSON_HB 5B0A202022302E3031222C0A202022302E3031222C0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31222C0A202022302E31222C0A202022302E313132220A5D
-test t1 f 1 5 0.2000 6.4000 8 JSON_HB 5B0A20202201222C0A20202202222C0A20202202222C0A20202203222C0A20202203222C0A20202204222C0A20202204222C0A20202205220A5D
+test t1 a 0 49 0.0000 1.0000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2234222C202239222C20223135222C20223231222C20223239222C20223333222C20223339222C20223433225D0A7D
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202276767676767676767676767676222C0A202020202276767676767676767676767676222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A202020202277777777777777777777777777777777777777777777777777777777222C0A20202020227878787878787878787878787878787878787878787878787878222C0A2020202022797979222C0A2020202022797979222C0A20202020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A20205D0A7D
+test t1 c aaaa dddddddd 0.1250 7.0000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202261616161222C0A202020202261616161222C0A2020202022626262626262222C0A2020202022626262626262222C0A2020202022636363636363636363222C0A2020202022636363636363636363222C0A20202020226464646464646464222C0A20202020226464646464646464220A20205D0A7D
+test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022313938392D30332D3132222C0A2020202022313938392D30332D3132222C0A2020202022313939302D30352D3135222C0A2020202022313939302D30352D3135222C0A2020202022313939302D30352D3135222C0A2020202022313939302D30352D3135222C0A2020202022313939392D30372D3233222C0A2020202022313939392D30372D3233220A20205D0A7D
+test t1 e 0.01 0.112 0.2250 6.2000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022302E3031222C0A2020202022302E3031222C0A2020202022302E3031222C0A2020202022302E303132222C0A2020202022302E3035222C0A2020202022302E31222C0A2020202022302E31222C0A2020202022302E313132220A20205D0A7D
+test t1 f 1 5 0.2000 6.4000 8 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2201222C202202222C202202222C202203222C202203222C202204222C202204222C202205225D0A7D
DELETE FROM mysql.column_stats;
set histogram_size= 0;
set histogram_type=@SINGLE_PREC_TYPE;
@@ -1502,109 +1502,111 @@ avg_length 4.0000
avg_frequency 2.7640
hist_size 100
hist_type JSON_HB
-hex(histogram) 5B0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E31222C0A202022302E31222C0A202022302E32222C0A202022302E32222C0A202022302E33222C0A202022302E33222C0A202022302E34222C0A202022302E34222C0A202022302E34222C0A202022302E35222C0A202022302E35222C0A202022302E36222C0A202022302E36222C0A202022302E37222C0A202022302E37222C0A202022302E38222C0A202022302E39222C0A202022312E31222C0A202022312E32222C0A202022312E33222C0A202022312E34222C0A202022312E34222C0A202022312E36222C0A202022312E36222C0A202022312E37222C0A202022312E39222C0A202022322E30222C0A202022322E32222C0A202022322E32222C0A202022322E33222C0A202022322E35222C0A202022322E36222C0A202022322E38222C0A202022322E39222C0A202022332E31222C0A202022332E32222C0A202022332E34222C0A202022332E36222C0A202022332E38222C0A202022342E30222C0A202022342E33222C0A202022342E35222C0A202022342E38222C0A202022352E31222C0A202022352E34222C0A202022352E37222C0A202022352E38222C0A202022362E31222C0A202022
362E34222C0A202022362E38222C0A202022372E32222C0A202022372E35222C0A202022372E37222C0A202022382E31222C0A202022382E35222C0A202022382E38222C0A202022392E31222C0A202022392E35222C0A20202231302E31222C0A20202231302E38222C0A20202231312E33222C0A20202231322E30222C0A20202231322E36222C0A20202231332E35222C0A20202231342E32222C0A20202231362E31222C0A20202231362E38222C0A20202231382E31222C0A20202232302E30222C0A20202232312E36222C0A20202232332E34222C0A20202232382E33222C0A20202233312E37222C0A20202233342E31222C0A20202233372E35222C0A20202234312E39222C0A20202234362E34222C0A20202235302E37222C0A20202235352E31222C0A20202236302E34222C0A20202236352E36222C0A20202237322E36222C0A20202237372E31222C0A20202238312E32222C0A20202238352E36222C0A20202238372E37222C0A20202238392E39222C0A20202239322E31222C0A20202239342E32222C0A20202239352E39222C0A20202239372E33222C0A20202239382E31222C0A20202239392E30222C0A20202239392E39220A5D
-decode_histogram(hist_type,histogram) [
- "0.0",
- "0.0",
- "0.0",
- "0.0",
- "0.0",
- "0.0",
- "0.1",
- "0.1",
- "0.2",
- "0.2",
- "0.3",
- "0.3",
- "0.4",
- "0.4",
- "0.4",
- "0.5",
- "0.5",
- "0.6",
- "0.6",
- "0.7",
- "0.7",
- "0.8",
- "0.9",
- "1.1",
- "1.2",
- "1.3",
- "1.4",
- "1.4",
- "1.6",
- "1.6",
- "1.7",
- "1.9",
- "2.0",
- "2.2",
- "2.2",
- "2.3",
- "2.5",
- "2.6",
- "2.8",
- "2.9",
- "3.1",
- "3.2",
- "3.4",
- "3.6",
- "3.8",
- "4.0",
- "4.3",
- "4.5",
- "4.8",
- "5.1",
- "5.4",
- "5.7",
- "5.8",
- "6.1",
- "6.4",
- "6.8",
- "7.2",
- "7.5",
- "7.7",
- "8.1",
- "8.5",
- "8.8",
- "9.1",
- "9.5",
- "10.1",
- "10.8",
- "11.3",
- "12.0",
- "12.6",
- "13.5",
- "14.2",
- "16.1",
- "16.8",
- "18.1",
- "20.0",
- "21.6",
- "23.4",
- "28.3",
- "31.7",
- "34.1",
- "37.5",
- "41.9",
- "46.4",
- "50.7",
- "55.1",
- "60.4",
- "65.6",
- "72.6",
- "77.1",
- "81.2",
- "85.6",
- "87.7",
- "89.9",
- "92.1",
- "94.2",
- "95.9",
- "97.3",
- "98.1",
- "99.0",
- "99.9"
-]
+hex(histogram) 7B0A202022686973746F6772616D5F68625F7631223A205B0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E30222C0A2020202022302E31222C0A2020202022302E31222C0A2020202022302E32222C0A2020202022302E32222C0A2020202022302E33222C0A2020202022302E33222C0A2020202022302E34222C0A2020202022302E34222C0A2020202022302E34222C0A2020202022302E35222C0A2020202022302E35222C0A2020202022302E36222C0A2020202022302E36222C0A2020202022302E37222C0A2020202022302E37222C0A2020202022302E38222C0A2020202022302E39222C0A2020202022312E31222C0A2020202022312E32222C0A2020202022312E33222C0A2020202022312E34222C0A2020202022312E34222C0A2020202022312E36222C0A2020202022312E36222C0A2020202022312E37222C0A2020202022312E39222C0A2020202022322E30222C0A2020202022322E32222C0A2020202022322E32222C0A2020202022322E33222C0A2020202022322E35222C0A2020202022322E36222C0A2020202022322E38222C0A2020202022322E39222C0A2020202022332E31222C0A2020202022332E32222C0A20202020
22332E34222C0A2020202022332E36222C0A2020202022332E38222C0A2020202022342E30222C0A2020202022342E33222C0A2020202022342E35222C0A2020202022342E38222C0A2020202022352E31222C0A2020202022352E34222C0A2020202022352E37222C0A2020202022352E38222C0A2020202022362E31222C0A2020202022362E34222C0A2020202022362E38222C0A2020202022372E32222C0A2020202022372E35222C0A2020202022372E37222C0A2020202022382E31222C0A2020202022382E35222C0A2020202022382E38222C0A2020202022392E31222C0A2020202022392E35222C0A202020202231302E31222C0A202020202231302E38222C0A202020202231312E33222C0A202020202231322E30222C0A202020202231322E36222C0A202020202231332E35222C0A202020202231342E32222C0A202020202231362E31222C0A202020202231362E38222C0A202020202231382E31222C0A202020202232302E30222C0A202020202232312E36222C0A202020202232332E34222C0A202020202232382E33222C0A202020202233312E37222C0A202020202233342E31222C0A202020202233372E35222C0A202020202234312E39222C0A202020202234362E34222C0A202020202235302E37222C0A202020202235352E31222C0A202020202236302E3
4222C0A202020202236352E36222C0A202020202237322E36222C0A202020202237372E31222C0A202020202238312E32222C0A202020202238352E36222C0A202020202238372E37222C0A202020202238392E39222C0A202020202239322E31222C0A202020202239342E32222C0A202020202239352E39222C0A202020202239372E33222C0A202020202239382E31222C0A202020202239392E30222C0A202020202239392E39220A20205D0A7D
+decode_histogram(hist_type,histogram) {
+ "histogram_hb_v1": [
+ "0.0",
+ "0.0",
+ "0.0",
+ "0.0",
+ "0.0",
+ "0.0",
+ "0.1",
+ "0.1",
+ "0.2",
+ "0.2",
+ "0.3",
+ "0.3",
+ "0.4",
+ "0.4",
+ "0.4",
+ "0.5",
+ "0.5",
+ "0.6",
+ "0.6",
+ "0.7",
+ "0.7",
+ "0.8",
+ "0.9",
+ "1.1",
+ "1.2",
+ "1.3",
+ "1.4",
+ "1.4",
+ "1.6",
+ "1.6",
+ "1.7",
+ "1.9",
+ "2.0",
+ "2.2",
+ "2.2",
+ "2.3",
+ "2.5",
+ "2.6",
+ "2.8",
+ "2.9",
+ "3.1",
+ "3.2",
+ "3.4",
+ "3.6",
+ "3.8",
+ "4.0",
+ "4.3",
+ "4.5",
+ "4.8",
+ "5.1",
+ "5.4",
+ "5.7",
+ "5.8",
+ "6.1",
+ "6.4",
+ "6.8",
+ "7.2",
+ "7.5",
+ "7.7",
+ "8.1",
+ "8.5",
+ "8.8",
+ "9.1",
+ "9.5",
+ "10.1",
+ "10.8",
+ "11.3",
+ "12.0",
+ "12.6",
+ "13.5",
+ "14.2",
+ "16.1",
+ "16.8",
+ "18.1",
+ "20.0",
+ "21.6",
+ "23.4",
+ "28.3",
+ "31.7",
+ "34.1",
+ "37.5",
+ "41.9",
+ "46.4",
+ "50.7",
+ "55.1",
+ "60.4",
+ "65.6",
+ "72.6",
+ "77.1",
+ "81.2",
+ "85.6",
+ "87.7",
+ "89.9",
+ "92.1",
+ "94.2",
+ "95.9",
+ "97.3",
+ "98.1",
+ "99.0",
+ "99.9"
+ ]
+}
select UPPER(db_name),UPPER(table_name),UPPER(column_name),min_value,max_value,nulls_ratio,avg_length,avg_frequency,hist_size,hist_type,hex(histogram),decode_histogram(hist_type,histogram) from mysql.column_stats where UPPER(db_name)='WORLD' and UPPER(table_name)='CITY' and UPPER(column_name) = 'POPULATION';;
UPPER(db_name) WORLD
UPPER(table_name) CITY
@@ -1616,263 +1618,265 @@ avg_length 4.0000
avg_frequency 1.0467
hist_size 254
hist_type JSON_HB
-hex(histogram) 5B0A20202231343338222C0A20202235303535222C0A2020223133303030222C0A2020223235383838222C0A2020223530363939222C0A2020223839303533222C0A2020223839333838222C0A2020223839383831222C0A2020223930313131222C0A2020223930363031222C0A2020223930393531222C0A2020223931323030222C0A2020223931373737222C0A2020223932323234222C0A2020223932353833222C0A2020223932393838222C0A2020223933333030222C0A2020223933383138222C0A2020223934313030222C0A2020223934363030222C0A2020223934393334222C0A2020223935343030222C0A2020223935393333222C0A2020223936323931222C0A2020223936383030222C0A2020223937313030222C0A2020223937343531222C0A2020223938303830222C0A2020223938333432222C0A2020223938373831222C0A2020223939333637222C0A2020223939373939222C0A202022313030313138222C0A202022313030343738222C0A202022313030383837222C0A202022313031323035222C0A202022313031353734222C0A202022313031393834222C0A202022313032323934222C0A202022313032363831222C0A202022313033313731222C0A202022313033353434222C0A202022313033393834222C0A20202231303437
3030222C0A202022313035313139222C0A202022313035363930222C0A202022313036303031222C0A202022313036343134222C0A202022313037303030222C0A202022313037333239222C0A202022313037373631222C0A202022313038313030222C0A202022313038353734222C0A202022313039313231222C0A202022313039353030222C0A202022313039393635222C0A202022313130333838222C0A202022313131313030222C0A202022313131373532222C0A202022313132333735222C0A202022313133303830222C0A202022313133383030222C0A202022313134323333222C0A202022313134383736222C0A202022313135353332222C0A202022313136313738222C0A202022313136363935222C0A202022313137323237222C0A202022313137383635222C0A202022313138373138222C0A202022313139323833222C0A202022313139373936222C0A202022313230323635222C0A202022313231303030222C0A202022313231363030222C0A202022313231393534222C0A202022313232373035222C0A202022313233333539222C0A202022313233383635222C0A202022313234323037222C0A202022313234373335222C0A202022313235323535222C0A202022313235373636222C0A202022313236323832222C0A202022313236383230222C0A202
022313237323232222C0A202022313237383031222C0A202022313238333030222C0A202022313239333030222C0A202022313330303030222C0A202022313331303030222C0A202022313331373137222C0A202022313332343535222C0A202022313333313036222C0A202022313333363432222C0A202022313334303337222C0A202022313335303130222C0A202022313336323136222C0A202022313337303238222C0A202022313337373736222C0A202022313338343138222C0A202022313339323833222C0A202022313430303330222C0A202022313430383030222C0A202022313432303434222C0A202022313432363539222C0A202022313433373236222C0A202022313434353832222C0A202022313435383030222C0A202022313436343339222C0A202022313437353233222C0A202022313438313035222C0A202022313439313436222C0A202022313530313030222C0A202022313531303630222C0A202022313532343432222C0A202022313533333634222C0A202022313534393830222C0A202022313535383030222C0A202022313537333030222C0A202022313538333335222C0A202022313539363332222C0A202022313631313631222C0A202022313632333030222C0A202022313633383439222C0A202022313634373437222C0A2020223136363436
37222C0A202022313637343631222C0A202022313639333030222C0A202022313730343238222C0A202022313731353332222C0A202022313732373031222C0A202022313733383935222C0A202022313734393835222C0A202022313736353736222C0A202022313738313832222C0A202022313739323038222C0A202022313830323130222C0A202022313831383035222C0A202022313833313030222C0A202022313834303631222C0A202022313835343031222C0A202022313836393030222C0A202022313838333434222C0A202022313839353639222C0A202022313930393035222C0A202022313933303035222C0A202022313934333030222C0A202022313935353030222C0A202022313937323534222C0A202022313939303030222C0A202022323030393031222C0A202022323032313334222C0A202022323033373933222C0A202022323036313538222C0A202022323037353838222C0A202022323130303638222C0A202022323132393736222C0A202022323134393530222C0A202022323136373335222C0A202022323138343437222C0A202022323231303030222C0A202022323232353138222C0A202022323234383837222C0A202022323237363537222C0A202022323239343235222C0A202022323333303431222C0A202022323336303030222C0A20202
2323339313234222C0A202022323431363439222C0A202022323433373432222C0A202022323435373732222C0A202022323438323435222C0A202022323532333836222C0A202022323534383432222C0A202022323537383132222C0A202022323632303030222C0A202022323634303831222C0A202022323636323831222C0A202022323730323531222C0A202022323732393638222C0A202022323736343231222C0A202022323739333430222C0A202022323832393431222C0A202022323836393030222C0A202022323931303030222C0A202022323934303536222C0A202022323938393030222C0A202022333031323736222C0A202022333034343737222C0A202022333039373530222C0A202022333133353330222C0A202022333137363030222C0A202022333232323637222C0A202022333236333939222C0A202022333330323736222C0A202022333334353633222C0A202022333339313331222C0A202022333432373338222C0A202022333439323436222C0A202022333533363332222C0A202022333539313437222C0A202022333632343730222C0A202022333636353439222C0A202022333732383430222C0A202022333830373535222C0A202022333835323031222C0A202022333932383330222C0A202022343030393937222C0A202022343039313030
222C0A202022343136393838222C0A202022343231353839222C0A202022343238353232222C0A202022343335393634222C0A202022343433373237222C0A202022343532393736222C0A202022343631303030222C0A202022343639373335222C0A202022343736383030222C0A202022343833313535222C0A202022343933343039222C0A202022353038383939222C0A202022353139373933222C0A202022353239393030222C0A202022353430383238222C0A202022353633363632222C0A202022353830303030222C0A202022353934353031222C0A202022363136373030222C0A202022363336373635222C0A202022363536393235222C0A202022363830333332222C0A202022373033353932222C0A202022373335313637222C0A202022373634393032222C0A202022373937373335222C0A202022383330303030222C0A202022383737323339222C0A202022393430353839222C0A202022393933343030222C0A20202231303432373430222C0A20202231313030303030222C0A20202231313536313030222C0A20202231323137383138222C0A20202231333030393737222C0A20202231333932383630222C0A20202231353137353530222C0A20202231363832303030222C0A20202231393639383638222C0A20202232313534333736222C0A20202232353
935363734222C0A20202232393634363338222C0A20202234323536333030222C0A20202236373538383435220A5D
-decode_histogram(hist_type,histogram) [
- "1438",
- "5055",
- "13000",
- "25888",
- "50699",
- "89053",
- "89388",
- "89881",
- "90111",
- "90601",
- "90951",
- "91200",
- "91777",
- "92224",
- "92583",
- "92988",
- "93300",
- "93818",
- "94100",
- "94600",
- "94934",
- "95400",
- "95933",
- "96291",
- "96800",
- "97100",
- "97451",
- "98080",
- "98342",
- "98781",
- "99367",
- "99799",
- "100118",
- "100478",
- "100887",
- "101205",
- "101574",
- "101984",
- "102294",
- "102681",
- "103171",
- "103544",
- "103984",
- "104700",
- "105119",
- "105690",
- "106001",
- "106414",
- "107000",
- "107329",
- "107761",
- "108100",
- "108574",
- "109121",
- "109500",
- "109965",
- "110388",
- "111100",
- "111752",
- "112375",
- "113080",
- "113800",
- "114233",
- "114876",
- "115532",
- "116178",
- "116695",
- "117227",
- "117865",
- "118718",
- "119283",
- "119796",
- "120265",
- "121000",
- "121600",
- "121954",
- "122705",
- "123359",
- "123865",
- "124207",
- "124735",
- "125255",
- "125766",
- "126282",
- "126820",
- "127222",
- "127801",
- "128300",
- "129300",
- "130000",
- "131000",
- "131717",
- "132455",
- "133106",
- "133642",
- "134037",
- "135010",
- "136216",
- "137028",
- "137776",
- "138418",
- "139283",
- "140030",
- "140800",
- "142044",
- "142659",
- "143726",
- "144582",
- "145800",
- "146439",
- "147523",
- "148105",
- "149146",
- "150100",
- "151060",
- "152442",
- "153364",
- "154980",
- "155800",
- "157300",
- "158335",
- "159632",
- "161161",
- "162300",
- "163849",
- "164747",
- "166467",
- "167461",
- "169300",
- "170428",
- "171532",
- "172701",
- "173895",
- "174985",
- "176576",
- "178182",
- "179208",
- "180210",
- "181805",
- "183100",
- "184061",
- "185401",
- "186900",
- "188344",
- "189569",
- "190905",
- "193005",
- "194300",
- "195500",
- "197254",
- "199000",
- "200901",
- "202134",
- "203793",
- "206158",
- "207588",
- "210068",
- "212976",
- "214950",
- "216735",
- "218447",
- "221000",
- "222518",
- "224887",
- "227657",
- "229425",
- "233041",
- "236000",
- "239124",
- "241649",
- "243742",
- "245772",
- "248245",
- "252386",
- "254842",
- "257812",
- "262000",
- "264081",
- "266281",
- "270251",
- "272968",
- "276421",
- "279340",
- "282941",
- "286900",
- "291000",
- "294056",
- "298900",
- "301276",
- "304477",
- "309750",
- "313530",
- "317600",
- "322267",
- "326399",
- "330276",
- "334563",
- "339131",
- "342738",
- "349246",
- "353632",
- "359147",
- "362470",
- "366549",
- "372840",
- "380755",
- "385201",
- "392830",
- "400997",
- "409100",
- "416988",
- "421589",
- "428522",
- "435964",
- "443727",
- "452976",
- "461000",
- "469735",
- "476800",
- "483155",
- "493409",
- "508899",
- "519793",
- "529900",
- "540828",
- "563662",
- "580000",
- "594501",
- "616700",
- "636765",
- "656925",
- "680332",
- "703592",
- "735167",
- "764902",
- "797735",
- "830000",
- "877239",
- "940589",
- "993400",
- "1042740",
- "1100000",
- "1156100",
- "1217818",
- "1300977",
- "1392860",
- "1517550",
- "1682000",
- "1969868",
- "2154376",
- "2595674",
- "2964638",
- "4256300",
- "6758845"
-]
+hex(histogram) 7B0A202022686973746F6772616D5F68625F7631223A205B0A202020202231343338222C0A202020202235303535222C0A20202020223133303030222C0A20202020223235383838222C0A20202020223530363939222C0A20202020223839303533222C0A20202020223839333838222C0A20202020223839383831222C0A20202020223930313131222C0A20202020223930363031222C0A20202020223930393531222C0A20202020223931323030222C0A20202020223931373737222C0A20202020223932323234222C0A20202020223932353833222C0A20202020223932393838222C0A20202020223933333030222C0A20202020223933383138222C0A20202020223934313030222C0A20202020223934363030222C0A20202020223934393334222C0A20202020223935343030222C0A20202020223935393333222C0A20202020223936323931222C0A20202020223936383030222C0A20202020223937313030222C0A20202020223937343531222C0A20202020223938303830222C0A20202020223938333432222C0A20202020223938373831222C0A20202020223939333637222C0A20202020223939373939222C0A2020202022313030313138222C0A2020202022313030343738222C0A2020202022313030383837222C0A20202020223130313230
35222C0A2020202022313031353734222C0A2020202022313031393834222C0A2020202022313032323934222C0A2020202022313032363831222C0A2020202022313033313731222C0A2020202022313033353434222C0A2020202022313033393834222C0A2020202022313034373030222C0A2020202022313035313139222C0A2020202022313035363930222C0A2020202022313036303031222C0A2020202022313036343134222C0A2020202022313037303030222C0A2020202022313037333239222C0A2020202022313037373631222C0A2020202022313038313030222C0A2020202022313038353734222C0A2020202022313039313231222C0A2020202022313039353030222C0A2020202022313039393635222C0A2020202022313130333838222C0A2020202022313131313030222C0A2020202022313131373532222C0A2020202022313132333735222C0A2020202022313133303830222C0A2020202022313133383030222C0A2020202022313134323333222C0A2020202022313134383736222C0A2020202022313135353332222C0A2020202022313136313738222C0A2020202022313136363935222C0A2020202022313137323237222C0A2020202022313137383635222C0A2020202022313138373138222C0A2020202022313139323833222C0A202020202
2313139373936222C0A2020202022313230323635222C0A2020202022313231303030222C0A2020202022313231363030222C0A2020202022313231393534222C0A2020202022313232373035222C0A2020202022313233333539222C0A2020202022313233383635222C0A2020202022313234323037222C0A2020202022313234373335222C0A2020202022313235323535222C0A2020202022313235373636222C0A2020202022313236323832222C0A2020202022313236383230222C0A2020202022313237323232222C0A2020202022313237383031222C0A2020202022313238333030222C0A2020202022313239333030222C0A2020202022313330303030222C0A2020202022313331303030222C0A2020202022313331373137222C0A2020202022313332343535222C0A2020202022313333313036222C0A2020202022313333363432222C0A2020202022313334303337222C0A2020202022313335303130222C0A2020202022313336323136222C0A2020202022313337303238222C0A2020202022313337373736222C0A2020202022313338343138222C0A2020202022313339323833222C0A2020202022313430303330222C0A2020202022313430383030222C0A2020202022313432303434222C0A2020202022313432363539222C0A2020202022313433373236222C
0A2020202022313434353832222C0A2020202022313435383030222C0A2020202022313436343339222C0A2020202022313437353233222C0A2020202022313438313035222C0A2020202022313439313436222C0A2020202022313530313030222C0A2020202022313531303630222C0A2020202022313532343432222C0A2020202022313533333634222C0A2020202022313534393830222C0A2020202022313535383030222C0A2020202022313537333030222C0A2020202022313538333335222C0A2020202022313539363332222C0A2020202022313631313631222C0A2020202022313632333030222C0A2020202022313633383439222C0A2020202022313634373437222C0A2020202022313636343637222C0A2020202022313637343631222C0A2020202022313639333030222C0A2020202022313730343238222C0A2020202022313731353332222C0A2020202022313732373031222C0A2020202022313733383935222C0A2020202022313734393835222C0A2020202022313736353736222C0A2020202022313738313832222C0A2020202022313739323038222C0A2020202022313830323130222C0A2020202022313831383035222C0A2020202022313833313030222C0A2020202022313834303631222C0A2020202022313835343031222C0A202020202231383
6393030222C0A2020202022313838333434222C0A2020202022313839353639222C0A2020202022313930393035222C0A2020202022313933303035222C0A2020202022313934333030222C0A2020202022313935353030222C0A2020202022313937323534222C0A2020202022313939303030222C0A2020202022323030393031222C0A2020202022323032313334222C0A2020202022323033373933222C0A2020202022323036313538222C0A2020202022323037353838222C0A2020202022323130303638222C0A2020202022323132393736222C0A2020202022323134393530222C0A2020202022323136373335222C0A2020202022323138343437222C0A2020202022323231303030222C0A2020202022323232353138222C0A2020202022323234383837222C0A2020202022323237363537222C0A2020202022323239343235222C0A2020202022323333303431222C0A2020202022323336303030222C0A2020202022323339313234222C0A2020202022323431363439222C0A2020202022323433373432222C0A2020202022323435373732222C0A2020202022323438323435222C0A2020202022323532333836222C0A2020202022323534383432222C0A2020202022323537383132222C0A2020202022323632303030222C0A2020202022323634303831222C0A2020
202022323636323831222C0A2020202022323730323531222C0A2020202022323732393638222C0A2020202022323736343231222C0A2020202022323739333430222C0A2020202022323832393431222C0A2020202022323836393030222C0A2020202022323931303030222C0A2020202022323934303536222C0A2020202022323938393030222C0A2020202022333031323736222C0A2020202022333034343737222C0A2020202022333039373530222C0A2020202022333133353330222C0A2020202022333137363030222C0A2020202022333232323637222C0A2020202022333236333939222C0A2020202022333330323736222C0A2020202022333334353633222C0A2020202022333339313331222C0A2020202022333432373338222C0A2020202022333439323436222C0A2020202022333533363332222C0A2020202022333539313437222C0A2020202022333632343730222C0A2020202022333636353439222C0A2020202022333732383430222C0A2020202022333830373535222C0A2020202022333835323031222C0A2020202022333932383330222C0A2020202022343030393937222C0A2020202022343039313030222C0A2020202022343136393838222C0A2020202022343231353839222C0A2020202022343238353232222C0A202020202234333539363
4222C0A2020202022343433373237222C0A2020202022343532393736222C0A2020202022343631303030222C0A2020202022343639373335222C0A2020202022343736383030222C0A2020202022343833313535222C0A2020202022343933343039222C0A2020202022353038383939222C0A2020202022353139373933222C0A2020202022353239393030222C0A2020202022353430383238222C0A2020202022353633363632222C0A2020202022353830303030222C0A2020202022353934353031222C0A2020202022363136373030222C0A2020202022363336373635222C0A2020202022363536393235222C0A2020202022363830333332222C0A2020202022373033353932222C0A2020202022373335313637222C0A2020202022373634393032222C0A2020202022373937373335222C0A2020202022383330303030222C0A2020202022383737323339222C0A2020202022393430353839222C0A2020202022393933343030222C0A202020202231303432373430222C0A202020202231313030303030222C0A202020202231313536313030222C0A202020202231323137383138222C0A202020202231333030393737222C0A202020202231333932383630222C0A202020202231353137353530222C0A202020202231363832303030222C0A2020202022313936393836
38222C0A202020202232313534333736222C0A202020202232353935363734222C0A202020202232393634363338222C0A202020202234323536333030222C0A202020202236373538383435220A20205D0A7D
+decode_histogram(hist_type,histogram) {
+ "histogram_hb_v1": [
+ "1438",
+ "5055",
+ "13000",
+ "25888",
+ "50699",
+ "89053",
+ "89388",
+ "89881",
+ "90111",
+ "90601",
+ "90951",
+ "91200",
+ "91777",
+ "92224",
+ "92583",
+ "92988",
+ "93300",
+ "93818",
+ "94100",
+ "94600",
+ "94934",
+ "95400",
+ "95933",
+ "96291",
+ "96800",
+ "97100",
+ "97451",
+ "98080",
+ "98342",
+ "98781",
+ "99367",
+ "99799",
+ "100118",
+ "100478",
+ "100887",
+ "101205",
+ "101574",
+ "101984",
+ "102294",
+ "102681",
+ "103171",
+ "103544",
+ "103984",
+ "104700",
+ "105119",
+ "105690",
+ "106001",
+ "106414",
+ "107000",
+ "107329",
+ "107761",
+ "108100",
+ "108574",
+ "109121",
+ "109500",
+ "109965",
+ "110388",
+ "111100",
+ "111752",
+ "112375",
+ "113080",
+ "113800",
+ "114233",
+ "114876",
+ "115532",
+ "116178",
+ "116695",
+ "117227",
+ "117865",
+ "118718",
+ "119283",
+ "119796",
+ "120265",
+ "121000",
+ "121600",
+ "121954",
+ "122705",
+ "123359",
+ "123865",
+ "124207",
+ "124735",
+ "125255",
+ "125766",
+ "126282",
+ "126820",
+ "127222",
+ "127801",
+ "128300",
+ "129300",
+ "130000",
+ "131000",
+ "131717",
+ "132455",
+ "133106",
+ "133642",
+ "134037",
+ "135010",
+ "136216",
+ "137028",
+ "137776",
+ "138418",
+ "139283",
+ "140030",
+ "140800",
+ "142044",
+ "142659",
+ "143726",
+ "144582",
+ "145800",
+ "146439",
+ "147523",
+ "148105",
+ "149146",
+ "150100",
+ "151060",
+ "152442",
+ "153364",
+ "154980",
+ "155800",
+ "157300",
+ "158335",
+ "159632",
+ "161161",
+ "162300",
+ "163849",
+ "164747",
+ "166467",
+ "167461",
+ "169300",
+ "170428",
+ "171532",
+ "172701",
+ "173895",
+ "174985",
+ "176576",
+ "178182",
+ "179208",
+ "180210",
+ "181805",
+ "183100",
+ "184061",
+ "185401",
+ "186900",
+ "188344",
+ "189569",
+ "190905",
+ "193005",
+ "194300",
+ "195500",
+ "197254",
+ "199000",
+ "200901",
+ "202134",
+ "203793",
+ "206158",
+ "207588",
+ "210068",
+ "212976",
+ "214950",
+ "216735",
+ "218447",
+ "221000",
+ "222518",
+ "224887",
+ "227657",
+ "229425",
+ "233041",
+ "236000",
+ "239124",
+ "241649",
+ "243742",
+ "245772",
+ "248245",
+ "252386",
+ "254842",
+ "257812",
+ "262000",
+ "264081",
+ "266281",
+ "270251",
+ "272968",
+ "276421",
+ "279340",
+ "282941",
+ "286900",
+ "291000",
+ "294056",
+ "298900",
+ "301276",
+ "304477",
+ "309750",
+ "313530",
+ "317600",
+ "322267",
+ "326399",
+ "330276",
+ "334563",
+ "339131",
+ "342738",
+ "349246",
+ "353632",
+ "359147",
+ "362470",
+ "366549",
+ "372840",
+ "380755",
+ "385201",
+ "392830",
+ "400997",
+ "409100",
+ "416988",
+ "421589",
+ "428522",
+ "435964",
+ "443727",
+ "452976",
+ "461000",
+ "469735",
+ "476800",
+ "483155",
+ "493409",
+ "508899",
+ "519793",
+ "529900",
+ "540828",
+ "563662",
+ "580000",
+ "594501",
+ "616700",
+ "636765",
+ "656925",
+ "680332",
+ "703592",
+ "735167",
+ "764902",
+ "797735",
+ "830000",
+ "877239",
+ "940589",
+ "993400",
+ "1042740",
+ "1100000",
+ "1156100",
+ "1217818",
+ "1300977",
+ "1392860",
+ "1517550",
+ "1682000",
+ "1969868",
+ "2154376",
+ "2595674",
+ "2964638",
+ "4256300",
+ "6758845"
+ ]
+}
set histogram_type=@SINGLE_PREC_TYPE;
set histogram_size=0;
use test;
@@ -1943,7 +1947,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 1 3 0.0000 1.0000 10 JSON_HB 5B0A20202231222C0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202233220A5D
+test t1 a 1 3 0.0000 1.0000 10 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2231222C202231222C202231222C202232222C202232222C202232222C202232222C202233222C202233222C202233225D0A7D
set histogram_size=default;
drop table t1;
#
@@ -1968,7 +1972,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 1 5 0.0000 1.0000 10 JSON_HB 5B0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202234222C0A20202234222C0A20202235222C0A20202235220A5D
+test t1 a 1 5 0.0000 1.0000 10 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B2231222C202231222C202232222C202232222C202233222C202233222C202234222C202234222C202235222C202235225D0A7D
set histogram_size=0;
set histogram_type=@SINGLE_PREC_TYPE;
drop table t1;
@@ -2009,7 +2013,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t2 id 1 1024 0.0000 8.0000 63 JSON_HB 5B0A2020223137222C0A2020223333222C0A2020223439222C0A2020223635222C0A2020223831222C0A2020223937222C0A202022313133222C0A202022313239222C0A202022313435222C0A202022313631222C0A202022313737222C0A202022313933222C0A202022323039222C0A202022323235222C0A202022323431222C0A202022323537222C0A202022323733222C0A202022323839222C0A202022333035222C0A202022333231222C0A202022333337222C0A202022333533222C0A202022333639222C0A202022333835222C0A202022343031222C0A202022343137222C0A202022343333222C0A202022343439222C0A202022343635222C0A202022343831222C0A202022343937222C0A202022353133222C0A202022353239222C0A202022353435222C0A202022353631222C0A202022353737222C0A202022353933222C0A202022363039222C0A202022363235222C0A202022363431222C0A202022363537222C0A202022363733222C0A202022363839222C0A202022373035222C0A202022373231222C0A202022373337222C0A202022373533222C0A202022373639222C0A202022373835222C0A202022383031222C0A202022383137222C0A202022383333222C0A202022383439222C0A20202238
3635222C0A202022383831222C0A202022383937222C0A202022393133222C0A202022393239222C0A202022393435222C0A202022393631222C0A202022393737222C0A202022393933222C0A20202231303039220A5D
+test t2 id 1 1024 0.0000 8.0000 63 JSON_HB 7B0A202022686973746F6772616D5F68625F7631223A205B0A20202020223137222C0A20202020223333222C0A20202020223439222C0A20202020223635222C0A20202020223831222C0A20202020223937222C0A2020202022313133222C0A2020202022313239222C0A2020202022313435222C0A2020202022313631222C0A2020202022313737222C0A2020202022313933222C0A2020202022323039222C0A2020202022323235222C0A2020202022323431222C0A2020202022323537222C0A2020202022323733222C0A2020202022323839222C0A2020202022333035222C0A2020202022333231222C0A2020202022333337222C0A2020202022333533222C0A2020202022333639222C0A2020202022333835222C0A2020202022343031222C0A2020202022343137222C0A2020202022343333222C0A2020202022343439222C0A2020202022343635222C0A2020202022343831222C0A2020202022343937222C0A2020202022353133222C0A2020202022353239222C0A2020202022353435222C0A2020202022353631222C0A2020202022353737222C0A2020202022353933222C0A2020202022363039222C0A2020202022363235222C0A2020202022363431222C0A2020202022363537222C0A20202020223637
33222C0A2020202022363839222C0A2020202022373035222C0A2020202022373231222C0A2020202022373337222C0A2020202022373533222C0A2020202022373639222C0A2020202022373835222C0A2020202022383031222C0A2020202022383137222C0A2020202022383333222C0A2020202022383439222C0A2020202022383635222C0A2020202022383831222C0A2020202022383937222C0A2020202022393133222C0A2020202022393239222C0A2020202022393435222C0A2020202022393631222C0A2020202022393737222C0A2020202022393933222C0A202020202231303039220A20205D0A7D
set histogram_size=0;
drop table t1, t2;
set use_stat_tables=@save_use_stat_tables;
@@ -2169,18 +2173,20 @@ select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, a
DECODE_HISTOGRAM(hist_type, histogram)
from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
-t1 id 1 17384 0.0000 4.0000 14.0000 [
- "1490",
- "2979",
- "4469",
- "5958",
- "7448",
- "9937",
- "11427",
- "12916",
- "14406",
- "15895"
-]
+t1 id 1 17384 0.0000 4.0000 14.0000 {
+ "histogram_hb_v1": [
+ "1490",
+ "2979",
+ "4469",
+ "5958",
+ "7448",
+ "9937",
+ "11427",
+ "12916",
+ "14406",
+ "15895"
+ ]
+}
set analyze_sample_percentage=0.1;
#
# This query will show an innacurate avg_frequency value.
@@ -2193,18 +2199,20 @@ select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, a
DECODE_HISTOGRAM(hist_type, histogram)
from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
-t1 id 111 17026 0.0000 4.0000 10.4739 [
- "832",
- "2446",
- "3422",
- "5411",
- "6687",
- "9390",
- "10738",
- "12738",
- "14365",
- "15411"
-]
+t1 id 111 17026 0.0000 4.0000 10.4739 {
+ "histogram_hb_v1": [
+ "832",
+ "2446",
+ "3422",
+ "5411",
+ "6687",
+ "9390",
+ "10738",
+ "12738",
+ "14365",
+ "15411"
+ ]
+}
#
# This query will show a better avg_frequency value.
#
@@ -2217,18 +2225,20 @@ select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, a
DECODE_HISTOGRAM(hist_type, histogram)
from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
-t1 id 1 17384 0.0000 4.0000 14.0401 [
- "1478",
- "2954",
- "4441",
- "5894",
- "7397",
- "9888",
- "11391",
- "12895",
- "14370",
- "15880"
-]
+t1 id 1 17384 0.0000 4.0000 14.0401 {
+ "histogram_hb_v1": [
+ "1478",
+ "2954",
+ "4441",
+ "5894",
+ "7397",
+ "9888",
+ "11391",
+ "12895",
+ "14370",
+ "15880"
+ ]
+}
set analyze_sample_percentage=0;
#
# Test self adjusting sampling level.
@@ -2241,18 +2251,20 @@ select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, a
DECODE_HISTOGRAM(hist_type, histogram)
from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
-t1 id 1 17384 0.0000 4.0000 13.9812 [
- "1500",
- "3009",
- "4501",
- "5997",
- "7493",
- "9981",
- "11456",
- "12932",
- "14408",
- "15903"
-]
+t1 id 1 17384 0.0000 4.0000 13.9812 {
+ "histogram_hb_v1": [
+ "1500",
+ "3009",
+ "4501",
+ "5997",
+ "7493",
+ "9981",
+ "11456",
+ "12932",
+ "14408",
+ "15903"
+ ]
+}
#
# Test record estimation is working properly.
#
@@ -2271,18 +2283,20 @@ select table_name, column_name, min_value, max_value, nulls_ratio, avg_length, a
DECODE_HISTOGRAM(hist_type, histogram)
from mysql.column_stats;
table_name column_name min_value max_value nulls_ratio avg_length avg_frequency DECODE_HISTOGRAM(hist_type, histogram)
-t1 id 1 17384 0.0000 4.0000 14.0000 [
- "1490",
- "2979",
- "4469",
- "5958",
- "7448",
- "9937",
- "11427",
- "12916",
- "14406",
- "15895"
-]
+t1 id 1 17384 0.0000 4.0000 14.0000 {
+ "histogram_hb_v1": [
+ "1490",
+ "2979",
+ "4469",
+ "5958",
+ "7448",
+ "9937",
+ "11427",
+ "12916",
+ "14406",
+ "15895"
+ ]
+}
explain select * from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 229376
@@ -2324,108 +2338,110 @@ test.t1_json analyze status Engine-independent statistics collected
test.t1_json analyze status OK
select * from mysql.column_stats where table_name='t1_json';
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
-test t1_json a a-0 a-9 0.0000 3.0000 1.0000 100 JSON_HB [
- "a-0",
- "a-0",
- "a-0",
- "a-0",
- "a-0",
- "a-0",
- "a-0",
- "a-0",
- "a-0",
- "a-0",
- "a-1",
- "a-1",
- "a-1",
- "a-1",
- "a-1",
- "a-1",
- "a-1",
- "a-1",
- "a-1",
- "a-1",
- "a-2",
- "a-2",
- "a-2",
- "a-2",
- "a-2",
- "a-2",
- "a-2",
- "a-2",
- "a-2",
- "a-2",
- "a-3",
- "a-3",
- "a-3",
- "a-3",
- "a-3",
- "a-3",
- "a-3",
- "a-3",
- "a-3",
- "a-3",
- "a-4",
- "a-4",
- "a-4",
- "a-4",
- "a-4",
- "a-4",
- "a-4",
- "a-4",
- "a-4",
- "a-4",
- "a-5",
- "a-5",
- "a-5",
- "a-5",
- "a-5",
- "a-5",
- "a-5",
- "a-5",
- "a-5",
- "a-5",
- "a-6",
- "a-6",
- "a-6",
- "a-6",
- "a-6",
- "a-6",
- "a-6",
- "a-6",
- "a-6",
- "a-6",
- "a-7",
- "a-7",
- "a-7",
- "a-7",
- "a-7",
- "a-7",
- "a-7",
- "a-7",
- "a-7",
- "a-7",
- "a-8",
- "a-8",
- "a-8",
- "a-8",
- "a-8",
- "a-8",
- "a-8",
- "a-8",
- "a-8",
- "a-8",
- "a-9",
- "a-9",
- "a-9",
- "a-9",
- "a-9",
- "a-9",
- "a-9",
- "a-9",
- "a-9",
- "a-9"
-]
+test t1_json a a-0 a-9 0.0000 3.0000 1.0000 100 JSON_HB {
+ "histogram_hb_v1": [
+ "a-0",
+ "a-0",
+ "a-0",
+ "a-0",
+ "a-0",
+ "a-0",
+ "a-0",
+ "a-0",
+ "a-0",
+ "a-0",
+ "a-1",
+ "a-1",
+ "a-1",
+ "a-1",
+ "a-1",
+ "a-1",
+ "a-1",
+ "a-1",
+ "a-1",
+ "a-1",
+ "a-2",
+ "a-2",
+ "a-2",
+ "a-2",
+ "a-2",
+ "a-2",
+ "a-2",
+ "a-2",
+ "a-2",
+ "a-2",
+ "a-3",
+ "a-3",
+ "a-3",
+ "a-3",
+ "a-3",
+ "a-3",
+ "a-3",
+ "a-3",
+ "a-3",
+ "a-3",
+ "a-4",
+ "a-4",
+ "a-4",
+ "a-4",
+ "a-4",
+ "a-4",
+ "a-4",
+ "a-4",
+ "a-4",
+ "a-4",
+ "a-5",
+ "a-5",
+ "a-5",
+ "a-5",
+ "a-5",
+ "a-5",
+ "a-5",
+ "a-5",
+ "a-5",
+ "a-5",
+ "a-6",
+ "a-6",
+ "a-6",
+ "a-6",
+ "a-6",
+ "a-6",
+ "a-6",
+ "a-6",
+ "a-6",
+ "a-6",
+ "a-7",
+ "a-7",
+ "a-7",
+ "a-7",
+ "a-7",
+ "a-7",
+ "a-7",
+ "a-7",
+ "a-7",
+ "a-7",
+ "a-8",
+ "a-8",
+ "a-8",
+ "a-8",
+ "a-8",
+ "a-8",
+ "a-8",
+ "a-8",
+ "a-8",
+ "a-8",
+ "a-9",
+ "a-9",
+ "a-9",
+ "a-9",
+ "a-9",
+ "a-9",
+ "a-9",
+ "a-9",
+ "a-9",
+ "a-9"
+ ]
+}
explain extended select * from t1_json where a between 'a-3a' and 'zzzzzzzzz';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 60.87 Using where
@@ -2441,46 +2457,47 @@ Warnings:
Note 1003 select `test`.`t1_json`.`a` AS `a` from `test`.`t1_json` where `test`.`t1_json`.`a` < 'b-1a'
analyze select * from t1_json where a > 'zzzzzzzzz';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 0.00 0.00 Using where
+1 SIMPLE t1_json ALL NULL NULL NULL NULL 10 10.00 10.00 0.00 Using where
+drop table ten;
UPDATE mysql.column_stats SET histogram='["a-1", "a-2", {"a": "b"}, "a-3"]' WHERE table_name='t1_json';
FLUSH TABLES;
explain extended select * from t1_json where a between 'a-3a' and 'zzzzzzzzz';
-ERROR HY000: Failed to parse histogram, encountered JSON_TYPE '1'.
-create table users (
+ERROR HY000: Failed to parse histogram: Root JSON element must be a JSON object at offset 1.
+create table t2 (
city varchar(100)
);
set histogram_size=50;
-insert into users select 'Moscow' from seq_1_to_99;
-insert into users select 'Helsinki' from seq_1_to_2;
+insert into t2 select 'Moscow' from seq_1_to_99;
+insert into t2 select 'Helsinki' from seq_1_to_2;
set histogram_type=json_hb;
-analyze table users persistent for all;
+analyze table t2 persistent for all;
Table Op Msg_type Msg_text
-test.users analyze status Engine-independent statistics collected
-test.users analyze status OK
-explain extended select * from users where city = 'Moscow';
+test.t2 analyze status Engine-independent statistics collected
+test.t2 analyze status OK
+explain extended select * from t2 where city = 'Moscow';
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE users ALL NULL NULL NULL NULL 101 98.04 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 101 98.04 Using where
Warnings:
-Note 1003 select `test`.`users`.`city` AS `city` from `test`.`users` where `test`.`users`.`city` = 'Moscow'
-analyze select * from users where city = 'Moscow';
+Note 1003 select `test`.`t2`.`city` AS `city` from `test`.`t2` where `test`.`t2`.`city` = 'Moscow'
+analyze select * from t2 where city = 'Moscow';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE users ALL NULL NULL NULL NULL 101 101.00 98.04 98.02 Using where
-explain extended select * from users where city = 'Helsinki';
+1 SIMPLE t2 ALL NULL NULL NULL NULL 101 101.00 98.04 98.02 Using where
+explain extended select * from t2 where city = 'Helsinki';
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE users ALL NULL NULL NULL NULL 101 2.00 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 101 2.00 Using where
Warnings:
-Note 1003 select `test`.`users`.`city` AS `city` from `test`.`users` where `test`.`users`.`city` = 'Helsinki'
-analyze select * from users where city = 'helsinki';
+Note 1003 select `test`.`t2`.`city` AS `city` from `test`.`t2` where `test`.`t2`.`city` = 'Helsinki'
+analyze select * from t2 where city = 'helsinki';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
-1 SIMPLE users ALL NULL NULL NULL NULL 101 101.00 2.00 1.98 Using where
-explain extended select * from users where city < 'Lagos';
+1 SIMPLE t2 ALL NULL NULL NULL NULL 101 101.00 2.00 1.98 Using where
+explain extended select * from t2 where city < 'Lagos';
id select_type table type possible_keys key key_len ref rows filtered Extra
-1 SIMPLE users ALL NULL NULL NULL NULL 101 3.58 Using where
+1 SIMPLE t2 ALL NULL NULL NULL NULL 101 50.00 Using where
Warnings:
-Note 1003 select `test`.`users`.`city` AS `city` from `test`.`users` where `test`.`users`.`city` < 'Lagos'
+Note 1003 select `test`.`t2`.`city` AS `city` from `test`.`t2` where `test`.`t2`.`city` < 'Lagos'
drop table t1_bin;
drop table t1_json;
-drop table users;
+drop table t2;
DELETE FROM mysql.column_stats;
create schema world;
use world;
@@ -2489,630 +2506,654 @@ set histogram_size=50;
ANALYZE TABLE Country, City, CountryLanguage persistent for all;
SELECT column_name, min_value, max_value, hist_size, hist_type, histogram FROM mysql.column_stats;
column_name min_value max_value hist_size hist_type histogram
-Code ABW ZWE 50 JSON_HB [
- "ALB",
- "ARM",
- "AUS",
- "BEL",
- "BHR",
- "BMU",
- "BRN",
- "CAN",
- "CIV",
- "COK",
- "CUB",
- "DEU",
- "DOM",
- "ESH",
- "FJI",
- "FSM",
- "GIB",
- "GNQ",
- "GUF",
- "HMD",
- "IDN",
- "IRQ",
- "JAM",
- "KGZ",
- "KWT",
- "LBY",
- "LTU",
- "MCO",
- "MEX",
- "MMR",
- "MSR",
- "MYS",
- "NFK",
- "NOR",
- "PAK",
- "PHL",
- "PRK",
- "QAT",
- "RWA",
- "SGS",
- "SLV",
- "STP",
- "SWZ",
- "TGO",
- "TKM",
- "TUR",
- "UKR",
- "UZB",
- "VIR",
- "YEM"
-]
-Name Afghanistan Zimbabwe 50 JSON_HB [
- "Andorra",
- "Argentina",
- "Azerbaijan",
- "Barbados",
- "Bermuda",
- "Bouvet Island",
- "Bulgaria",
- "Canada",
- "Chile",
- "Colombia",
- "Costa Rica",
- "Côte d’Ivoire",
- "Dominican Republic",
- "Equatorial Guinea",
- "Faroe Islands",
- "French Guiana",
- "Georgia",
- "Greenland",
- "Guinea",
- "Heard Island and McDonald Islands",
- "Iceland",
- "Ireland",
- "Japan",
- "Kuwait",
- "Lesotho",
- "Lithuania",
- "Malawi",
- "Marshall Islands",
- "Mayotte",
- "Mongolia",
- "Namibia",
- "Netherlands Antilles",
- "Nigeria",
- "Norway",
- "Panama",
- "Philippines",
- "Qatar",
- "Saint Helena",
- "Saint Vincent and the Grenadines",
- "Senegal",
- "Slovenia",
- "South Georgia and the South Sandwich Islands",
- "Suriname",
- "Syria",
- "Thailand",
- "Tunisia",
- "Uganda",
- "United States",
- "Venezuela",
- "Western Sahara"
-]
-SurfaceArea 0.40 17075400.00 50 JSON_HB [
- "14.00",
- "36.00",
- "78.00",
- "151.00",
- "200.00",
- "264.00",
- "344.00",
- "430.00",
- "464.00",
- "622.00",
- "751.00",
- "1399.00",
- "2510.00",
- "4033.00",
- "8875.00",
- "11000.00",
- "14874.00",
- "20256.00",
- "25713.00",
- "28051.00",
- "30518.00",
- "41526.00",
- "48511.00",
- "56785.00",
- "69700.00",
- "78866.00",
- "90000.00",
- "103000.00",
- "111369.00",
- "120538.00",
- "147181.00",
- "181035.00",
- "214969.00",
- "242900.00",
- "274000.00",
- "309500.00",
- "331689.00",
- "390757.00",
- "447400.00",
- "505992.00",
- "581730.00",
- "637657.00",
- "774815.00",
- "912050.00",
- "1098581.00",
- "1246700.00",
- "1648195.00",
- "2149690.00",
- "2724900.00",
- "9363520.00"
-]
-Population 0 1277558000 50 JSON_HB [
- "0",
- "1000",
- "2500",
- "8000",
- "17000",
- "27000",
- "38000",
- "68000",
- "78000",
- "99000",
- "149000",
- "190000",
- "241000",
- "307000",
- "428000",
- "456000",
- "638000",
- "885000",
- "1295000",
- "1726000",
- "2153000",
- "2662000",
- "3101000",
- "3520000",
- "3850000",
- "4023000",
- "4629000",
- "5074000",
- "5398700",
- "6188000",
- "6782000",
- "7733000",
- "8329000",
- "9586000",
- "10239000",
- "10730000",
- "11385000",
- "14786000",
- "15942000",
- "18886000",
- "22244000",
- "23115000",
- "25662000",
- "31471000",
- "39441700",
- "50456000",
- "61399000",
- "68470000",
- "111506000",
- "170115000"
-]
-Capital 1 4074 50 JSON_HB [
- "35",
- "63",
- "129",
- "150",
- "187",
- "204",
- "538",
- "554",
- "586",
- "652",
- "764",
- "904",
- "917",
- "926",
- "937",
- "1365",
- "1464",
- "1532",
- "1800",
- "1864",
- "2256",
- "2317",
- "2409",
- "2434",
- "2441",
- "2454",
- "2463",
- "2507",
- "2514",
- "2696",
- "2728",
- "2754",
- "2821",
- "2884",
- "2914",
- "2973",
- "3018",
- "3064",
- "3161",
- "3172",
- "3208",
- "3225",
- "3248",
- "3315",
- "3334",
- "3358",
- "3425",
- "3499",
- "3537",
- "3791"
-]
-ID 1 4079 50 JSON_HB [
- "80",
- "160",
- "240",
- "320",
- "400",
- "480",
- "560",
- "640",
- "720",
- "800",
- "880",
- "960",
- "1040",
- "1120",
- "1200",
- "1280",
- "1360",
- "1440",
- "1520",
- "1600",
- "1680",
- "1760",
- "1840",
- "1920",
- "2000",
- "2080",
- "2160",
- "2240",
- "2320",
- "2400",
- "2480",
- "2560",
- "2640",
- "2720",
- "2800",
- "2880",
- "2960",
- "3040",
- "3120",
- "3200",
- "3280",
- "3360",
- "3440",
- "3520",
- "3600",
- "3680",
- "3760",
- "3840",
- "3920",
- "4000"
-]
-Name A Coruña (La Coruña) Ürgenc 50 JSON_HB [
- "Allentown",
- "Araguari",
- "Bahtim",
- "Batangas",
- "Bialystok",
- "Brampton",
- "Calama",
- "Changchun",
- "Ciomas",
- "Cuautla",
- "Detroit",
- "Effon-Alaiye",
- "Firozabad",
- "Gebze",
- "Guangyuan",
- "Hangzhou",
- "Hradec Králové",
- "Inazawa",
- "Jalib al-Shuyukh",
- "Jubayl",
- "Kassel",
- "Kitakyushu",
- "Kunshan",
- "Le Mans",
- "Longueuil",
- "Malang",
- "Mati",
- "Mishan",
- "Muroran",
- "Natal",
- "North York",
- "Omsk",
- "Palu",
- "Phoenix",
- "Poznan",
- "Quezon",
- "Rishra",
- "Salem",
- "Sancti-SpÃritus",
- "Sekondi-Takoradi",
- "Silao",
- "Stoke-on-Trent",
- "Taegu",
- "Teheran",
- "Tomsk",
- "Târgu Mures",
- "Varginha",
- "Weifang",
- "Yangjiang",
- "Zhaodong"
-]
-Country ABW ZWE 50 JSON_HB [
- "ARM",
- "BHS",
- "BRA",
- "BRA",
- "BRA",
- "CAN",
- "CHN",
- "CHN",
- "CHN",
- "CHN",
- "CHN",
- "COL",
- "DEU",
- "DZA",
- "ESP",
- "FRA",
- "GBR",
- "IDN",
- "IDN",
- "IND",
- "IND",
- "IND",
- "IND",
- "IRN",
- "ITA",
- "JPN",
- "JPN",
- "JPN",
- "KOR",
- "LKA",
- "MEX",
- "MEX",
- "MMR",
- "NGA",
- "NZL",
- "PER",
- "PHL",
- "POL",
- "QAT",
- "RUS",
- "RUS",
- "SAU",
- "TCD",
- "TUR",
- "UKR",
- "USA",
- "USA",
- "USA",
- "USA",
- "VNM"
-]
-Population 42 10500000 50 JSON_HB [
- "50699",
- "90601",
- "92583",
- "94600",
- "96800",
- "98781",
- "100887",
- "102681",
- "105119",
- "107329",
- "109500",
- "112375",
- "115532",
- "118718",
- "121600",
- "124207",
- "126820",
- "130000",
- "133642",
- "137776",
- "142044",
- "146439",
- "151060",
- "157300",
- "163849",
- "170428",
- "176576",
- "183100",
- "189569",
- "197254",
- "206158",
- "216735",
- "227657",
- "241649",
- "254842",
- "270251",
- "286900",
- "304477",
- "326399",
- "349246",
- "372840",
- "409100",
- "443727",
- "483155",
- "540828",
- "636765",
- "764902",
- "993400",
- "1300977",
- "2154376"
-]
-Country ABW ZWE 50 JSON_HB [
- "ALB",
- "ASM",
- "AZE",
- "BFA",
- "BHS",
- "BRA",
- "CAF",
- "CHE",
- "CIV",
- "COD",
- "CPV",
- "CZE",
- "DOM",
- "EST",
- "FRA",
- "GBR",
- "GIN",
- "GRC",
- "HKG",
- "IDN",
- "IND",
- "ISL",
- "JPN",
- "KGZ",
- "LAO",
- "LIE",
- "LVA",
- "MDA",
- "MLI",
- "MNG",
- "MRT",
- "MYS",
- "NER",
- "NIU",
- "NRU",
- "PAN",
- "PLW",
- "PYF",
- "RUS",
- "SDN",
- "SLE",
- "SVN",
- "TCD",
- "THA",
- "TUR",
- "TZA",
- "UKR",
- "UZB",
- "VNM",
- "ZAF"
-]
-Language Abhyasi [South]Mande 50 JSON_HB [
- "Amhara",
- "Arabic",
- "Araucan",
- "Bakhtyari",
- "Belorussian",
- "Bubi",
- "Cebuano",
- "Chinese",
- "Comorian",
- "Creole French",
- "Danish",
- "Embera",
- "English",
- "English",
- "English",
- "French",
- "French",
- "Futuna",
- "German",
- "Greek",
- "Hakka",
- "Hui",
- "Italian",
- "Joruba",
- "Kazakh",
- "Kongo",
- "Kurdish",
- "Luchazi",
- "Makua",
- "Malinke",
- "Marshallese",
- "Mixed Languages",
- "Nauru",
- "Nung",
- "Pangasinan",
- "Polish",
- "Portuguese",
- "Romanian",
- "Russian",
- "Sara",
- "Shona",
- "Songhai",
- "Spanish",
- "Spanish",
- "Tamashek",
- "Thai",
- "Tswana",
- "Tuvalu",
- "Urdu",
- "Wolea"
-]
-Percentage 0.0 99.9 50 JSON_HB [
- "0.0",
- "0.0",
- "0.0",
- "0.1",
- "0.2",
- "0.3",
- "0.4",
- "0.5",
- "0.6",
- "0.7",
- "0.8",
- "1.1",
- "1.3",
- "1.4",
- "1.6",
- "1.8",
- "2.1",
- "2.3",
- "2.5",
- "2.9",
- "3.2",
- "3.5",
- "3.8",
- "4.4",
- "4.9",
- "5.5",
- "5.9",
- "6.6",
- "7.4",
- "7.8",
- "8.6",
- "9.2",
- "10.3",
- "11.5",
- "12.9",
- "14.6",
- "17.1",
- "20.3",
- "23.8",
- "31.8",
- "39.4",
- "47.5",
- "55.1",
- "66.5",
- "77.2",
- "86.0",
- "89.9",
- "94.3",
- "97.3",
- "99.0"
-]
+Code ABW ZWE 50 JSON_HB {
+ "histogram_hb_v1": [
+ "ALB",
+ "ARM",
+ "AUS",
+ "BEL",
+ "BHR",
+ "BMU",
+ "BRN",
+ "CAN",
+ "CIV",
+ "COK",
+ "CUB",
+ "DEU",
+ "DOM",
+ "ESH",
+ "FJI",
+ "FSM",
+ "GIB",
+ "GNQ",
+ "GUF",
+ "HMD",
+ "IDN",
+ "IRQ",
+ "JAM",
+ "KGZ",
+ "KWT",
+ "LBY",
+ "LTU",
+ "MCO",
+ "MEX",
+ "MMR",
+ "MSR",
+ "MYS",
+ "NFK",
+ "NOR",
+ "PAK",
+ "PHL",
+ "PRK",
+ "QAT",
+ "RWA",
+ "SGS",
+ "SLV",
+ "STP",
+ "SWZ",
+ "TGO",
+ "TKM",
+ "TUR",
+ "UKR",
+ "UZB",
+ "VIR",
+ "YEM"
+ ]
+}
+Name Afghanistan Zimbabwe 50 JSON_HB {
+ "histogram_hb_v1": [
+ "Andorra",
+ "Argentina",
+ "Azerbaijan",
+ "Barbados",
+ "Bermuda",
+ "Bouvet Island",
+ "Bulgaria",
+ "Canada",
+ "Chile",
+ "Colombia",
+ "Costa Rica",
+ "Côte d’Ivoire",
+ "Dominican Republic",
+ "Equatorial Guinea",
+ "Faroe Islands",
+ "French Guiana",
+ "Georgia",
+ "Greenland",
+ "Guinea",
+ "Heard Island and McDonald Islands",
+ "Iceland",
+ "Ireland",
+ "Japan",
+ "Kuwait",
+ "Lesotho",
+ "Lithuania",
+ "Malawi",
+ "Marshall Islands",
+ "Mayotte",
+ "Mongolia",
+ "Namibia",
+ "Netherlands Antilles",
+ "Nigeria",
+ "Norway",
+ "Panama",
+ "Philippines",
+ "Qatar",
+ "Saint Helena",
+ "Saint Vincent and the Grenadines",
+ "Senegal",
+ "Slovenia",
+ "South Georgia and the South Sandwich Islands",
+ "Suriname",
+ "Syria",
+ "Thailand",
+ "Tunisia",
+ "Uganda",
+ "United States",
+ "Venezuela",
+ "Western Sahara"
+ ]
+}
+SurfaceArea 0.40 17075400.00 50 JSON_HB {
+ "histogram_hb_v1": [
+ "14.00",
+ "36.00",
+ "78.00",
+ "151.00",
+ "200.00",
+ "264.00",
+ "344.00",
+ "430.00",
+ "464.00",
+ "622.00",
+ "751.00",
+ "1399.00",
+ "2510.00",
+ "4033.00",
+ "8875.00",
+ "11000.00",
+ "14874.00",
+ "20256.00",
+ "25713.00",
+ "28051.00",
+ "30518.00",
+ "41526.00",
+ "48511.00",
+ "56785.00",
+ "69700.00",
+ "78866.00",
+ "90000.00",
+ "103000.00",
+ "111369.00",
+ "120538.00",
+ "147181.00",
+ "181035.00",
+ "214969.00",
+ "242900.00",
+ "274000.00",
+ "309500.00",
+ "331689.00",
+ "390757.00",
+ "447400.00",
+ "505992.00",
+ "581730.00",
+ "637657.00",
+ "774815.00",
+ "912050.00",
+ "1098581.00",
+ "1246700.00",
+ "1648195.00",
+ "2149690.00",
+ "2724900.00",
+ "9363520.00"
+ ]
+}
+Population 0 1277558000 50 JSON_HB {
+ "histogram_hb_v1": [
+ "0",
+ "1000",
+ "2500",
+ "8000",
+ "17000",
+ "27000",
+ "38000",
+ "68000",
+ "78000",
+ "99000",
+ "149000",
+ "190000",
+ "241000",
+ "307000",
+ "428000",
+ "456000",
+ "638000",
+ "885000",
+ "1295000",
+ "1726000",
+ "2153000",
+ "2662000",
+ "3101000",
+ "3520000",
+ "3850000",
+ "4023000",
+ "4629000",
+ "5074000",
+ "5398700",
+ "6188000",
+ "6782000",
+ "7733000",
+ "8329000",
+ "9586000",
+ "10239000",
+ "10730000",
+ "11385000",
+ "14786000",
+ "15942000",
+ "18886000",
+ "22244000",
+ "23115000",
+ "25662000",
+ "31471000",
+ "39441700",
+ "50456000",
+ "61399000",
+ "68470000",
+ "111506000",
+ "170115000"
+ ]
+}
+Capital 1 4074 50 JSON_HB {
+ "histogram_hb_v1": [
+ "35",
+ "63",
+ "129",
+ "150",
+ "187",
+ "204",
+ "538",
+ "554",
+ "586",
+ "652",
+ "764",
+ "904",
+ "917",
+ "926",
+ "937",
+ "1365",
+ "1464",
+ "1532",
+ "1800",
+ "1864",
+ "2256",
+ "2317",
+ "2409",
+ "2434",
+ "2441",
+ "2454",
+ "2463",
+ "2507",
+ "2514",
+ "2696",
+ "2728",
+ "2754",
+ "2821",
+ "2884",
+ "2914",
+ "2973",
+ "3018",
+ "3064",
+ "3161",
+ "3172",
+ "3208",
+ "3225",
+ "3248",
+ "3315",
+ "3334",
+ "3358",
+ "3425",
+ "3499",
+ "3537",
+ "3791"
+ ]
+}
+ID 1 4079 50 JSON_HB {
+ "histogram_hb_v1": [
+ "80",
+ "160",
+ "240",
+ "320",
+ "400",
+ "480",
+ "560",
+ "640",
+ "720",
+ "800",
+ "880",
+ "960",
+ "1040",
+ "1120",
+ "1200",
+ "1280",
+ "1360",
+ "1440",
+ "1520",
+ "1600",
+ "1680",
+ "1760",
+ "1840",
+ "1920",
+ "2000",
+ "2080",
+ "2160",
+ "2240",
+ "2320",
+ "2400",
+ "2480",
+ "2560",
+ "2640",
+ "2720",
+ "2800",
+ "2880",
+ "2960",
+ "3040",
+ "3120",
+ "3200",
+ "3280",
+ "3360",
+ "3440",
+ "3520",
+ "3600",
+ "3680",
+ "3760",
+ "3840",
+ "3920",
+ "4000"
+ ]
+}
+Name A Coruña (La Coruña) Ürgenc 50 JSON_HB {
+ "histogram_hb_v1": [
+ "Allentown",
+ "Araguari",
+ "Bahtim",
+ "Batangas",
+ "Bialystok",
+ "Brampton",
+ "Calama",
+ "Changchun",
+ "Ciomas",
+ "Cuautla",
+ "Detroit",
+ "Effon-Alaiye",
+ "Firozabad",
+ "Gebze",
+ "Guangyuan",
+ "Hangzhou",
+ "Hradec Králové",
+ "Inazawa",
+ "Jalib al-Shuyukh",
+ "Jubayl",
+ "Kassel",
+ "Kitakyushu",
+ "Kunshan",
+ "Le Mans",
+ "Longueuil",
+ "Malang",
+ "Mati",
+ "Mishan",
+ "Muroran",
+ "Natal",
+ "North York",
+ "Omsk",
+ "Palu",
+ "Phoenix",
+ "Poznan",
+ "Quezon",
+ "Rishra",
+ "Salem",
+ "Sancti-SpÃritus",
+ "Sekondi-Takoradi",
+ "Silao",
+ "Stoke-on-Trent",
+ "Taegu",
+ "Teheran",
+ "Tomsk",
+ "Târgu Mures",
+ "Varginha",
+ "Weifang",
+ "Yangjiang",
+ "Zhaodong"
+ ]
+}
+Country ABW ZWE 50 JSON_HB {
+ "histogram_hb_v1": [
+ "ARM",
+ "BHS",
+ "BRA",
+ "BRA",
+ "BRA",
+ "CAN",
+ "CHN",
+ "CHN",
+ "CHN",
+ "CHN",
+ "CHN",
+ "COL",
+ "DEU",
+ "DZA",
+ "ESP",
+ "FRA",
+ "GBR",
+ "IDN",
+ "IDN",
+ "IND",
+ "IND",
+ "IND",
+ "IND",
+ "IRN",
+ "ITA",
+ "JPN",
+ "JPN",
+ "JPN",
+ "KOR",
+ "LKA",
+ "MEX",
+ "MEX",
+ "MMR",
+ "NGA",
+ "NZL",
+ "PER",
+ "PHL",
+ "POL",
+ "QAT",
+ "RUS",
+ "RUS",
+ "SAU",
+ "TCD",
+ "TUR",
+ "UKR",
+ "USA",
+ "USA",
+ "USA",
+ "USA",
+ "VNM"
+ ]
+}
+Population 42 10500000 50 JSON_HB {
+ "histogram_hb_v1": [
+ "50699",
+ "90601",
+ "92583",
+ "94600",
+ "96800",
+ "98781",
+ "100887",
+ "102681",
+ "105119",
+ "107329",
+ "109500",
+ "112375",
+ "115532",
+ "118718",
+ "121600",
+ "124207",
+ "126820",
+ "130000",
+ "133642",
+ "137776",
+ "142044",
+ "146439",
+ "151060",
+ "157300",
+ "163849",
+ "170428",
+ "176576",
+ "183100",
+ "189569",
+ "197254",
+ "206158",
+ "216735",
+ "227657",
+ "241649",
+ "254842",
+ "270251",
+ "286900",
+ "304477",
+ "326399",
+ "349246",
+ "372840",
+ "409100",
+ "443727",
+ "483155",
+ "540828",
+ "636765",
+ "764902",
+ "993400",
+ "1300977",
+ "2154376"
+ ]
+}
+Country ABW ZWE 50 JSON_HB {
+ "histogram_hb_v1": [
+ "ALB",
+ "ASM",
+ "AZE",
+ "BFA",
+ "BHS",
+ "BRA",
+ "CAF",
+ "CHE",
+ "CIV",
+ "COD",
+ "CPV",
+ "CZE",
+ "DOM",
+ "EST",
+ "FRA",
+ "GBR",
+ "GIN",
+ "GRC",
+ "HKG",
+ "IDN",
+ "IND",
+ "ISL",
+ "JPN",
+ "KGZ",
+ "LAO",
+ "LIE",
+ "LVA",
+ "MDA",
+ "MLI",
+ "MNG",
+ "MRT",
+ "MYS",
+ "NER",
+ "NIU",
+ "NRU",
+ "PAN",
+ "PLW",
+ "PYF",
+ "RUS",
+ "SDN",
+ "SLE",
+ "SVN",
+ "TCD",
+ "THA",
+ "TUR",
+ "TZA",
+ "UKR",
+ "UZB",
+ "VNM",
+ "ZAF"
+ ]
+}
+Language Abhyasi [South]Mande 50 JSON_HB {
+ "histogram_hb_v1": [
+ "Amhara",
+ "Arabic",
+ "Araucan",
+ "Bakhtyari",
+ "Belorussian",
+ "Bubi",
+ "Cebuano",
+ "Chinese",
+ "Comorian",
+ "Creole French",
+ "Danish",
+ "Embera",
+ "English",
+ "English",
+ "English",
+ "French",
+ "French",
+ "Futuna",
+ "German",
+ "Greek",
+ "Hakka",
+ "Hui",
+ "Italian",
+ "Joruba",
+ "Kazakh",
+ "Kongo",
+ "Kurdish",
+ "Luchazi",
+ "Makua",
+ "Malinke",
+ "Marshallese",
+ "Mixed Languages",
+ "Nauru",
+ "Nung",
+ "Pangasinan",
+ "Polish",
+ "Portuguese",
+ "Romanian",
+ "Russian",
+ "Sara",
+ "Shona",
+ "Songhai",
+ "Spanish",
+ "Spanish",
+ "Tamashek",
+ "Thai",
+ "Tswana",
+ "Tuvalu",
+ "Urdu",
+ "Wolea"
+ ]
+}
+Percentage 0.0 99.9 50 JSON_HB {
+ "histogram_hb_v1": [
+ "0.0",
+ "0.0",
+ "0.0",
+ "0.1",
+ "0.2",
+ "0.3",
+ "0.4",
+ "0.5",
+ "0.6",
+ "0.7",
+ "0.8",
+ "1.1",
+ "1.3",
+ "1.4",
+ "1.6",
+ "1.8",
+ "2.1",
+ "2.3",
+ "2.5",
+ "2.9",
+ "3.2",
+ "3.5",
+ "3.8",
+ "4.4",
+ "4.9",
+ "5.5",
+ "5.9",
+ "6.6",
+ "7.4",
+ "7.8",
+ "8.6",
+ "9.2",
+ "10.3",
+ "11.5",
+ "12.9",
+ "14.6",
+ "17.1",
+ "20.3",
+ "23.8",
+ "31.8",
+ "39.4",
+ "47.5",
+ "55.1",
+ "66.5",
+ "77.2",
+ "86.0",
+ "89.9",
+ "94.3",
+ "97.3",
+ "99.0"
+ ]
+}
explain extended select * from Country where 'Code' between 'BBC' and 'GGG';
id select_type table type possible_keys key key_len ref rows filtered Extra
1 SIMPLE Country ALL NULL NULL NULL NULL 239 100.00
diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test
index 404d1e11650..99705aa38ae 100644
--- a/mysql-test/main/statistics_json.test
+++ b/mysql-test/main/statistics_json.test
@@ -37,6 +37,8 @@ analyze select * from t1_json where a between 'a-3a' and 'zzzzzzzzz';
explain extended select * from t1_json where a < 'b-1a';
analyze select * from t1_json where a > 'zzzzzzzzz';
+drop table ten;
+
# test different valid JSON strings that are invalid histograms.
UPDATE mysql.column_stats SET histogram='["a-1", "a-2", {"a": "b"}, "a-3"]' WHERE table_name='t1_json';
FLUSH TABLES;
@@ -45,23 +47,23 @@ explain extended select * from t1_json where a between 'a-3a' and 'zzzzzzzzz';
--source include/have_sequence.inc
-create table users (
+create table t2 (
city varchar(100)
);
set histogram_size=50;
-insert into users select 'Moscow' from seq_1_to_99;
-insert into users select 'Helsinki' from seq_1_to_2;
+insert into t2 select 'Moscow' from seq_1_to_99;
+insert into t2 select 'Helsinki' from seq_1_to_2;
set histogram_type=json_hb;
-analyze table users persistent for all;
-explain extended select * from users where city = 'Moscow';
-analyze select * from users where city = 'Moscow';
-explain extended select * from users where city = 'Helsinki';
-analyze select * from users where city = 'helsinki';
-explain extended select * from users where city < 'Lagos';
+analyze table t2 persistent for all;
+explain extended select * from t2 where city = 'Moscow';
+analyze select * from t2 where city = 'Moscow';
+explain extended select * from t2 where city = 'Helsinki';
+analyze select * from t2 where city = 'helsinki';
+explain extended select * from t2 where city < 'Lagos';
drop table t1_bin;
drop table t1_json;
-drop table users;
+drop table t2;
DELETE FROM mysql.column_stats;
diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt
index 3e03f587f84..47929c8707a 100644
--- a/sql/share/errmsg-utf8.txt
+++ b/sql/share/errmsg-utf8.txt
@@ -7993,4 +7993,4 @@ ER_REMOVED_ORPHAN_TRIGGER
ER_STORAGE_ENGINE_DISABLED
eng "Storage engine %s is disabled"
ER_JSON_HISTOGRAM_PARSE_FAILED
- eng "Failed to parse histogram, encountered JSON_TYPE '%d'."
+ eng "Failed to parse histogram: %s at offset %d."
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 4c300b1c04d..af884fdd6e8 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -1123,6 +1123,7 @@ class Column_stat: public Stat_table
void get_stat_values()
{
table_field->read_stats->set_all_nulls();
+ // default: hist_type=NULL means there's no histogram
table_field->read_stats->histogram_type_on_disk= INVALID_HISTOGRAM;
if (table_field->read_stats->min_value)
@@ -1196,7 +1197,10 @@ class Column_stat: public Stat_table
break;
}
case COLUMN_STAT_HISTOGRAM:
- //TODO: if stat_field->length() == 0 then histogram_type_on_disk is set to INVALID_HISTOGRAM
+ /*
+ Do nothing here: we take the histogram length from the 'histogram'
+ column itself
+ */
break;
}
}
@@ -1245,7 +1249,7 @@ class Column_stat: public Stat_table
}
if (!hist->parse(mem_root, table_field,
table_field->read_stats->histogram_type_on_disk,
- (const uchar*)val.ptr(), val.length()))
+ val.ptr(), val.length()))
{
table_field->read_stats->histogram_= hist;
return hist;
@@ -1255,19 +1259,19 @@ class Column_stat: public Stat_table
}
};
-bool Histogram_binary::parse(MEM_ROOT *mem_root, Field *,
- Histogram_type type_arg,
- const uchar *ptr_arg, uint size_arg)
+
+bool Histogram_binary::parse(MEM_ROOT *mem_root, Field*,
+ Histogram_type type_arg, const char *hist_data,
+ size_t hist_data_len)
{
- // Just copy the data
- size = (uint8) size_arg;
- type = type_arg;
- if ((values = (uchar*)alloc_root(mem_root, size_arg)))
- {
- memcpy(values, ptr_arg, size_arg);
- return false;
- }
- return true;
+ /* On-disk an in-memory formats are the same. Just copy the data. */
+ type= type_arg;
+ size= (uint8) hist_data_len; // 'size' holds the size of histogram in bytes
+ if (!(values= (uchar*)alloc_root(mem_root, hist_data_len)))
+ return true;
+
+ memcpy(values, hist_data, hist_data_len);
+ return false;
}
/*
@@ -1307,39 +1311,81 @@ void Histogram_json::init_for_collection(MEM_ROOT *mem_root,
*/
bool Histogram_json::parse(MEM_ROOT *mem_root, Field *field,
- Histogram_type type_arg, const uchar *ptr,
- uint size_arg)
+ Histogram_type type_arg, const char *hist_data,
+ size_t hist_data_len)
{
DBUG_ENTER("Histogram_json::parse");
DBUG_ASSERT(type_arg == JSON_HB);
- size = (uint8) size_arg;
- const char *json = (char *)ptr;
- int vt;
- std::vector<std::string> hist_buckets_text;
- bool result = json_get_array_items(json, json + strlen(json), &vt, hist_buckets_text);
- if (!result)
- {
- my_error(ER_JSON_HISTOGRAM_PARSE_FAILED, MYF(0), vt);
- DBUG_RETURN(true);
+ const char *err;
+ json_engine_t je;
+ json_string_t key_name;
+
+ json_scan_start(&je, &my_charset_utf8mb4_bin,
+ (const uchar*)hist_data,
+ (const uchar*)hist_data+hist_data_len);
+
+ if (json_read_value(&je) || je.value_type != JSON_VALUE_OBJECT)
+ {
+ err= "Root JSON element must be a JSON object";
+ goto error;
}
- size= hist_buckets_text.size();
- /*
- Convert the text based array into a data structure that allows lookups and
- estimates
- */
- for (auto &s : hist_buckets_text)
+ json_string_set_str(&key_name, (const uchar*)JSON_NAME,
+ (const uchar*)JSON_NAME + strlen(JSON_NAME));
+ json_string_set_cs(&key_name, system_charset_info);
+
+ if (json_scan_next(&je) || je.state != JST_KEY ||
+ !json_key_matches(&je, &key_name))
{
- field->store_text(s.data(), s.size(), &my_charset_bin);
+ err= "The first key in the object must be histogram_hb_v1";
+ goto error;
+ }
- // Get the value in "truncated key tuple format" here:
- uchar buf[MAX_KEY_LENGTH];
- uint len_to_copy= field->key_length();
- uint bytes= field->get_key_image(buf, len_to_copy, Field::itRAW);
- histogram_bounds.push_back(std::string((char*)buf, bytes));
+ // The value must be a JSON array
+ if (json_read_value(&je) || (je.value_type != JSON_VALUE_ARRAY))
+ {
+ err= "A JSON array expected";
+ goto error;
}
+ // Read the array
+ while (!json_scan_next(&je))
+ {
+ switch(je.state)
+ {
+ case JST_VALUE:
+ {
+ const char *val;
+ int val_len;
+ json_smart_read_value(&je, &val, &val_len);
+ if (je.value_type != JSON_VALUE_STRING &&
+ je.value_type != JSON_VALUE_NUMBER &&
+ je.value_type != JSON_VALUE_TRUE &&
+ je.value_type != JSON_VALUE_FALSE)
+ {
+ err= "Scalar value expected";
+ goto error;
+ }
+ uchar buf[MAX_KEY_LENGTH];
+ uint len_to_copy= field->key_length();
+ field->store_text(val, val_len, &my_charset_bin);
+ uint bytes= field->get_key_image(buf, len_to_copy, Field::itRAW);
+ histogram_bounds.push_back(std::string((char*)buf, bytes));
+ // TODO: Should we also compare this endpoint with the previous
+ // to verify that the ordering is right?
+ break;
+ }
+ case JST_ARRAY_END:
+ break;
+ }
+ }
+ size= histogram_bounds.size();
DBUG_RETURN(false);
+
+error:
+ my_error(ER_JSON_HISTOGRAM_PARSE_FAILED, MYF(0), err,
+ je.s.c_str - (const uchar*)hist_data);
+ DBUG_RETURN(true);
}
@@ -1347,7 +1393,7 @@ static
void store_key_image_to_rec_no_null(Field *field, uchar *ptr) {
MY_BITMAP *old_map= dbug_tmp_use_all_columns(field->table,
&field->table->write_set);
- field->set_key_image(ptr, field->key_length());
+ field->set_key_image(ptr, field->key_length());
dbug_tmp_restore_column_map(&field->table->write_set, old_map);
}
@@ -1506,9 +1552,9 @@ double Histogram_json::point_selectivity(Field *field, key_range *endpoint, doub
/*
@param field The table field histogram is for. We don't care about the
- field's current value, we only need its virtual functions to
+ field's current value, we only need its virtual functions to
perform various operations
-
+
@param min_endp, max_endp - this specifies the range.
*/
double Histogram_json::range_selectivity(Field *field, key_range *min_endp,
@@ -1594,7 +1640,7 @@ double Histogram_json::range_selectivity(Field *field, key_range *min_endp,
void Histogram_json::serialize(Field *field)
{
- field->store((char*)json_text, strlen((char*)json_text), &my_charset_bin);
+ field->store(json_text.data(), json_text.size(), &my_charset_bin);
}
@@ -2052,13 +2098,16 @@ class Histogram_builder_json : public Histogram_builder
}
void build_json_from_histogram() {
- Json_writer *writer = new Json_writer();
- writer->start_array();
+ Json_writer writer;
+ writer.start_object();
+ writer.add_member(Histogram_json::JSON_NAME).start_array();
+
for(auto& value: bucket_bounds) {
- writer->add_str(value.c_str());
+ writer.add_str(value.c_str());
}
- writer->end_array();
- Binary_string *json_string = (Binary_string *) writer->output.get_string();
+ writer.end_array();
+ writer.end_object();
+ Binary_string *json_string = (Binary_string *) writer.output.get_string();
Histogram_json *hist= (Histogram_json*)histogram;
hist->set_json_text(bucket_bounds.size(), (uchar *) json_string->c_ptr());
}
@@ -2080,42 +2129,6 @@ Histogram_base *create_histogram(Histogram_type hist_type)
}
-bool json_get_array_items(const char *json, const char *json_end, int *value_type, std::vector<std::string> &container) {
- json_engine_t je;
- int vl;
- const char *v;
-
- json_scan_start(&je, &my_charset_utf8mb4_bin, (const uchar *)json, (const uchar *)json_end);
-
- if (json_read_value(&je) || (*value_type = je.value_type) != JSON_VALUE_ARRAY)
- {
- return false;
- }
-
- std::string val;
- while(!json_scan_next(&je))
- {
- switch(je.state)
- {
- case JST_VALUE:
- *value_type = json_smart_read_value(&je, &v, &vl);
- if (je.value_type != JSON_VALUE_STRING &&
- je.value_type != JSON_VALUE_NUMBER &&
- je.value_type != JSON_VALUE_TRUE &&
- je.value_type != JSON_VALUE_FALSE)
- {
- return false;
- }
- val = std::string(v, vl);
- container.emplace_back(val);
- break;
- case JST_ARRAY_END:
- break;
- }
- }
- return true;
-}
-
C_MODE_START
int histogram_build_walk(void *elem, element_count elem_cnt, void *arg)
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index 48b9e24b8f0..eb982f9c4b3 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -152,7 +152,7 @@ class Histogram_base : public Sql_alloc
{
public:
virtual bool parse(MEM_ROOT *mem_root, Field *field, Histogram_type type_arg,
- const uchar *ptr, uint size)= 0;
+ const char *hist_data, size_t hist_data_len)= 0;
virtual void serialize(Field *to_field)= 0;
virtual Histogram_type get_type()=0;
@@ -187,7 +187,7 @@ class Histogram_binary : public Histogram_base
{
public:
bool parse(MEM_ROOT *mem_root, Field *, Histogram_type type_arg,
- const uchar *ptr_arg, uint size_arg) override;
+ const char *hist_data, size_t hist_data_len) override;
void serialize(Field *to_field) override;
Histogram_type get_type() override { return type; }
@@ -350,14 +350,16 @@ class Histogram_json : public Histogram_base
uint8 size; /* Number of elements in the histogram */
/* Collection-time only: collected histogram in the JSON form. */
- uchar *json_text;
+ std::string json_text;
// Array of histogram bucket endpoints in KeyTupleFormat.
std::vector<std::string> histogram_bounds;
public:
+ static constexpr const char* JSON_NAME="histogram_hb_v1";
+
bool parse(MEM_ROOT *mem_root, Field *field, Histogram_type type_arg,
- const uchar *ptr, uint size) override;
+ const char *hist_data, size_t hist_data_len) override;
void serialize(Field *field) override;
@@ -375,7 +377,8 @@ class Histogram_json : public Histogram_base
void set_json_text(ulonglong sz, uchar *json_text_arg)
{
size = (uint8) sz;
- json_text= json_text_arg;
+ json_text.assign((const char*)json_text_arg,
+ strlen((const char*)json_text_arg));
}
uint get_size() override
@@ -481,8 +484,9 @@ class Column_statistics
ulonglong avg_frequency;
public:
-
+ /* Histogram type as specified in mysql.column_stats.hist_type */
Histogram_type histogram_type_on_disk;
+
Histogram_base *histogram_;
uint32 no_values_provided_bitmap()
1
0
revision-id: 02ca278e695535fbd2a43e392276f030c3617207 (mariadb-10.6.1-98-g02ca278e695)
parent(s): 4b1a3f7b588e8553e51edf4deba825b53f328aa5
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-28 12:31:13 +0300
message:
Code cleanup part #2.
---
sql/sql_statistics.cc | 59 ++++++++++++++++-----------------------------------
sql/sql_statistics.h | 13 ++++++++----
2 files changed, 27 insertions(+), 45 deletions(-)
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index fefe0709672..4c300b1c04d 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -1292,8 +1292,7 @@ void Histogram_json::init_for_collection(MEM_ROOT *mem_root,
Histogram_type htype_arg,
ulonglong size_arg)
{
- type= htype_arg;
- //values_ = (uchar*)alloc_root(mem_root, size_arg);
+ DBUG_ASSERT(htype_arg == JSON_HB);
size= (uint8) size_arg;
}
@@ -1302,6 +1301,9 @@ void Histogram_json::init_for_collection(MEM_ROOT *mem_root,
@brief
Parse the histogram from its on-disk representation
+ @return
+ false OK
+ True Error
*/
bool Histogram_json::parse(MEM_ROOT *mem_root, Field *field,
@@ -1309,8 +1311,8 @@ bool Histogram_json::parse(MEM_ROOT *mem_root, Field *field,
uint size_arg)
{
DBUG_ENTER("Histogram_json::parse");
+ DBUG_ASSERT(type_arg == JSON_HB);
size = (uint8) size_arg;
- type = type_arg;
const char *json = (char *)ptr;
int vt;
std::vector<std::string> hist_buckets_text;
@@ -1595,6 +1597,7 @@ void Histogram_json::serialize(Field *field)
field->store((char*)json_text, strlen((char*)json_text), &my_charset_bin);
}
+
int Histogram_json::find_bucket(Field *field, const uchar *endpoint)
{
int low = 0;
@@ -2061,15 +2064,22 @@ class Histogram_builder_json : public Histogram_builder
}
};
+
Histogram_base *create_histogram(Histogram_type hist_type)
{
- // assumes the caller already checked for invalid histograms
- if (hist_type == JSON_HB)
- return new Histogram_json;
- else
- return new Histogram_binary;
+ switch (hist_type) {
+ case SINGLE_PREC_HB:
+ case DOUBLE_PREC_HB:
+ return new Histogram_binary();
+ case JSON_HB:
+ return new Histogram_json();
+ default:
+ DBUG_ASSERT(0);
+ }
+ return NULL;
}
+
bool json_get_array_items(const char *json, const char *json_end, int *value_type, std::vector<std::string> &container) {
json_engine_t je;
int vl;
@@ -2255,16 +2265,6 @@ class Count_distinct_field: public Sql_alloc
return distincts_single_occurence;
}
- /*
- @brief
- Get the size of the histogram in bytes built for table_field
- */
- /*
- uint get_hist_size()
- {
- return table_field->collected_stats->histogram.get_size();
- }*/
-
/*
@brief
Get the pointer to the histogram built for table_field
@@ -2916,27 +2916,6 @@ bool Column_statistics_collected::add()
return err;
}
-
-/*
- Create an empty Histogram object from histogram_type.
-
- Note: it is not yet clear whether collection-time histogram should be the same
- as lookup-time histogram. At the moment, they are.
-*/
-
-Histogram_base * get_histogram_by_type(MEM_ROOT *mem_root, Histogram_type hist_type) {
- switch (hist_type) {
- case SINGLE_PREC_HB:
- case DOUBLE_PREC_HB:
- return new Histogram_binary();
- case JSON_HB:
- return new Histogram_json();
- default:
- DBUG_ASSERT(0);
- }
- return NULL;
-};
-
/**
@brief
Get the results of aggregation when collecting the statistics on a column
@@ -3488,7 +3467,6 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
/* Read statistics from the statistical table column_stats */
stat_table= stat_tables[COLUMN_STAT].table;
- //ulong total_hist_size= 0;
bool have_histograms= false;
Column_stat column_stat(stat_table, table);
for (field_ptr= table_share->field; *field_ptr; field_ptr++)
@@ -3496,7 +3474,6 @@ int read_statistics_for_table(THD *thd, TABLE *table, TABLE_LIST *stat_tables)
table_field= *field_ptr;
column_stat.set_key_fields(table_field);
column_stat.get_stat_values();
- //total_hist_size+= table_field->read_stats->histogram.get_size();
if (table_field->read_stats->histogram_type_on_disk != INVALID_HISTOGRAM)
have_histograms= true;
}
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index f9031257728..48b9e24b8f0 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -17,6 +17,8 @@
#define SQL_STATISTICS_H
#include <vector>
+#include <string>
+
/*
For COMPLEMENTARY_FOR_QUERIES and PREFERABLY_FOR_QUERIES they are
similar to the COMPLEMENTARY and PREFERABLY respectively except that
@@ -279,7 +281,7 @@ class Histogram_binary : public Histogram_base
uint get_size() override {return (uint)size;}
- bool is_available() override { return get_size() > 0 && (values!=NULL); }
+ bool is_available() override { return (values!=NULL); }
/*
This function checks that histograms should be usable only when
@@ -335,13 +337,17 @@ class Histogram_binary : public Histogram_base
/*
An equi-height histogram which stores real values for bucket bounds.
+
+ Handles @@histogram_type=JSON_HB
+
+ On-disk format is JSON:
+ (TODO description)
*/
class Histogram_json : public Histogram_base
{
private:
- Histogram_type type;
- uint8 size; /* Number of elements in the histogram*/
+ uint8 size; /* Number of elements in the histogram */
/* Collection-time only: collected histogram in the JSON form. */
uchar *json_text;
@@ -414,7 +420,6 @@ class Table_statistics
/* Array of records per key for index prefixes */
ulonglong *idx_avg_frequency;
- //uchar *histograms; /* Sequence of histograms */
};
1
0
28 Aug '21
revision-id: 4b1a3f7b588e8553e51edf4deba825b53f328aa5 (mariadb-10.6.1-97-g4b1a3f7b588)
parent(s): 23ae4232b691c2eb5157396747ea8d20115ab22c
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-28 12:31:00 +0300
message:
Update test results (new histogram type: JSON_HB)
---
mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result | 8 ++++----
mysql-test/suite/sys_vars/r/sysvars_server_embedded.result | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
index 1a794c2828d..acb527a773b 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql_embedded.result
@@ -13,9 +13,9 @@ def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL
def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) NEVER NULL
def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_bin varchar(64) PRI NEVER NULL
def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_bin varchar(64) PRI NEVER NULL
-def mysql column_stats histogram 11 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) NEVER NULL
+def mysql column_stats histogram 11 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob NEVER NULL
def mysql column_stats hist_size 9 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned NEVER NULL
-def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') NEVER NULL
+def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') NEVER NULL
def mysql column_stats max_value 5 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) NEVER NULL
def mysql column_stats min_value 4 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) NEVER NULL
def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) NEVER NULL
@@ -342,8 +342,8 @@ NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats hist_size tinyint NULL NULL NULL NULL tinyint(3) unsigned
-3.0000 mysql column_stats hist_type enum 14 42 utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB')
-1.0000 mysql column_stats histogram varbinary 255 255 NULL NULL varbinary(255)
+3.0000 mysql column_stats hist_type enum 14 42 utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB')
+1.0000 mysql column_stats histogram blob 65535 65535 NULL NULL blob
3.0000 mysql db Host char 255 765 utf8mb3 utf8mb3_bin char(255)
3.0000 mysql db Db char 64 192 utf8mb3 utf8mb3_bin char(64)
3.0000 mysql db User char 128 384 utf8mb3 utf8mb3_bin char(128)
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
index b1d2a6595b3..210c9c8d7d2 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result
@@ -1209,7 +1209,7 @@ VARIABLE_COMMENT Specifies type of the histograms created by ANALYZE. Possible v
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
-ENUM_VALUE_LIST SINGLE_PREC_HB,DOUBLE_PREC_HB
+ENUM_VALUE_LIST SINGLE_PREC_HB,DOUBLE_PREC_HB,JSON_HB
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME HOSTNAME
1
0
revision-id: 23ae4232b691c2eb5157396747ea8d20115ab22c (mariadb-10.6.1-96-g23ae4232b69)
parent(s): f7efa5e713ddef1ac9e34ff5032e17d67e5074a1
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-27 22:28:59 +0300
message:
Code cleanup part #1
---
sql/sql_statistics.cc | 77 +++++++++++++++++++++++++++--------------------
sql/sql_statistics.h | 83 ++++++++++++++++++++++-----------------------------
strings/json_lib.c | 5 ++--
3 files changed, 83 insertions(+), 82 deletions(-)
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index fb89bf513c1..fefe0709672 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -1179,14 +1179,17 @@ class Column_stat: public Stat_table
table_field->read_stats->set_avg_frequency(stat_field->val_real());
break;
case COLUMN_STAT_HIST_SIZE:
- //TODO: ignore this. The size is a part of histogram!
- //table_field->read_stats->histogram.set_size(stat_field->val_int());
+ /*
+ Ignore the contents of mysql.column_stats.hist_size. We take the
+ size from the mysql.column_stats.histogram column, itself.
+ */
break;
case COLUMN_STAT_HIST_TYPE:
- // TODO: save this next to histogram.
- // For some reason, the histogram itself is read in
- // read_histograms_for_table
{
+ /*
+ Save the histogram type. The histogram itself will be read in
+ read_histograms_for_table().
+ */
Histogram_type hist_type= (Histogram_type) (stat_field->val_int() -
1);
table_field->read_stats->histogram_type_on_disk= hist_type;
@@ -1247,21 +1250,24 @@ class Column_stat: public Stat_table
table_field->read_stats->histogram_= hist;
return hist;
}
- //memcpy(table_field->read_stats->histogram_.get_values(),
- // val.ptr(), table_field->read_stats->histogram.get_size());
}
return NULL;
}
};
-bool Histogram_binary::parse(MEM_ROOT *mem_root, Field *, Histogram_type type_arg, const uchar *ptr_arg, uint size_arg)
+bool Histogram_binary::parse(MEM_ROOT *mem_root, Field *,
+ Histogram_type type_arg,
+ const uchar *ptr_arg, uint size_arg)
{
// Just copy the data
size = (uint8) size_arg;
type = type_arg;
- values = (uchar*)alloc_root(mem_root, size_arg);
- memcpy(values, ptr_arg, size_arg);
- return false;
+ if ((values = (uchar*)alloc_root(mem_root, size_arg)))
+ {
+ memcpy(values, ptr_arg, size_arg);
+ return false;
+ }
+ return true;
}
/*
@@ -1269,7 +1275,7 @@ bool Histogram_binary::parse(MEM_ROOT *mem_root, Field *, Histogram_type type_ar
*/
void Histogram_binary::serialize(Field *field)
{
- field->store((char*)get_values(), get_size(), &my_charset_bin);
+ field->store((char*)values, size, &my_charset_bin);
}
void Histogram_binary::init_for_collection(MEM_ROOT *mem_root,
@@ -1282,20 +1288,32 @@ void Histogram_binary::init_for_collection(MEM_ROOT *mem_root,
}
-void Histogram_json::init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg, ulonglong size_arg)
+void Histogram_json::init_for_collection(MEM_ROOT *mem_root,
+ Histogram_type htype_arg,
+ ulonglong size_arg)
{
type= htype_arg;
- values = (uchar*)alloc_root(mem_root, size_arg);
- size = (uint8) size_arg;
+ //values_ = (uchar*)alloc_root(mem_root, size_arg);
+ size= (uint8) size_arg;
}
-bool Histogram_json::parse(MEM_ROOT *mem_root, Field *field, Histogram_type type_arg, const uchar *ptr, uint size_arg)
+
+/*
+ @brief
+ Parse the histogram from its on-disk representation
+
+*/
+
+bool Histogram_json::parse(MEM_ROOT *mem_root, Field *field,
+ Histogram_type type_arg, const uchar *ptr,
+ uint size_arg)
{
DBUG_ENTER("Histogram_json::parse");
size = (uint8) size_arg;
type = type_arg;
const char *json = (char *)ptr;
int vt;
+ std::vector<std::string> hist_buckets_text;
bool result = json_get_array_items(json, json + strlen(json), &vt, hist_buckets_text);
if (!result)
{
@@ -1482,6 +1500,8 @@ double Histogram_json::point_selectivity(Field *field, key_range *endpoint, doub
}
return sel;
}
+
+
/*
@param field The table field histogram is for. We don't care about the
field's current value, we only need its virtual functions to
@@ -1492,14 +1512,13 @@ double Histogram_json::point_selectivity(Field *field, key_range *endpoint, doub
double Histogram_json::range_selectivity(Field *field, key_range *min_endp,
key_range *max_endp)
{
- //fprintf(stderr, "Histogram_json::range_selectivity\n");
double min = 0.0, max = 1.0;
double width = 1.0/(int)histogram_bounds.size();
if (min_endp)
{
double min_sel = 0.0;
const uchar *min_key= min_endp->key;
- // TODO: also, properly handle SQL NULLs.
+ // GSOC-TODO: properly handle SQL NULLs.
// in this test patch, we just assume the values are not SQL NULLs.
if (field->real_maybe_null())
min_key++;
@@ -1573,8 +1592,7 @@ double Histogram_json::range_selectivity(Field *field, key_range *min_endp,
void Histogram_json::serialize(Field *field)
{
- field->store((char*)get_values(), strlen((char*)get_values()),
- &my_charset_bin);
+ field->store((char*)json_text, strlen((char*)json_text), &my_charset_bin);
}
int Histogram_json::find_bucket(Field *field, const uchar *endpoint)
@@ -1583,7 +1601,7 @@ int Histogram_json::find_bucket(Field *field, const uchar *endpoint)
int high = (int)histogram_bounds.size()-1;
int mid;
int min_bucket_index = -1;
- std::string mid_val;
+ std::string mid_val; // GSOC-todo: don't copy strings
while(low <= high) {
// c++ gives us the floor of integer divisions by default, below we get the ceiling (round-up).
@@ -2037,9 +2055,9 @@ class Histogram_builder_json : public Histogram_builder
writer->add_str(value.c_str());
}
writer->end_array();
- histogram->set_size(bucket_bounds.size());
Binary_string *json_string = (Binary_string *) writer->output.get_string();
- ((Histogram_json *)histogram)->set_values((uchar *) json_string->c_ptr());
+ Histogram_json *hist= (Histogram_json*)histogram;
+ hist->set_json_text(bucket_bounds.size(), (uchar *) json_string->c_ptr());
}
};
@@ -2207,6 +2225,7 @@ class Count_distinct_field: public Sql_alloc
*/
void walk_tree_with_histogram(ha_rows rows)
{
+ // GSOC-TODO: is below a meaningful difference:
if (table_field->collected_stats->histogram_->get_type() == JSON_HB)
{
Histogram_builder_json hist_builder(table_field, tree_key_length, rows);
@@ -2680,11 +2699,6 @@ int alloc_statistics_for_table(THD* thd, TABLE *table)
if (bitmap_is_set(table->read_set, (*field_ptr)->field_index))
{
column_stats->histogram_ = NULL;
- /*
- column_stats->histogram.set_size(hist_size);
- column_stats->histogram.set_type(hist_type);
- column_stats->histogram.set_values(histogram);
- histogram+= hist_size;*/
(*field_ptr)->collected_stats= column_stats++;
}
}
@@ -2950,9 +2964,9 @@ void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows, doubl
}
if (count_distinct)
{
- //uint hist_size= count_distinct->get_hist_size();
uint hist_size= current_thd->variables.histogram_size;
- Histogram_type hist_type= (Histogram_type) (current_thd->variables.histogram_type);
+ Histogram_type hist_type=
+ (Histogram_type) (current_thd->variables.histogram_type);
bool have_histogram= false;
if (hist_size != 0 && hist_type != INVALID_HISTOGRAM)
{
@@ -3001,12 +3015,11 @@ void Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows, doubl
}
else
have_histogram= false ; // TODO: need this?
- //histogram.set_size(hist_size);
+
set_not_null(COLUMN_STAT_HIST_SIZE);
if (have_histogram && distincts)
{
set_not_null(COLUMN_STAT_HIST_TYPE);
- //histogram.set_values(count_distinct->get_histogram());
histogram_= count_distinct->get_histogram();
set_not_null(COLUMN_STAT_HISTOGRAM);
}
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index f9fdd0a63bc..f9031257728 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -157,22 +157,17 @@ class Histogram_base : public Sql_alloc
virtual uint get_width()=0;
- virtual void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg, ulonglong size)=0;
+ virtual void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg,
+ ulonglong size)=0;
virtual bool is_available()=0;
virtual bool is_usable(THD *thd)=0;
- virtual void set_values(uchar * values)=0;
-
- virtual uchar *get_values()=0;
-
- virtual void set_size(ulonglong sz)=0;
-
- virtual double point_selectivity(Field *field, key_range *endpoint, double avg_selection)=0;
-
+ virtual double point_selectivity(Field *field, key_range *endpoint,
+ double avg_selection)=0;
virtual double range_selectivity(Field *field, key_range *min_endp,
- key_range *max_endp)=0;
+ key_range *max_endp)=0;
// Legacy: return the size of the histogram on disk.
// This will be stored in mysql.column_stats.hist_size column.
@@ -181,6 +176,11 @@ class Histogram_base : public Sql_alloc
virtual ~Histogram_base()= default;
};
+
+/*
+ A Height-balanced histogram that stores numeric fractions
+*/
+
class Histogram_binary : public Histogram_base
{
public:
@@ -274,17 +274,12 @@ class Histogram_binary : public Histogram_base
return i;
}
- uchar *get_values() override { return (uchar *) values; }
public:
void init_for_collection(MEM_ROOT *mem_root, Histogram_type htype_arg, ulonglong size) override;
- // Note: these two are used only for saving the JSON text:
- void set_values (uchar *vals) override { values= (uchar *) vals; }
- void set_size (ulonglong sz) override { size= (uint8) sz; }
-
uint get_size() override {return (uint)size;}
- bool is_available() override { return get_size() > 0 && get_values(); }
+ bool is_available() override { return get_size() > 0 && (values!=NULL); }
/*
This function checks that histograms should be usable only when
@@ -328,58 +323,57 @@ class Histogram_binary : public Histogram_base
}
double range_selectivity(Field *field, key_range *min_endp,
- key_range *max_endp) override;
-
+ key_range *max_endp) override;
+
/*
Estimate selectivity of "col=const" using a histogram
*/
- double point_selectivity(Field *field, key_range *endpoint, double avg_sel) override;
+ double point_selectivity(Field *field, key_range *endpoint,
+ double avg_sel) override;
};
+
+/*
+ An equi-height histogram which stores real values for bucket bounds.
+*/
+
class Histogram_json : public Histogram_base
{
private:
Histogram_type type;
uint8 size; /* Number of elements in the histogram*/
-
- /*
- GSOC-TODO: This is used for storing collected JSON text. Rename it
- accordingly.
- */
- uchar *values;
-
- // List of values in string form.
- /*
- GSOC-TODO: We don't need to save this. It can be a local variable in
- parse().
- Eventually we should get rid of this at all, as we can convert the
- endpoints and add them to histogram_bounds as soon as we've read them.
- */
- std::vector<std::string> hist_buckets_text;
+ /* Collection-time only: collected histogram in the JSON form. */
+ uchar *json_text;
+
// Array of histogram bucket endpoints in KeyTupleFormat.
std::vector<std::string> histogram_bounds;
public:
bool parse(MEM_ROOT *mem_root, Field *field, Histogram_type type_arg,
- const uchar *ptr, uint size) override;
+ const uchar *ptr, uint size) override;
void serialize(Field *field) override;
// returns number of buckets in the histogram
uint get_width() override
{
- return size;
- };
+ return size;
+ }
Histogram_type get_type() override
{
return JSON_HB;
}
- void set_size (ulonglong sz) override {size = (uint8) sz; }
+ void set_json_text(ulonglong sz, uchar *json_text_arg)
+ {
+ size = (uint8) sz;
+ json_text= json_text_arg;
+ }
- uint get_size() override {
+ uint get_size() override
+ {
return size;
}
@@ -393,15 +387,10 @@ class Histogram_json : public Histogram_base
is_available();
}
- void set_values (uchar *vals) override { values= (uchar *) vals; }
-
- uchar *get_values() override { return (uchar *) values; }
-
- double point_selectivity(Field *field, key_range *endpoint, double avg_selection) override;
-
+ double point_selectivity(Field *field, key_range *endpoint,
+ double avg_selection) override;
double range_selectivity(Field *field, key_range *min_endp,
- key_range *max_endp) override;
-
+ key_range *max_endp) override;
/*
* Returns the index of the biggest histogram value that is smaller than endpoint
*/
diff --git a/strings/json_lib.c b/strings/json_lib.c
index 02e09acb8b1..b61eb634a20 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -1869,7 +1869,7 @@ int json_path_compare(const json_path_t *a, const json_path_t *b,
enum json_types json_smart_read_value(json_engine_t *je,
- const char **value, int *value_len)
+ const char **value, int *value_len)
{
if (json_read_value(je))
goto err_return;
@@ -1952,6 +1952,7 @@ enum json_types json_get_array_item(const char *js, const char *js_end,
return JSV_BAD_JSON;
}
+
/** Simple json lookup for a value by the key.
Expects JSON object.
@@ -2027,8 +2028,6 @@ enum json_types json_get_object_nkey(const char *js __attribute__((unused)),
return JSV_NOTHING;
}
-
-
/** Check if json is valid (well-formed)
@retval 0 - success, json is well-formed
1
0
revision-id: f7efa5e713ddef1ac9e34ff5032e17d67e5074a1 (mariadb-10.6.1-95-gf7efa5e713d)
parent(s): b9edd5606a6bcae1ea3f2eaeee1e6c7f0502f091
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-27 19:28:10 +0300
message:
Rename histogram_type=JSON to JSON_HB
---
mysql-test/main/statistics_json.result | 74 +++++++++++-----------
mysql-test/main/statistics_json.test | 10 +--
mysql-test/main/system_mysql_db.result | 2 +-
mysql-test/main/system_mysql_db_fix40123.result | 2 +-
mysql-test/main/system_mysql_db_fix50030.result | 2 +-
mysql-test/main/system_mysql_db_fix50117.result | 2 +-
mysql-test/suite/funcs_1/r/is_columns_mysql.result | 8 +--
.../sys_vars/r/sysvars_server_notembedded.result | 2 +-
scripts/mysql_system_tables.sql | 2 +-
sql/item_strfunc.cc | 13 ++--
sql/sql_statistics.cc | 10 +--
sql/sql_statistics.h | 4 +-
12 files changed, 67 insertions(+), 64 deletions(-)
diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result
index 5bf5c98a206..97931026690 100644
--- a/mysql-test/main/statistics_json.result
+++ b/mysql-test/main/statistics_json.result
@@ -4,9 +4,9 @@
set @SINGLE_PREC_TYPE='single_prec_hb';
set @DOUBLE_PREC_TYPE='double_prec_hb';
set @DEFAULT_HIST_TYPE=@@histogram_type;
-set @SINGLE_PREC_TYPE='JSON';
-set @DOUBLE_PREC_TYPE='JSON';
-set @DEFAULT_HIST_TYPE='JSON';
+set @SINGLE_PREC_TYPE='JSON_HB';
+set @DOUBLE_PREC_TYPE='JSON_HB';
+set @DEFAULT_HIST_TYPE='JSON_HB';
drop table if exists t1,t2;
set @save_use_stat_tables=@@use_stat_tables;
set @save_histogram_size=@@global.histogram_size;
@@ -232,12 +232,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 0 49 0.0000 1.0000 4 JSON 5B0A20202239222C0A2020223139222C0A2020223331222C0A2020223430220A5D
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON 5B0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
-test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON 5B0A20202261616161222C0A202022626262626262222C0A202022636363636363636363222C0A2020226464646464646464220A5D
-test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON 5B0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233220A5D
-test t1 e 0.01 0.112 0.2250 6.2000 4 JSON 5B0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31220A5D
-test t1 f 1 5 0.2000 6.4000 4 JSON 5B0A20202202222C0A20202203222C0A20202204222C0A20202204220A5D
+test t1 a 0 49 0.0000 1.0000 4 JSON_HB 5B0A20202239222C0A2020223139222C0A2020223331222C0A2020223430220A5D
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON_HB 5B0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
+test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON_HB 5B0A20202261616161222C0A202022626262626262222C0A202022636363636363636363222C0A2020226464646464646464220A5D
+test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON_HB 5B0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233220A5D
+test t1 e 0.01 0.112 0.2250 6.2000 4 JSON_HB 5B0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31220A5D
+test t1 f 1 5 0.2000 6.4000 4 JSON_HB 5B0A20202202222C0A20202203222C0A20202204222C0A20202204220A5D
DELETE FROM mysql.column_stats;
set histogram_size=8;
set histogram_type=@DOUBLE_PREC_TYPE;
@@ -251,12 +251,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 0 49 0.0000 1.0000 8 JSON 5B0A20202234222C0A20202239222C0A2020223135222C0A2020223231222C0A2020223239222C0A2020223333222C0A2020223339222C0A2020223433220A5D
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 JSON 5B0A20202276767676767676767676767676222C0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A20202277777777777777777777777777777777777777777777777777777777222C0A2020227878787878787878787878787878787878787878787878787878222C0A202022797979222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
-test t1 c aaaa dddddddd 0.1250 7.0000 8 JSON 5B0A20202261616161222C0A20202261616161222C0A202022626262626262222C0A202022626262626262222C0A202022636363636363636363222C0A202022636363636363636363222C0A2020226464646464646464222C0A2020226464646464646464220A5D
-test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 JSON 5B0A202022313938392D30332D3132222C0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233222C0A202022313939392D30372D3233220A5D
-test t1 e 0.01 0.112 0.2250 6.2000 8 JSON 5B0A202022302E3031222C0A202022302E3031222C0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31222C0A202022302E31222C0A202022302E313132220A5D
-test t1 f 1 5 0.2000 6.4000 8 JSON 5B0A20202201222C0A20202202222C0A20202202222C0A20202203222C0A20202203222C0A20202204222C0A20202204222C0A20202205220A5D
+test t1 a 0 49 0.0000 1.0000 8 JSON_HB 5B0A20202234222C0A20202239222C0A2020223135222C0A2020223231222C0A2020223239222C0A2020223333222C0A2020223339222C0A2020223433220A5D
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 JSON_HB 5B0A20202276767676767676767676767676222C0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A20202277777777777777777777777777777777777777777777777777777777222C0A2020227878787878787878787878787878787878787878787878787878222C0A202022797979222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
+test t1 c aaaa dddddddd 0.1250 7.0000 8 JSON_HB 5B0A20202261616161222C0A20202261616161222C0A202022626262626262222C0A202022626262626262222C0A202022636363636363636363222C0A202022636363636363636363222C0A2020226464646464646464222C0A2020226464646464646464220A5D
+test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 JSON_HB 5B0A202022313938392D30332D3132222C0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233222C0A202022313939392D30372D3233220A5D
+test t1 e 0.01 0.112 0.2250 6.2000 8 JSON_HB 5B0A202022302E3031222C0A202022302E3031222C0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31222C0A202022302E31222C0A202022302E313132220A5D
+test t1 f 1 5 0.2000 6.4000 8 JSON_HB 5B0A20202201222C0A20202202222C0A20202202222C0A20202203222C0A20202203222C0A20202204222C0A20202204222C0A20202205220A5D
DELETE FROM mysql.column_stats;
set histogram_size= 0;
set histogram_type=@SINGLE_PREC_TYPE;
@@ -1501,7 +1501,7 @@ nulls_ratio 0.0000
avg_length 4.0000
avg_frequency 2.7640
hist_size 100
-hist_type JSON
+hist_type JSON_HB
hex(histogram) 5B0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E31222C0A202022302E31222C0A202022302E32222C0A202022302E32222C0A202022302E33222C0A202022302E33222C0A202022302E34222C0A202022302E34222C0A202022302E34222C0A202022302E35222C0A202022302E35222C0A202022302E36222C0A202022302E36222C0A202022302E37222C0A202022302E37222C0A202022302E38222C0A202022302E39222C0A202022312E31222C0A202022312E32222C0A202022312E33222C0A202022312E34222C0A202022312E34222C0A202022312E36222C0A202022312E36222C0A202022312E37222C0A202022312E39222C0A202022322E30222C0A202022322E32222C0A202022322E32222C0A202022322E33222C0A202022322E35222C0A202022322E36222C0A202022322E38222C0A202022322E39222C0A202022332E31222C0A202022332E32222C0A202022332E34222C0A202022332E36222C0A202022332E38222C0A202022342E30222C0A202022342E33222C0A202022342E35222C0A202022342E38222C0A202022352E31222C0A202022352E34222C0A202022352E37222C0A202022352E38222C0A202022362E31222C0A202022
362E34222C0A202022362E38222C0A202022372E32222C0A202022372E35222C0A202022372E37222C0A202022382E31222C0A202022382E35222C0A202022382E38222C0A202022392E31222C0A202022392E35222C0A20202231302E31222C0A20202231302E38222C0A20202231312E33222C0A20202231322E30222C0A20202231322E36222C0A20202231332E35222C0A20202231342E32222C0A20202231362E31222C0A20202231362E38222C0A20202231382E31222C0A20202232302E30222C0A20202232312E36222C0A20202232332E34222C0A20202232382E33222C0A20202233312E37222C0A20202233342E31222C0A20202233372E35222C0A20202234312E39222C0A20202234362E34222C0A20202235302E37222C0A20202235352E31222C0A20202236302E34222C0A20202236352E36222C0A20202237322E36222C0A20202237372E31222C0A20202238312E32222C0A20202238352E36222C0A20202238372E37222C0A20202238392E39222C0A20202239322E31222C0A20202239342E32222C0A20202239352E39222C0A20202239372E33222C0A20202239382E31222C0A20202239392E30222C0A20202239392E39220A5D
decode_histogram(hist_type,histogram) [
"0.0",
@@ -1615,7 +1615,7 @@ nulls_ratio 0.0000
avg_length 4.0000
avg_frequency 1.0467
hist_size 254
-hist_type JSON
+hist_type JSON_HB
hex(histogram) 5B0A20202231343338222C0A20202235303535222C0A2020223133303030222C0A2020223235383838222C0A2020223530363939222C0A2020223839303533222C0A2020223839333838222C0A2020223839383831222C0A2020223930313131222C0A2020223930363031222C0A2020223930393531222C0A2020223931323030222C0A2020223931373737222C0A2020223932323234222C0A2020223932353833222C0A2020223932393838222C0A2020223933333030222C0A2020223933383138222C0A2020223934313030222C0A2020223934363030222C0A2020223934393334222C0A2020223935343030222C0A2020223935393333222C0A2020223936323931222C0A2020223936383030222C0A2020223937313030222C0A2020223937343531222C0A2020223938303830222C0A2020223938333432222C0A2020223938373831222C0A2020223939333637222C0A2020223939373939222C0A202022313030313138222C0A202022313030343738222C0A202022313030383837222C0A202022313031323035222C0A202022313031353734222C0A202022313031393834222C0A202022313032323934222C0A202022313032363831222C0A202022313033313731222C0A202022313033353434222C0A202022313033393834222C0A20202231303437
3030222C0A202022313035313139222C0A202022313035363930222C0A202022313036303031222C0A202022313036343134222C0A202022313037303030222C0A202022313037333239222C0A202022313037373631222C0A202022313038313030222C0A202022313038353734222C0A202022313039313231222C0A202022313039353030222C0A202022313039393635222C0A202022313130333838222C0A202022313131313030222C0A202022313131373532222C0A202022313132333735222C0A202022313133303830222C0A202022313133383030222C0A202022313134323333222C0A202022313134383736222C0A202022313135353332222C0A202022313136313738222C0A202022313136363935222C0A202022313137323237222C0A202022313137383635222C0A202022313138373138222C0A202022313139323833222C0A202022313139373936222C0A202022313230323635222C0A202022313231303030222C0A202022313231363030222C0A202022313231393534222C0A202022313232373035222C0A202022313233333539222C0A202022313233383635222C0A202022313234323037222C0A202022313234373335222C0A202022313235323535222C0A202022313235373636222C0A202022313236323832222C0A202022313236383230222C0A202
022313237323232222C0A202022313237383031222C0A202022313238333030222C0A202022313239333030222C0A202022313330303030222C0A202022313331303030222C0A202022313331373137222C0A202022313332343535222C0A202022313333313036222C0A202022313333363432222C0A202022313334303337222C0A202022313335303130222C0A202022313336323136222C0A202022313337303238222C0A202022313337373736222C0A202022313338343138222C0A202022313339323833222C0A202022313430303330222C0A202022313430383030222C0A202022313432303434222C0A202022313432363539222C0A202022313433373236222C0A202022313434353832222C0A202022313435383030222C0A202022313436343339222C0A202022313437353233222C0A202022313438313035222C0A202022313439313436222C0A202022313530313030222C0A202022313531303630222C0A202022313532343432222C0A202022313533333634222C0A202022313534393830222C0A202022313535383030222C0A202022313537333030222C0A202022313538333335222C0A202022313539363332222C0A202022313631313631222C0A202022313632333030222C0A202022313633383439222C0A202022313634373437222C0A2020223136363436
37222C0A202022313637343631222C0A202022313639333030222C0A202022313730343238222C0A202022313731353332222C0A202022313732373031222C0A202022313733383935222C0A202022313734393835222C0A202022313736353736222C0A202022313738313832222C0A202022313739323038222C0A202022313830323130222C0A202022313831383035222C0A202022313833313030222C0A202022313834303631222C0A202022313835343031222C0A202022313836393030222C0A202022313838333434222C0A202022313839353639222C0A202022313930393035222C0A202022313933303035222C0A202022313934333030222C0A202022313935353030222C0A202022313937323534222C0A202022313939303030222C0A202022323030393031222C0A202022323032313334222C0A202022323033373933222C0A202022323036313538222C0A202022323037353838222C0A202022323130303638222C0A202022323132393736222C0A202022323134393530222C0A202022323136373335222C0A202022323138343437222C0A202022323231303030222C0A202022323232353138222C0A202022323234383837222C0A202022323237363537222C0A202022323239343235222C0A202022323333303431222C0A202022323336303030222C0A20202
2323339313234222C0A202022323431363439222C0A202022323433373432222C0A202022323435373732222C0A202022323438323435222C0A202022323532333836222C0A202022323534383432222C0A202022323537383132222C0A202022323632303030222C0A202022323634303831222C0A202022323636323831222C0A202022323730323531222C0A202022323732393638222C0A202022323736343231222C0A202022323739333430222C0A202022323832393431222C0A202022323836393030222C0A202022323931303030222C0A202022323934303536222C0A202022323938393030222C0A202022333031323736222C0A202022333034343737222C0A202022333039373530222C0A202022333133353330222C0A202022333137363030222C0A202022333232323637222C0A202022333236333939222C0A202022333330323736222C0A202022333334353633222C0A202022333339313331222C0A202022333432373338222C0A202022333439323436222C0A202022333533363332222C0A202022333539313437222C0A202022333632343730222C0A202022333636353439222C0A202022333732383430222C0A202022333830373535222C0A202022333835323031222C0A202022333932383330222C0A202022343030393937222C0A202022343039313030
222C0A202022343136393838222C0A202022343231353839222C0A202022343238353232222C0A202022343335393634222C0A202022343433373237222C0A202022343532393736222C0A202022343631303030222C0A202022343639373335222C0A202022343736383030222C0A202022343833313535222C0A202022343933343039222C0A202022353038383939222C0A202022353139373933222C0A202022353239393030222C0A202022353430383238222C0A202022353633363632222C0A202022353830303030222C0A202022353934353031222C0A202022363136373030222C0A202022363336373635222C0A202022363536393235222C0A202022363830333332222C0A202022373033353932222C0A202022373335313637222C0A202022373634393032222C0A202022373937373335222C0A202022383330303030222C0A202022383737323339222C0A202022393430353839222C0A202022393933343030222C0A20202231303432373430222C0A20202231313030303030222C0A20202231313536313030222C0A20202231323137383138222C0A20202231333030393737222C0A20202231333932383630222C0A20202231353137353530222C0A20202231363832303030222C0A20202231393639383638222C0A20202232313534333736222C0A20202232353
935363734222C0A20202232393634363338222C0A20202234323536333030222C0A20202236373538383435220A5D
decode_histogram(hist_type,histogram) [
"1438",
@@ -1943,7 +1943,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 1 3 0.0000 1.0000 10 JSON 5B0A20202231222C0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202233220A5D
+test t1 a 1 3 0.0000 1.0000 10 JSON_HB 5B0A20202231222C0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202233220A5D
set histogram_size=default;
drop table t1;
#
@@ -1957,7 +1957,7 @@ set histogram_type=@DOUBLE_PREC_TYPE;
show variables like 'histogram%';
Variable_name Value
histogram_size 10
-histogram_type JSON
+histogram_type JSON_HB
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@@ -1968,7 +1968,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 1 5 0.0000 1.0000 10 JSON 5B0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202234222C0A20202234222C0A20202235222C0A20202235220A5D
+test t1 a 1 5 0.0000 1.0000 10 JSON_HB 5B0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202234222C0A20202234222C0A20202235222C0A20202235220A5D
set histogram_size=0;
set histogram_type=@SINGLE_PREC_TYPE;
drop table t1;
@@ -2009,7 +2009,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t2 id 1 1024 0.0000 8.0000 63 JSON 5B0A2020223137222C0A2020223333222C0A2020223439222C0A2020223635222C0A2020223831222C0A2020223937222C0A202022313133222C0A202022313239222C0A202022313435222C0A202022313631222C0A202022313737222C0A202022313933222C0A202022323039222C0A202022323235222C0A202022323431222C0A202022323537222C0A202022323733222C0A202022323839222C0A202022333035222C0A202022333231222C0A202022333337222C0A202022333533222C0A202022333639222C0A202022333835222C0A202022343031222C0A202022343137222C0A202022343333222C0A202022343439222C0A202022343635222C0A202022343831222C0A202022343937222C0A202022353133222C0A202022353239222C0A202022353435222C0A202022353631222C0A202022353737222C0A202022353933222C0A202022363039222C0A202022363235222C0A202022363431222C0A202022363537222C0A202022363733222C0A202022363839222C0A202022373035222C0A202022373231222C0A202022373337222C0A202022373533222C0A202022373639222C0A202022373835222C0A202022383031222C0A202022383137222C0A202022383333222C0A202022383439222C0A20202238363
5222C0A202022383831222C0A202022383937222C0A202022393133222C0A202022393239222C0A202022393435222C0A202022393631222C0A202022393737222C0A202022393933222C0A20202231303039220A5D
+test t2 id 1 1024 0.0000 8.0000 63 JSON_HB 5B0A2020223137222C0A2020223333222C0A2020223439222C0A2020223635222C0A2020223831222C0A2020223937222C0A202022313133222C0A202022313239222C0A202022313435222C0A202022313631222C0A202022313737222C0A202022313933222C0A202022323039222C0A202022323235222C0A202022323431222C0A202022323537222C0A202022323733222C0A202022323839222C0A202022333035222C0A202022333231222C0A202022333337222C0A202022333533222C0A202022333639222C0A202022333835222C0A202022343031222C0A202022343137222C0A202022343333222C0A202022343439222C0A202022343635222C0A202022343831222C0A202022343937222C0A202022353133222C0A202022353239222C0A202022353435222C0A202022353631222C0A202022353737222C0A202022353933222C0A202022363039222C0A202022363235222C0A202022363431222C0A202022363537222C0A202022363733222C0A202022363839222C0A202022373035222C0A202022373231222C0A202022373337222C0A202022373533222C0A202022373639222C0A202022373835222C0A202022383031222C0A202022383137222C0A202022383333222C0A202022383439222C0A20202238
3635222C0A202022383831222C0A202022383937222C0A202022393133222C0A202022393239222C0A202022393435222C0A202022393631222C0A202022393737222C0A202022393933222C0A20202231303039220A5D
set histogram_size=0;
drop table t1, t2;
set use_stat_tables=@save_use_stat_tables;
@@ -2315,7 +2315,7 @@ Note 1003 select `test`.`t1_bin`.`a` AS `a` from `test`.`t1_bin` where `test`.`t
analyze select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1_bin ALL NULL NULL NULL NULL 10 10.00 58.82 60.00 Using where
-set histogram_type=json;
+set histogram_type=json_hb;
create table t1_json (a varchar(255));
insert into t1_json select concat('a-', a) from ten;
analyze table t1_json persistent for all;
@@ -2324,7 +2324,7 @@ test.t1_json analyze status Engine-independent statistics collected
test.t1_json analyze status OK
select * from mysql.column_stats where table_name='t1_json';
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
-test t1_json a a-0 a-9 0.0000 3.0000 1.0000 100 JSON [
+test t1_json a a-0 a-9 0.0000 3.0000 1.0000 100 JSON_HB [
"a-0",
"a-0",
"a-0",
@@ -2452,7 +2452,7 @@ city varchar(100)
set histogram_size=50;
insert into users select 'Moscow' from seq_1_to_99;
insert into users select 'Helsinki' from seq_1_to_2;
-set histogram_type=json;
+set histogram_type=json_hb;
analyze table users persistent for all;
Table Op Msg_type Msg_text
test.users analyze status Engine-independent statistics collected
@@ -2484,12 +2484,12 @@ drop table users;
DELETE FROM mysql.column_stats;
create schema world;
use world;
-set histogram_type='JSON';
+set histogram_type='JSON_HB';
set histogram_size=50;
ANALYZE TABLE Country, City, CountryLanguage persistent for all;
SELECT column_name, min_value, max_value, hist_size, hist_type, histogram FROM mysql.column_stats;
column_name min_value max_value hist_size hist_type histogram
-Code ABW ZWE 50 JSON [
+Code ABW ZWE 50 JSON_HB [
"ALB",
"ARM",
"AUS",
@@ -2541,7 +2541,7 @@ Code ABW ZWE 50 JSON [
"VIR",
"YEM"
]
-Name Afghanistan Zimbabwe 50 JSON [
+Name Afghanistan Zimbabwe 50 JSON_HB [
"Andorra",
"Argentina",
"Azerbaijan",
@@ -2593,7 +2593,7 @@ Name Afghanistan Zimbabwe 50 JSON [
"Venezuela",
"Western Sahara"
]
-SurfaceArea 0.40 17075400.00 50 JSON [
+SurfaceArea 0.40 17075400.00 50 JSON_HB [
"14.00",
"36.00",
"78.00",
@@ -2645,7 +2645,7 @@ SurfaceArea 0.40 17075400.00 50 JSON [
"2724900.00",
"9363520.00"
]
-Population 0 1277558000 50 JSON [
+Population 0 1277558000 50 JSON_HB [
"0",
"1000",
"2500",
@@ -2697,7 +2697,7 @@ Population 0 1277558000 50 JSON [
"111506000",
"170115000"
]
-Capital 1 4074 50 JSON [
+Capital 1 4074 50 JSON_HB [
"35",
"63",
"129",
@@ -2749,7 +2749,7 @@ Capital 1 4074 50 JSON [
"3537",
"3791"
]
-ID 1 4079 50 JSON [
+ID 1 4079 50 JSON_HB [
"80",
"160",
"240",
@@ -2801,7 +2801,7 @@ ID 1 4079 50 JSON [
"3920",
"4000"
]
-Name A Coruña (La Coruña) Ürgenc 50 JSON [
+Name A Coruña (La Coruña) Ürgenc 50 JSON_HB [
"Allentown",
"Araguari",
"Bahtim",
@@ -2853,7 +2853,7 @@ Name A Coruña (La Coruña) Ürgenc 50 JSON [
"Yangjiang",
"Zhaodong"
]
-Country ABW ZWE 50 JSON [
+Country ABW ZWE 50 JSON_HB [
"ARM",
"BHS",
"BRA",
@@ -2905,7 +2905,7 @@ Country ABW ZWE 50 JSON [
"USA",
"VNM"
]
-Population 42 10500000 50 JSON [
+Population 42 10500000 50 JSON_HB [
"50699",
"90601",
"92583",
@@ -2957,7 +2957,7 @@ Population 42 10500000 50 JSON [
"1300977",
"2154376"
]
-Country ABW ZWE 50 JSON [
+Country ABW ZWE 50 JSON_HB [
"ALB",
"ASM",
"AZE",
@@ -3009,7 +3009,7 @@ Country ABW ZWE 50 JSON [
"VNM",
"ZAF"
]
-Language Abhyasi [South]Mande 50 JSON [
+Language Abhyasi [South]Mande 50 JSON_HB [
"Amhara",
"Arabic",
"Araucan",
@@ -3061,7 +3061,7 @@ Language Abhyasi [South]Mande 50 JSON [
"Urdu",
"Wolea"
]
-Percentage 0.0 99.9 50 JSON [
+Percentage 0.0 99.9 50 JSON_HB [
"0.0",
"0.0",
"0.0",
diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test
index 4bda3255b1c..404d1e11650 100644
--- a/mysql-test/main/statistics_json.test
+++ b/mysql-test/main/statistics_json.test
@@ -2,7 +2,7 @@
--echo # Test that we can store JSON arrays in histogram field mysql.column_stats when histogram_type=JSON
--echo #
-let $histogram_type_override='JSON';
+let $histogram_type_override='JSON_HB';
--source statistics.test
--source include/have_stat_tables.inc
@@ -27,7 +27,7 @@ select hex(histogram) from mysql.column_stats where table_name='t1_bin';
explain extended select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz';
analyze select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz';
-set histogram_type=json;
+set histogram_type=json_hb;
create table t1_json (a varchar(255));
insert into t1_json select concat('a-', a) from ten;
analyze table t1_json persistent for all;
@@ -51,7 +51,7 @@ create table users (
set histogram_size=50;
insert into users select 'Moscow' from seq_1_to_99;
insert into users select 'Helsinki' from seq_1_to_2;
-set histogram_type=json;
+set histogram_type=json_hb;
analyze table users persistent for all;
explain extended select * from users where city = 'Moscow';
analyze select * from users where city = 'Moscow';
@@ -76,7 +76,7 @@ use world;
--enable_result_log
--enable_query_log
-set histogram_type='JSON';
+set histogram_type='JSON_HB';
set histogram_size=50;
--disable_result_log
ANALYZE TABLE Country, City, CountryLanguage persistent for all;
@@ -91,4 +91,4 @@ analyze select * from Country where 'Code' < 'BBC';
set histogram_type=@save_histogram_type;
set histogram_size=@save_histogram_size;
-DROP SCHEMA world;
\ No newline at end of file
+DROP SCHEMA world;
diff --git a/mysql-test/main/system_mysql_db.result b/mysql-test/main/system_mysql_db.result
index b756dfcf45e..f9e37a6e616 100644
--- a/mysql-test/main/system_mysql_db.result
+++ b/mysql-test/main/system_mysql_db.result
@@ -234,7 +234,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/mysql-test/main/system_mysql_db_fix40123.result b/mysql-test/main/system_mysql_db_fix40123.result
index ec972058d54..613542caf42 100644
--- a/mysql-test/main/system_mysql_db_fix40123.result
+++ b/mysql-test/main/system_mysql_db_fix40123.result
@@ -272,7 +272,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result
index 4e038849cf6..b60253c42ad 100644
--- a/mysql-test/main/system_mysql_db_fix50030.result
+++ b/mysql-test/main/system_mysql_db_fix50030.result
@@ -276,7 +276,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/mysql-test/main/system_mysql_db_fix50117.result b/mysql-test/main/system_mysql_db_fix50117.result
index 7d540477d51..ebd8b8733c9 100644
--- a/mysql-test/main/system_mysql_db_fix50117.result
+++ b/mysql-test/main/system_mysql_db_fix50117.result
@@ -256,7 +256,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/mysql-test/suite/funcs_1/r/is_columns_mysql.result b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
index ef4832cdb8a..0211ff13cd6 100644
--- a/mysql-test/suite/funcs_1/r/is_columns_mysql.result
+++ b/mysql-test/suite/funcs_1/r/is_columns_mysql.result
@@ -13,9 +13,9 @@ def mysql column_stats avg_frequency 8 NULL YES decimal NULL NULL 12 4 NULL NULL
def mysql column_stats avg_length 7 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references NEVER NULL
def mysql column_stats column_name 3 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_bin varchar(64) PRI select,insert,update,references NEVER NULL
def mysql column_stats db_name 1 NULL NO varchar 64 192 NULL NULL NULL utf8mb3 utf8mb3_bin varchar(64) PRI select,insert,update,references NEVER NULL
-def mysql column_stats histogram 11 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) select,insert,update,references NEVER NULL
+def mysql column_stats histogram 11 NULL YES blob 65535 65535 NULL NULL NULL NULL NULL blob select,insert,update,references NEVER NULL
def mysql column_stats hist_size 9 NULL YES tinyint NULL NULL 3 0 NULL NULL NULL tinyint(3) unsigned select,insert,update,references NEVER NULL
-def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB') select,insert,update,references NEVER NULL
+def mysql column_stats hist_type 10 NULL YES enum 14 42 NULL NULL NULL utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') select,insert,update,references NEVER NULL
def mysql column_stats max_value 5 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) select,insert,update,references NEVER NULL
def mysql column_stats min_value 4 NULL YES varbinary 255 255 NULL NULL NULL NULL NULL varbinary(255) select,insert,update,references NEVER NULL
def mysql column_stats nulls_ratio 6 NULL YES decimal NULL NULL 12 4 NULL NULL NULL decimal(12,4) select,insert,update,references NEVER NULL
@@ -345,8 +345,8 @@ NULL mysql column_stats nulls_ratio decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_length decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats avg_frequency decimal NULL NULL NULL NULL decimal(12,4)
NULL mysql column_stats hist_size tinyint NULL NULL NULL NULL tinyint(3) unsigned
-3.0000 mysql column_stats hist_type enum 14 42 utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB')
-1.0000 mysql column_stats histogram varbinary 255 255 NULL NULL varbinary(255)
+3.0000 mysql column_stats hist_type enum 14 42 utf8mb3 utf8mb3_bin enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB')
+1.0000 mysql column_stats histogram blob 65535 65535 NULL NULL blob
3.0000 mysql db Host char 255 765 utf8mb3 utf8mb3_bin char(255)
3.0000 mysql db Db char 64 192 utf8mb3 utf8mb3_bin char(64)
3.0000 mysql db User char 128 384 utf8mb3 utf8mb3_bin char(128)
diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
index 7b811a011ff..e1a8f4126c0 100644
--- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
+++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result
@@ -1309,7 +1309,7 @@ VARIABLE_COMMENT Specifies type of the histograms created by ANALYZE. Possible v
NUMERIC_MIN_VALUE NULL
NUMERIC_MAX_VALUE NULL
NUMERIC_BLOCK_SIZE NULL
-ENUM_VALUE_LIST SINGLE_PREC_HB,DOUBLE_PREC_HB
+ENUM_VALUE_LIST SINGLE_PREC_HB,DOUBLE_PREC_HB,JSON_HB
READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME HOSTNAME
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index e31f3372b5f..e5b824894a0 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -314,7 +314,7 @@ DROP TABLE tmp_proxies_priv;
CREATE TABLE IF NOT EXISTS table_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables';
-CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON'), histogram blob, PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
+CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'), histogram blob, PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
CREATE TABLE IF NOT EXISTS index_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 1f31de8fd52..9f406a7a1cf 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -496,7 +496,7 @@ String *Item_func_from_base64::val_str(String *str)
const char *histogram_types[] =
- {"SINGLE_PREC_HB", "DOUBLE_PREC_HB", "JSON", 0};
+ {"SINGLE_PREC_HB", "DOUBLE_PREC_HB", "JSON_HB", 0};
static TYPELIB histogram_types_typelib=
{ array_elements(histogram_types),
"histogram_types",
@@ -526,6 +526,13 @@ String *Item_func_decode_histogram::val_str(String *str)
null_value= 1;
return 0;
}
+
+ if (type == JSON_HB)
+ {
+ // It's a JSON histogram. Return it as-is.
+ return res;
+ }
+
if (type == DOUBLE_PREC_HB && res->length() % 2 != 0)
res->length(res->length() - 1); // one byte is unused
@@ -534,10 +541,6 @@ String *Item_func_decode_histogram::val_str(String *str)
str->length(0);
char numbuf[32];
const uchar *p= (uchar*)res->c_ptr_safe();
- if (type == JSON)
- {
- return res;
- }
for (i= 0; i < res->length(); i++)
{
double val;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 43cf4d7dbdd..fb89bf513c1 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -193,7 +193,7 @@ TABLE_FIELD_TYPE column_stat_fields[COLUMN_STAT_N_FIELDS] =
},
{
{ STRING_WITH_LEN("hist_type") },
- { STRING_WITH_LEN("enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON')") },
+ { STRING_WITH_LEN("enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB')") },
{ STRING_WITH_LEN("utf8mb3") }
},
{
@@ -1234,7 +1234,7 @@ class Column_stat: public Stat_table
case DOUBLE_PREC_HB:
hist = new (mem_root) Histogram_binary();
break;
- case JSON:
+ case JSON_HB:
hist = new (mem_root) Histogram_json();
break;
default:
@@ -2046,7 +2046,7 @@ class Histogram_builder_json : public Histogram_builder
Histogram_base *create_histogram(Histogram_type hist_type)
{
// assumes the caller already checked for invalid histograms
- if (hist_type == JSON)
+ if (hist_type == JSON_HB)
return new Histogram_json;
else
return new Histogram_binary;
@@ -2207,7 +2207,7 @@ class Count_distinct_field: public Sql_alloc
*/
void walk_tree_with_histogram(ha_rows rows)
{
- if (table_field->collected_stats->histogram_->get_type() == JSON)
+ if (table_field->collected_stats->histogram_->get_type() == JSON_HB)
{
Histogram_builder_json hist_builder(table_field, tree_key_length, rows);
tree->walk(table_field->table, json_histogram_build_walk,
@@ -2915,7 +2915,7 @@ Histogram_base * get_histogram_by_type(MEM_ROOT *mem_root, Histogram_type hist_t
case SINGLE_PREC_HB:
case DOUBLE_PREC_HB:
return new Histogram_binary();
- case JSON:
+ case JSON_HB:
return new Histogram_json();
default:
DBUG_ASSERT(0);
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index 33e0430450a..f9fdd0a63bc 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -44,7 +44,7 @@ enum enum_histogram_type
{
SINGLE_PREC_HB,
DOUBLE_PREC_HB,
- JSON,
+ JSON_HB,
INVALID_HISTOGRAM
} Histogram_type;
@@ -374,7 +374,7 @@ class Histogram_json : public Histogram_base
Histogram_type get_type() override
{
- return JSON;
+ return JSON_HB;
}
void set_size (ulonglong sz) override {size = (uint8) sz; }
1
0
revision-id: c1dfee7b8a60ffd5955013f3c7735353bb8d8bab (mariadb-10.6.1-95-gc1dfee7b8a6)
parent(s): b9edd5606a6bcae1ea3f2eaeee1e6c7f0502f091
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-27 17:57:38 +0300
message:
Rename histogram_type=JSON to JSON_HB
---
mysql-test/main/statistics_json.result | 74 ++++++++++++-------------
mysql-test/main/statistics_json.test | 10 ++--
mysql-test/main/system_mysql_db.result | 2 +-
mysql-test/main/system_mysql_db_fix40123.result | 2 +-
mysql-test/main/system_mysql_db_fix50030.result | 2 +-
mysql-test/main/system_mysql_db_fix50117.result | 2 +-
scripts/mysql_system_tables.sql | 2 +-
sql/item_strfunc.cc | 13 +++--
sql/sql_statistics.cc | 10 ++--
sql/sql_statistics.h | 4 +-
10 files changed, 62 insertions(+), 59 deletions(-)
diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result
index 5bf5c98a206..97931026690 100644
--- a/mysql-test/main/statistics_json.result
+++ b/mysql-test/main/statistics_json.result
@@ -4,9 +4,9 @@
set @SINGLE_PREC_TYPE='single_prec_hb';
set @DOUBLE_PREC_TYPE='double_prec_hb';
set @DEFAULT_HIST_TYPE=@@histogram_type;
-set @SINGLE_PREC_TYPE='JSON';
-set @DOUBLE_PREC_TYPE='JSON';
-set @DEFAULT_HIST_TYPE='JSON';
+set @SINGLE_PREC_TYPE='JSON_HB';
+set @DOUBLE_PREC_TYPE='JSON_HB';
+set @DEFAULT_HIST_TYPE='JSON_HB';
drop table if exists t1,t2;
set @save_use_stat_tables=@@use_stat_tables;
set @save_histogram_size=@@global.histogram_size;
@@ -232,12 +232,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 0 49 0.0000 1.0000 4 JSON 5B0A20202239222C0A2020223139222C0A2020223331222C0A2020223430220A5D
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON 5B0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
-test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON 5B0A20202261616161222C0A202022626262626262222C0A202022636363636363636363222C0A2020226464646464646464220A5D
-test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON 5B0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233220A5D
-test t1 e 0.01 0.112 0.2250 6.2000 4 JSON 5B0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31220A5D
-test t1 f 1 5 0.2000 6.4000 4 JSON 5B0A20202202222C0A20202203222C0A20202204222C0A20202204220A5D
+test t1 a 0 49 0.0000 1.0000 4 JSON_HB 5B0A20202239222C0A2020223139222C0A2020223331222C0A2020223430220A5D
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON_HB 5B0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
+test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON_HB 5B0A20202261616161222C0A202022626262626262222C0A202022636363636363636363222C0A2020226464646464646464220A5D
+test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON_HB 5B0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233220A5D
+test t1 e 0.01 0.112 0.2250 6.2000 4 JSON_HB 5B0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31220A5D
+test t1 f 1 5 0.2000 6.4000 4 JSON_HB 5B0A20202202222C0A20202203222C0A20202204222C0A20202204220A5D
DELETE FROM mysql.column_stats;
set histogram_size=8;
set histogram_type=@DOUBLE_PREC_TYPE;
@@ -251,12 +251,12 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 0 49 0.0000 1.0000 8 JSON 5B0A20202234222C0A20202239222C0A2020223135222C0A2020223231222C0A2020223239222C0A2020223333222C0A2020223339222C0A2020223433220A5D
-test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 JSON 5B0A20202276767676767676767676767676222C0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A20202277777777777777777777777777777777777777777777777777777777222C0A2020227878787878787878787878787878787878787878787878787878222C0A202022797979222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
-test t1 c aaaa dddddddd 0.1250 7.0000 8 JSON 5B0A20202261616161222C0A20202261616161222C0A202022626262626262222C0A202022626262626262222C0A202022636363636363636363222C0A202022636363636363636363222C0A2020226464646464646464222C0A2020226464646464646464220A5D
-test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 JSON 5B0A202022313938392D30332D3132222C0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233222C0A202022313939392D30372D3233220A5D
-test t1 e 0.01 0.112 0.2250 6.2000 8 JSON 5B0A202022302E3031222C0A202022302E3031222C0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31222C0A202022302E31222C0A202022302E313132220A5D
-test t1 f 1 5 0.2000 6.4000 8 JSON 5B0A20202201222C0A20202202222C0A20202202222C0A20202203222C0A20202203222C0A20202204222C0A20202204222C0A20202205220A5D
+test t1 a 0 49 0.0000 1.0000 8 JSON_HB 5B0A20202234222C0A20202239222C0A2020223135222C0A2020223231222C0A2020223239222C0A2020223333222C0A2020223339222C0A2020223433220A5D
+test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 8 JSON_HB 5B0A20202276767676767676767676767676222C0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A20202277777777777777777777777777777777777777777777777777777777222C0A2020227878787878787878787878787878787878787878787878787878222C0A202022797979222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
+test t1 c aaaa dddddddd 0.1250 7.0000 8 JSON_HB 5B0A20202261616161222C0A20202261616161222C0A202022626262626262222C0A202022626262626262222C0A202022636363636363636363222C0A202022636363636363636363222C0A2020226464646464646464222C0A2020226464646464646464220A5D
+test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 8 JSON_HB 5B0A202022313938392D30332D3132222C0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233222C0A202022313939392D30372D3233220A5D
+test t1 e 0.01 0.112 0.2250 6.2000 8 JSON_HB 5B0A202022302E3031222C0A202022302E3031222C0A202022302E3031222C0A202022302E303132222C0A202022302E3035222C0A202022302E31222C0A202022302E31222C0A202022302E313132220A5D
+test t1 f 1 5 0.2000 6.4000 8 JSON_HB 5B0A20202201222C0A20202202222C0A20202202222C0A20202203222C0A20202203222C0A20202204222C0A20202204222C0A20202205220A5D
DELETE FROM mysql.column_stats;
set histogram_size= 0;
set histogram_type=@SINGLE_PREC_TYPE;
@@ -1501,7 +1501,7 @@ nulls_ratio 0.0000
avg_length 4.0000
avg_frequency 2.7640
hist_size 100
-hist_type JSON
+hist_type JSON_HB
hex(histogram) 5B0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E30222C0A202022302E31222C0A202022302E31222C0A202022302E32222C0A202022302E32222C0A202022302E33222C0A202022302E33222C0A202022302E34222C0A202022302E34222C0A202022302E34222C0A202022302E35222C0A202022302E35222C0A202022302E36222C0A202022302E36222C0A202022302E37222C0A202022302E37222C0A202022302E38222C0A202022302E39222C0A202022312E31222C0A202022312E32222C0A202022312E33222C0A202022312E34222C0A202022312E34222C0A202022312E36222C0A202022312E36222C0A202022312E37222C0A202022312E39222C0A202022322E30222C0A202022322E32222C0A202022322E32222C0A202022322E33222C0A202022322E35222C0A202022322E36222C0A202022322E38222C0A202022322E39222C0A202022332E31222C0A202022332E32222C0A202022332E34222C0A202022332E36222C0A202022332E38222C0A202022342E30222C0A202022342E33222C0A202022342E35222C0A202022342E38222C0A202022352E31222C0A202022352E34222C0A202022352E37222C0A202022352E38222C0A202022362E31222C0A202022
362E34222C0A202022362E38222C0A202022372E32222C0A202022372E35222C0A202022372E37222C0A202022382E31222C0A202022382E35222C0A202022382E38222C0A202022392E31222C0A202022392E35222C0A20202231302E31222C0A20202231302E38222C0A20202231312E33222C0A20202231322E30222C0A20202231322E36222C0A20202231332E35222C0A20202231342E32222C0A20202231362E31222C0A20202231362E38222C0A20202231382E31222C0A20202232302E30222C0A20202232312E36222C0A20202232332E34222C0A20202232382E33222C0A20202233312E37222C0A20202233342E31222C0A20202233372E35222C0A20202234312E39222C0A20202234362E34222C0A20202235302E37222C0A20202235352E31222C0A20202236302E34222C0A20202236352E36222C0A20202237322E36222C0A20202237372E31222C0A20202238312E32222C0A20202238352E36222C0A20202238372E37222C0A20202238392E39222C0A20202239322E31222C0A20202239342E32222C0A20202239352E39222C0A20202239372E33222C0A20202239382E31222C0A20202239392E30222C0A20202239392E39220A5D
decode_histogram(hist_type,histogram) [
"0.0",
@@ -1615,7 +1615,7 @@ nulls_ratio 0.0000
avg_length 4.0000
avg_frequency 1.0467
hist_size 254
-hist_type JSON
+hist_type JSON_HB
hex(histogram) 5B0A20202231343338222C0A20202235303535222C0A2020223133303030222C0A2020223235383838222C0A2020223530363939222C0A2020223839303533222C0A2020223839333838222C0A2020223839383831222C0A2020223930313131222C0A2020223930363031222C0A2020223930393531222C0A2020223931323030222C0A2020223931373737222C0A2020223932323234222C0A2020223932353833222C0A2020223932393838222C0A2020223933333030222C0A2020223933383138222C0A2020223934313030222C0A2020223934363030222C0A2020223934393334222C0A2020223935343030222C0A2020223935393333222C0A2020223936323931222C0A2020223936383030222C0A2020223937313030222C0A2020223937343531222C0A2020223938303830222C0A2020223938333432222C0A2020223938373831222C0A2020223939333637222C0A2020223939373939222C0A202022313030313138222C0A202022313030343738222C0A202022313030383837222C0A202022313031323035222C0A202022313031353734222C0A202022313031393834222C0A202022313032323934222C0A202022313032363831222C0A202022313033313731222C0A202022313033353434222C0A202022313033393834222C0A20202231303437
3030222C0A202022313035313139222C0A202022313035363930222C0A202022313036303031222C0A202022313036343134222C0A202022313037303030222C0A202022313037333239222C0A202022313037373631222C0A202022313038313030222C0A202022313038353734222C0A202022313039313231222C0A202022313039353030222C0A202022313039393635222C0A202022313130333838222C0A202022313131313030222C0A202022313131373532222C0A202022313132333735222C0A202022313133303830222C0A202022313133383030222C0A202022313134323333222C0A202022313134383736222C0A202022313135353332222C0A202022313136313738222C0A202022313136363935222C0A202022313137323237222C0A202022313137383635222C0A202022313138373138222C0A202022313139323833222C0A202022313139373936222C0A202022313230323635222C0A202022313231303030222C0A202022313231363030222C0A202022313231393534222C0A202022313232373035222C0A202022313233333539222C0A202022313233383635222C0A202022313234323037222C0A202022313234373335222C0A202022313235323535222C0A202022313235373636222C0A202022313236323832222C0A202022313236383230222C0A202
022313237323232222C0A202022313237383031222C0A202022313238333030222C0A202022313239333030222C0A202022313330303030222C0A202022313331303030222C0A202022313331373137222C0A202022313332343535222C0A202022313333313036222C0A202022313333363432222C0A202022313334303337222C0A202022313335303130222C0A202022313336323136222C0A202022313337303238222C0A202022313337373736222C0A202022313338343138222C0A202022313339323833222C0A202022313430303330222C0A202022313430383030222C0A202022313432303434222C0A202022313432363539222C0A202022313433373236222C0A202022313434353832222C0A202022313435383030222C0A202022313436343339222C0A202022313437353233222C0A202022313438313035222C0A202022313439313436222C0A202022313530313030222C0A202022313531303630222C0A202022313532343432222C0A202022313533333634222C0A202022313534393830222C0A202022313535383030222C0A202022313537333030222C0A202022313538333335222C0A202022313539363332222C0A202022313631313631222C0A202022313632333030222C0A202022313633383439222C0A202022313634373437222C0A2020223136363436
37222C0A202022313637343631222C0A202022313639333030222C0A202022313730343238222C0A202022313731353332222C0A202022313732373031222C0A202022313733383935222C0A202022313734393835222C0A202022313736353736222C0A202022313738313832222C0A202022313739323038222C0A202022313830323130222C0A202022313831383035222C0A202022313833313030222C0A202022313834303631222C0A202022313835343031222C0A202022313836393030222C0A202022313838333434222C0A202022313839353639222C0A202022313930393035222C0A202022313933303035222C0A202022313934333030222C0A202022313935353030222C0A202022313937323534222C0A202022313939303030222C0A202022323030393031222C0A202022323032313334222C0A202022323033373933222C0A202022323036313538222C0A202022323037353838222C0A202022323130303638222C0A202022323132393736222C0A202022323134393530222C0A202022323136373335222C0A202022323138343437222C0A202022323231303030222C0A202022323232353138222C0A202022323234383837222C0A202022323237363537222C0A202022323239343235222C0A202022323333303431222C0A202022323336303030222C0A20202
2323339313234222C0A202022323431363439222C0A202022323433373432222C0A202022323435373732222C0A202022323438323435222C0A202022323532333836222C0A202022323534383432222C0A202022323537383132222C0A202022323632303030222C0A202022323634303831222C0A202022323636323831222C0A202022323730323531222C0A202022323732393638222C0A202022323736343231222C0A202022323739333430222C0A202022323832393431222C0A202022323836393030222C0A202022323931303030222C0A202022323934303536222C0A202022323938393030222C0A202022333031323736222C0A202022333034343737222C0A202022333039373530222C0A202022333133353330222C0A202022333137363030222C0A202022333232323637222C0A202022333236333939222C0A202022333330323736222C0A202022333334353633222C0A202022333339313331222C0A202022333432373338222C0A202022333439323436222C0A202022333533363332222C0A202022333539313437222C0A202022333632343730222C0A202022333636353439222C0A202022333732383430222C0A202022333830373535222C0A202022333835323031222C0A202022333932383330222C0A202022343030393937222C0A202022343039313030
222C0A202022343136393838222C0A202022343231353839222C0A202022343238353232222C0A202022343335393634222C0A202022343433373237222C0A202022343532393736222C0A202022343631303030222C0A202022343639373335222C0A202022343736383030222C0A202022343833313535222C0A202022343933343039222C0A202022353038383939222C0A202022353139373933222C0A202022353239393030222C0A202022353430383238222C0A202022353633363632222C0A202022353830303030222C0A202022353934353031222C0A202022363136373030222C0A202022363336373635222C0A202022363536393235222C0A202022363830333332222C0A202022373033353932222C0A202022373335313637222C0A202022373634393032222C0A202022373937373335222C0A202022383330303030222C0A202022383737323339222C0A202022393430353839222C0A202022393933343030222C0A20202231303432373430222C0A20202231313030303030222C0A20202231313536313030222C0A20202231323137383138222C0A20202231333030393737222C0A20202231333932383630222C0A20202231353137353530222C0A20202231363832303030222C0A20202231393639383638222C0A20202232313534333736222C0A20202232353
935363734222C0A20202232393634363338222C0A20202234323536333030222C0A20202236373538383435220A5D
decode_histogram(hist_type,histogram) [
"1438",
@@ -1943,7 +1943,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 1 3 0.0000 1.0000 10 JSON 5B0A20202231222C0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202233220A5D
+test t1 a 1 3 0.0000 1.0000 10 JSON_HB 5B0A20202231222C0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202233220A5D
set histogram_size=default;
drop table t1;
#
@@ -1957,7 +1957,7 @@ set histogram_type=@DOUBLE_PREC_TYPE;
show variables like 'histogram%';
Variable_name Value
histogram_size 10
-histogram_type JSON
+histogram_type JSON_HB
analyze table t1 persistent for all;
Table Op Msg_type Msg_text
test.t1 analyze status Engine-independent statistics collected
@@ -1968,7 +1968,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 1 5 0.0000 1.0000 10 JSON 5B0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202234222C0A20202234222C0A20202235222C0A20202235220A5D
+test t1 a 1 5 0.0000 1.0000 10 JSON_HB 5B0A20202231222C0A20202231222C0A20202232222C0A20202232222C0A20202233222C0A20202233222C0A20202234222C0A20202234222C0A20202235222C0A20202235220A5D
set histogram_size=0;
set histogram_type=@SINGLE_PREC_TYPE;
drop table t1;
@@ -2009,7 +2009,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t2 id 1 1024 0.0000 8.0000 63 JSON 5B0A2020223137222C0A2020223333222C0A2020223439222C0A2020223635222C0A2020223831222C0A2020223937222C0A202022313133222C0A202022313239222C0A202022313435222C0A202022313631222C0A202022313737222C0A202022313933222C0A202022323039222C0A202022323235222C0A202022323431222C0A202022323537222C0A202022323733222C0A202022323839222C0A202022333035222C0A202022333231222C0A202022333337222C0A202022333533222C0A202022333639222C0A202022333835222C0A202022343031222C0A202022343137222C0A202022343333222C0A202022343439222C0A202022343635222C0A202022343831222C0A202022343937222C0A202022353133222C0A202022353239222C0A202022353435222C0A202022353631222C0A202022353737222C0A202022353933222C0A202022363039222C0A202022363235222C0A202022363431222C0A202022363537222C0A202022363733222C0A202022363839222C0A202022373035222C0A202022373231222C0A202022373337222C0A202022373533222C0A202022373639222C0A202022373835222C0A202022383031222C0A202022383137222C0A202022383333222C0A202022383439222C0A20202238363
5222C0A202022383831222C0A202022383937222C0A202022393133222C0A202022393239222C0A202022393435222C0A202022393631222C0A202022393737222C0A202022393933222C0A20202231303039220A5D
+test t2 id 1 1024 0.0000 8.0000 63 JSON_HB 5B0A2020223137222C0A2020223333222C0A2020223439222C0A2020223635222C0A2020223831222C0A2020223937222C0A202022313133222C0A202022313239222C0A202022313435222C0A202022313631222C0A202022313737222C0A202022313933222C0A202022323039222C0A202022323235222C0A202022323431222C0A202022323537222C0A202022323733222C0A202022323839222C0A202022333035222C0A202022333231222C0A202022333337222C0A202022333533222C0A202022333639222C0A202022333835222C0A202022343031222C0A202022343137222C0A202022343333222C0A202022343439222C0A202022343635222C0A202022343831222C0A202022343937222C0A202022353133222C0A202022353239222C0A202022353435222C0A202022353631222C0A202022353737222C0A202022353933222C0A202022363039222C0A202022363235222C0A202022363431222C0A202022363537222C0A202022363733222C0A202022363839222C0A202022373035222C0A202022373231222C0A202022373337222C0A202022373533222C0A202022373639222C0A202022373835222C0A202022383031222C0A202022383137222C0A202022383333222C0A202022383439222C0A20202238
3635222C0A202022383831222C0A202022383937222C0A202022393133222C0A202022393239222C0A202022393435222C0A202022393631222C0A202022393737222C0A202022393933222C0A20202231303039220A5D
set histogram_size=0;
drop table t1, t2;
set use_stat_tables=@save_use_stat_tables;
@@ -2315,7 +2315,7 @@ Note 1003 select `test`.`t1_bin`.`a` AS `a` from `test`.`t1_bin` where `test`.`t
analyze select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz';
id select_type table type possible_keys key key_len ref rows r_rows filtered r_filtered Extra
1 SIMPLE t1_bin ALL NULL NULL NULL NULL 10 10.00 58.82 60.00 Using where
-set histogram_type=json;
+set histogram_type=json_hb;
create table t1_json (a varchar(255));
insert into t1_json select concat('a-', a) from ten;
analyze table t1_json persistent for all;
@@ -2324,7 +2324,7 @@ test.t1_json analyze status Engine-independent statistics collected
test.t1_json analyze status OK
select * from mysql.column_stats where table_name='t1_json';
db_name table_name column_name min_value max_value nulls_ratio avg_length avg_frequency hist_size hist_type histogram
-test t1_json a a-0 a-9 0.0000 3.0000 1.0000 100 JSON [
+test t1_json a a-0 a-9 0.0000 3.0000 1.0000 100 JSON_HB [
"a-0",
"a-0",
"a-0",
@@ -2452,7 +2452,7 @@ city varchar(100)
set histogram_size=50;
insert into users select 'Moscow' from seq_1_to_99;
insert into users select 'Helsinki' from seq_1_to_2;
-set histogram_type=json;
+set histogram_type=json_hb;
analyze table users persistent for all;
Table Op Msg_type Msg_text
test.users analyze status Engine-independent statistics collected
@@ -2484,12 +2484,12 @@ drop table users;
DELETE FROM mysql.column_stats;
create schema world;
use world;
-set histogram_type='JSON';
+set histogram_type='JSON_HB';
set histogram_size=50;
ANALYZE TABLE Country, City, CountryLanguage persistent for all;
SELECT column_name, min_value, max_value, hist_size, hist_type, histogram FROM mysql.column_stats;
column_name min_value max_value hist_size hist_type histogram
-Code ABW ZWE 50 JSON [
+Code ABW ZWE 50 JSON_HB [
"ALB",
"ARM",
"AUS",
@@ -2541,7 +2541,7 @@ Code ABW ZWE 50 JSON [
"VIR",
"YEM"
]
-Name Afghanistan Zimbabwe 50 JSON [
+Name Afghanistan Zimbabwe 50 JSON_HB [
"Andorra",
"Argentina",
"Azerbaijan",
@@ -2593,7 +2593,7 @@ Name Afghanistan Zimbabwe 50 JSON [
"Venezuela",
"Western Sahara"
]
-SurfaceArea 0.40 17075400.00 50 JSON [
+SurfaceArea 0.40 17075400.00 50 JSON_HB [
"14.00",
"36.00",
"78.00",
@@ -2645,7 +2645,7 @@ SurfaceArea 0.40 17075400.00 50 JSON [
"2724900.00",
"9363520.00"
]
-Population 0 1277558000 50 JSON [
+Population 0 1277558000 50 JSON_HB [
"0",
"1000",
"2500",
@@ -2697,7 +2697,7 @@ Population 0 1277558000 50 JSON [
"111506000",
"170115000"
]
-Capital 1 4074 50 JSON [
+Capital 1 4074 50 JSON_HB [
"35",
"63",
"129",
@@ -2749,7 +2749,7 @@ Capital 1 4074 50 JSON [
"3537",
"3791"
]
-ID 1 4079 50 JSON [
+ID 1 4079 50 JSON_HB [
"80",
"160",
"240",
@@ -2801,7 +2801,7 @@ ID 1 4079 50 JSON [
"3920",
"4000"
]
-Name A Coruña (La Coruña) Ürgenc 50 JSON [
+Name A Coruña (La Coruña) Ürgenc 50 JSON_HB [
"Allentown",
"Araguari",
"Bahtim",
@@ -2853,7 +2853,7 @@ Name A Coruña (La Coruña) Ürgenc 50 JSON [
"Yangjiang",
"Zhaodong"
]
-Country ABW ZWE 50 JSON [
+Country ABW ZWE 50 JSON_HB [
"ARM",
"BHS",
"BRA",
@@ -2905,7 +2905,7 @@ Country ABW ZWE 50 JSON [
"USA",
"VNM"
]
-Population 42 10500000 50 JSON [
+Population 42 10500000 50 JSON_HB [
"50699",
"90601",
"92583",
@@ -2957,7 +2957,7 @@ Population 42 10500000 50 JSON [
"1300977",
"2154376"
]
-Country ABW ZWE 50 JSON [
+Country ABW ZWE 50 JSON_HB [
"ALB",
"ASM",
"AZE",
@@ -3009,7 +3009,7 @@ Country ABW ZWE 50 JSON [
"VNM",
"ZAF"
]
-Language Abhyasi [South]Mande 50 JSON [
+Language Abhyasi [South]Mande 50 JSON_HB [
"Amhara",
"Arabic",
"Araucan",
@@ -3061,7 +3061,7 @@ Language Abhyasi [South]Mande 50 JSON [
"Urdu",
"Wolea"
]
-Percentage 0.0 99.9 50 JSON [
+Percentage 0.0 99.9 50 JSON_HB [
"0.0",
"0.0",
"0.0",
diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test
index 4bda3255b1c..404d1e11650 100644
--- a/mysql-test/main/statistics_json.test
+++ b/mysql-test/main/statistics_json.test
@@ -2,7 +2,7 @@
--echo # Test that we can store JSON arrays in histogram field mysql.column_stats when histogram_type=JSON
--echo #
-let $histogram_type_override='JSON';
+let $histogram_type_override='JSON_HB';
--source statistics.test
--source include/have_stat_tables.inc
@@ -27,7 +27,7 @@ select hex(histogram) from mysql.column_stats where table_name='t1_bin';
explain extended select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz';
analyze select * from t1_bin where a between 'a-3a' and 'zzzzzzzzz';
-set histogram_type=json;
+set histogram_type=json_hb;
create table t1_json (a varchar(255));
insert into t1_json select concat('a-', a) from ten;
analyze table t1_json persistent for all;
@@ -51,7 +51,7 @@ create table users (
set histogram_size=50;
insert into users select 'Moscow' from seq_1_to_99;
insert into users select 'Helsinki' from seq_1_to_2;
-set histogram_type=json;
+set histogram_type=json_hb;
analyze table users persistent for all;
explain extended select * from users where city = 'Moscow';
analyze select * from users where city = 'Moscow';
@@ -76,7 +76,7 @@ use world;
--enable_result_log
--enable_query_log
-set histogram_type='JSON';
+set histogram_type='JSON_HB';
set histogram_size=50;
--disable_result_log
ANALYZE TABLE Country, City, CountryLanguage persistent for all;
@@ -91,4 +91,4 @@ analyze select * from Country where 'Code' < 'BBC';
set histogram_type=@save_histogram_type;
set histogram_size=@save_histogram_size;
-DROP SCHEMA world;
\ No newline at end of file
+DROP SCHEMA world;
diff --git a/mysql-test/main/system_mysql_db.result b/mysql-test/main/system_mysql_db.result
index b756dfcf45e..f9e37a6e616 100644
--- a/mysql-test/main/system_mysql_db.result
+++ b/mysql-test/main/system_mysql_db.result
@@ -234,7 +234,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/mysql-test/main/system_mysql_db_fix40123.result b/mysql-test/main/system_mysql_db_fix40123.result
index ec972058d54..613542caf42 100644
--- a/mysql-test/main/system_mysql_db_fix40123.result
+++ b/mysql-test/main/system_mysql_db_fix40123.result
@@ -272,7 +272,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result
index 4e038849cf6..b60253c42ad 100644
--- a/mysql-test/main/system_mysql_db_fix50030.result
+++ b/mysql-test/main/system_mysql_db_fix50030.result
@@ -276,7 +276,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/mysql-test/main/system_mysql_db_fix50117.result b/mysql-test/main/system_mysql_db_fix50117.result
index 7d540477d51..ebd8b8733c9 100644
--- a/mysql-test/main/system_mysql_db_fix50117.result
+++ b/mysql-test/main/system_mysql_db_fix50117.result
@@ -256,7 +256,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index e31f3372b5f..e5b824894a0 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -314,7 +314,7 @@ DROP TABLE tmp_proxies_priv;
CREATE TABLE IF NOT EXISTS table_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables';
-CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON'), histogram blob, PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
+CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'), histogram blob, PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
CREATE TABLE IF NOT EXISTS index_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 1f31de8fd52..9f406a7a1cf 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -496,7 +496,7 @@ String *Item_func_from_base64::val_str(String *str)
const char *histogram_types[] =
- {"SINGLE_PREC_HB", "DOUBLE_PREC_HB", "JSON", 0};
+ {"SINGLE_PREC_HB", "DOUBLE_PREC_HB", "JSON_HB", 0};
static TYPELIB histogram_types_typelib=
{ array_elements(histogram_types),
"histogram_types",
@@ -526,6 +526,13 @@ String *Item_func_decode_histogram::val_str(String *str)
null_value= 1;
return 0;
}
+
+ if (type == JSON_HB)
+ {
+ // It's a JSON histogram. Return it as-is.
+ return res;
+ }
+
if (type == DOUBLE_PREC_HB && res->length() % 2 != 0)
res->length(res->length() - 1); // one byte is unused
@@ -534,10 +541,6 @@ String *Item_func_decode_histogram::val_str(String *str)
str->length(0);
char numbuf[32];
const uchar *p= (uchar*)res->c_ptr_safe();
- if (type == JSON)
- {
- return res;
- }
for (i= 0; i < res->length(); i++)
{
double val;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 43cf4d7dbdd..fb89bf513c1 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -193,7 +193,7 @@ TABLE_FIELD_TYPE column_stat_fields[COLUMN_STAT_N_FIELDS] =
},
{
{ STRING_WITH_LEN("hist_type") },
- { STRING_WITH_LEN("enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON')") },
+ { STRING_WITH_LEN("enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB')") },
{ STRING_WITH_LEN("utf8mb3") }
},
{
@@ -1234,7 +1234,7 @@ class Column_stat: public Stat_table
case DOUBLE_PREC_HB:
hist = new (mem_root) Histogram_binary();
break;
- case JSON:
+ case JSON_HB:
hist = new (mem_root) Histogram_json();
break;
default:
@@ -2046,7 +2046,7 @@ class Histogram_builder_json : public Histogram_builder
Histogram_base *create_histogram(Histogram_type hist_type)
{
// assumes the caller already checked for invalid histograms
- if (hist_type == JSON)
+ if (hist_type == JSON_HB)
return new Histogram_json;
else
return new Histogram_binary;
@@ -2207,7 +2207,7 @@ class Count_distinct_field: public Sql_alloc
*/
void walk_tree_with_histogram(ha_rows rows)
{
- if (table_field->collected_stats->histogram_->get_type() == JSON)
+ if (table_field->collected_stats->histogram_->get_type() == JSON_HB)
{
Histogram_builder_json hist_builder(table_field, tree_key_length, rows);
tree->walk(table_field->table, json_histogram_build_walk,
@@ -2915,7 +2915,7 @@ Histogram_base * get_histogram_by_type(MEM_ROOT *mem_root, Histogram_type hist_t
case SINGLE_PREC_HB:
case DOUBLE_PREC_HB:
return new Histogram_binary();
- case JSON:
+ case JSON_HB:
return new Histogram_json();
default:
DBUG_ASSERT(0);
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index 33e0430450a..f9fdd0a63bc 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -44,7 +44,7 @@ enum enum_histogram_type
{
SINGLE_PREC_HB,
DOUBLE_PREC_HB,
- JSON,
+ JSON_HB,
INVALID_HISTOGRAM
} Histogram_type;
@@ -374,7 +374,7 @@ class Histogram_json : public Histogram_base
Histogram_type get_type() override
{
- return JSON;
+ return JSON_HB;
}
void set_size (ulonglong sz) override {size = (uint8) sz; }
1
0
revision-id: ef70a780ac663f56412183ef47cfac2d4ae84738 (mariadb-10.6.0-413-gef70a780ac6)
parent(s): d809e220eb2a31f07016210186600fa9dfe56232
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-27 16:57:22 +0300
message:
Rename histogram_type=JSON to JSON_HB
---
mysql-test/main/statistics_json.result | 8 ++++----
mysql-test/main/statistics_json.test | 6 +++---
mysql-test/main/system_mysql_db.result | 3 +--
mysql-test/main/system_mysql_db_fix50030.result | 2 +-
scripts/mysql_system_tables.sql | 2 +-
sql/item_strfunc.cc | 13 ++++++++-----
sql/sql_statistics.cc | 10 +++++-----
sql/sql_statistics.h | 4 ++--
8 files changed, 25 insertions(+), 23 deletions(-)
diff --git a/mysql-test/main/statistics_json.result b/mysql-test/main/statistics_json.result
index 5bf5c98a206..9eaa195c534 100644
--- a/mysql-test/main/statistics_json.result
+++ b/mysql-test/main/statistics_json.result
@@ -4,9 +4,9 @@
set @SINGLE_PREC_TYPE='single_prec_hb';
set @DOUBLE_PREC_TYPE='double_prec_hb';
set @DEFAULT_HIST_TYPE=@@histogram_type;
-set @SINGLE_PREC_TYPE='JSON';
-set @DOUBLE_PREC_TYPE='JSON';
-set @DEFAULT_HIST_TYPE='JSON';
+set @SINGLE_PREC_TYPE='JSON_HB';
+set @DOUBLE_PREC_TYPE='JSON_HB';
+set @DEFAULT_HIST_TYPE='JSON_HB';
drop table if exists t1,t2;
set @save_use_stat_tables=@@use_stat_tables;
set @save_histogram_size=@@global.histogram_size;
@@ -232,7 +232,7 @@ nulls_ratio, avg_frequency,
hist_size, hist_type, HEX(histogram)
FROM mysql.column_stats;
db_name table_name column_name min_value max_value nulls_ratio avg_frequency hist_size hist_type HEX(histogram)
-test t1 a 0 49 0.0000 1.0000 4 JSON 5B0A20202239222C0A2020223139222C0A2020223331222C0A2020223430220A5D
+test t1 a 0 49 0.0000 1.0000 4 JSON_HB 5B0A20202239222C0A2020223139222C0A2020223331222C0A2020223430220A5D
test t1 b vvvvvvvvvvvvv zzzzzzzzzzzzzzzzzz 0.2000 6.4000 4 JSON 5B0A20202276767676767676767676767676222C0A20202277777777777777777777777777777777777777777777777777777777222C0A202022797979222C0A2020227A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A7A220A5D
test t1 c aaaa dddddddd 0.1250 7.0000 4 JSON 5B0A20202261616161222C0A202022626262626262222C0A202022636363636363636363222C0A2020226464646464646464220A5D
test t1 d 1989-03-12 1999-07-23 0.1500 8.5000 4 JSON 5B0A202022313938392D30332D3132222C0A202022313939302D30352D3135222C0A202022313939302D30352D3135222C0A202022313939392D30372D3233220A5D
diff --git a/mysql-test/main/statistics_json.test b/mysql-test/main/statistics_json.test
index 4bda3255b1c..1fc42155ece 100644
--- a/mysql-test/main/statistics_json.test
+++ b/mysql-test/main/statistics_json.test
@@ -2,7 +2,7 @@
--echo # Test that we can store JSON arrays in histogram field mysql.column_stats when histogram_type=JSON
--echo #
-let $histogram_type_override='JSON';
+let $histogram_type_override='JSON_HB';
--source statistics.test
--source include/have_stat_tables.inc
@@ -76,7 +76,7 @@ use world;
--enable_result_log
--enable_query_log
-set histogram_type='JSON';
+set histogram_type='JSON_HB';
set histogram_size=50;
--disable_result_log
ANALYZE TABLE Country, City, CountryLanguage persistent for all;
@@ -91,4 +91,4 @@ analyze select * from Country where 'Code' < 'BBC';
set histogram_type=@save_histogram_type;
set histogram_size=@save_histogram_size;
-DROP SCHEMA world;
\ No newline at end of file
+DROP SCHEMA world;
diff --git a/mysql-test/main/system_mysql_db.result b/mysql-test/main/system_mysql_db.result
index b756dfcf45e..cfcd738e7cc 100644
--- a/mysql-test/main/system_mysql_db.result
+++ b/mysql-test/main/system_mysql_db.result
@@ -234,8 +234,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
- `histogram` blob DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL, `histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
show create table index_stats;
diff --git a/mysql-test/main/system_mysql_db_fix50030.result b/mysql-test/main/system_mysql_db_fix50030.result
index 4e038849cf6..b60253c42ad 100644
--- a/mysql-test/main/system_mysql_db_fix50030.result
+++ b/mysql-test/main/system_mysql_db_fix50030.result
@@ -276,7 +276,7 @@ column_stats CREATE TABLE `column_stats` (
`avg_length` decimal(12,4) DEFAULT NULL,
`avg_frequency` decimal(12,4) DEFAULT NULL,
`hist_size` tinyint(3) unsigned DEFAULT NULL,
- `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON') COLLATE utf8mb3_bin DEFAULT NULL,
+ `hist_type` enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB') COLLATE utf8mb3_bin DEFAULT NULL,
`histogram` blob DEFAULT NULL,
PRIMARY KEY (`db_name`,`table_name`,`column_name`)
) ENGINE=Aria DEFAULT CHARSET=utf8mb3 COLLATE=utf8mb3_bin PAGE_CHECKSUM=1 TRANSACTIONAL=0 COMMENT='Statistics on Columns'
diff --git a/scripts/mysql_system_tables.sql b/scripts/mysql_system_tables.sql
index e31f3372b5f..e5b824894a0 100644
--- a/scripts/mysql_system_tables.sql
+++ b/scripts/mysql_system_tables.sql
@@ -314,7 +314,7 @@ DROP TABLE tmp_proxies_priv;
CREATE TABLE IF NOT EXISTS table_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, cardinality bigint(21) unsigned DEFAULT NULL, PRIMARY KEY (db_name,table_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Tables';
-CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON'), histogram blob, PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
+CREATE TABLE IF NOT EXISTS column_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, column_name varchar(64) NOT NULL, min_value varbinary(255) DEFAULT NULL, max_value varbinary(255) DEFAULT NULL, nulls_ratio decimal(12,4) DEFAULT NULL, avg_length decimal(12,4) DEFAULT NULL, avg_frequency decimal(12,4) DEFAULT NULL, hist_size tinyint unsigned, hist_type enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB'), histogram blob, PRIMARY KEY (db_name,table_name,column_name) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Columns';
CREATE TABLE IF NOT EXISTS index_stats (db_name varchar(64) NOT NULL, table_name varchar(64) NOT NULL, index_name varchar(64) NOT NULL, prefix_arity int(11) unsigned NOT NULL, avg_frequency decimal(12,4) DEFAULT NULL, PRIMARY KEY (db_name,table_name,index_name,prefix_arity) ) engine=Aria transactional=0 CHARACTER SET utf8 COLLATE utf8_bin comment='Statistics on Indexes';
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 1f31de8fd52..9f406a7a1cf 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -496,7 +496,7 @@ String *Item_func_from_base64::val_str(String *str)
const char *histogram_types[] =
- {"SINGLE_PREC_HB", "DOUBLE_PREC_HB", "JSON", 0};
+ {"SINGLE_PREC_HB", "DOUBLE_PREC_HB", "JSON_HB", 0};
static TYPELIB histogram_types_typelib=
{ array_elements(histogram_types),
"histogram_types",
@@ -526,6 +526,13 @@ String *Item_func_decode_histogram::val_str(String *str)
null_value= 1;
return 0;
}
+
+ if (type == JSON_HB)
+ {
+ // It's a JSON histogram. Return it as-is.
+ return res;
+ }
+
if (type == DOUBLE_PREC_HB && res->length() % 2 != 0)
res->length(res->length() - 1); // one byte is unused
@@ -534,10 +541,6 @@ String *Item_func_decode_histogram::val_str(String *str)
str->length(0);
char numbuf[32];
const uchar *p= (uchar*)res->c_ptr_safe();
- if (type == JSON)
- {
- return res;
- }
for (i= 0; i < res->length(); i++)
{
double val;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index 43cf4d7dbdd..fb89bf513c1 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -193,7 +193,7 @@ TABLE_FIELD_TYPE column_stat_fields[COLUMN_STAT_N_FIELDS] =
},
{
{ STRING_WITH_LEN("hist_type") },
- { STRING_WITH_LEN("enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON')") },
+ { STRING_WITH_LEN("enum('SINGLE_PREC_HB','DOUBLE_PREC_HB','JSON_HB')") },
{ STRING_WITH_LEN("utf8mb3") }
},
{
@@ -1234,7 +1234,7 @@ class Column_stat: public Stat_table
case DOUBLE_PREC_HB:
hist = new (mem_root) Histogram_binary();
break;
- case JSON:
+ case JSON_HB:
hist = new (mem_root) Histogram_json();
break;
default:
@@ -2046,7 +2046,7 @@ class Histogram_builder_json : public Histogram_builder
Histogram_base *create_histogram(Histogram_type hist_type)
{
// assumes the caller already checked for invalid histograms
- if (hist_type == JSON)
+ if (hist_type == JSON_HB)
return new Histogram_json;
else
return new Histogram_binary;
@@ -2207,7 +2207,7 @@ class Count_distinct_field: public Sql_alloc
*/
void walk_tree_with_histogram(ha_rows rows)
{
- if (table_field->collected_stats->histogram_->get_type() == JSON)
+ if (table_field->collected_stats->histogram_->get_type() == JSON_HB)
{
Histogram_builder_json hist_builder(table_field, tree_key_length, rows);
tree->walk(table_field->table, json_histogram_build_walk,
@@ -2915,7 +2915,7 @@ Histogram_base * get_histogram_by_type(MEM_ROOT *mem_root, Histogram_type hist_t
case SINGLE_PREC_HB:
case DOUBLE_PREC_HB:
return new Histogram_binary();
- case JSON:
+ case JSON_HB:
return new Histogram_json();
default:
DBUG_ASSERT(0);
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index 33e0430450a..f9fdd0a63bc 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -44,7 +44,7 @@ enum enum_histogram_type
{
SINGLE_PREC_HB,
DOUBLE_PREC_HB,
- JSON,
+ JSON_HB,
INVALID_HISTOGRAM
} Histogram_type;
@@ -374,7 +374,7 @@ class Histogram_json : public Histogram_base
Histogram_type get_type() override
{
- return JSON;
+ return JSON_HB;
}
void set_size (ulonglong sz) override {size = (uint8) sz; }
1
0
revision-id: d809e220eb2a31f07016210186600fa9dfe56232 (mariadb-10.6.0-412-gd809e220eb2)
parent(s): aba2dcd0861bf6ed596c24a227522cb3c602874c
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-27 16:49:45 +0300
message:
Fix compile error and test failure:
- Don't use 'res' uninitialized
- multiply it by col_non_nulls before set_if_bigger(...) call.
---
sql/sql_statistics.cc | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index a518aa44958..43cf4d7dbdd 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -4369,8 +4369,8 @@ double get_column_range_cardinality(Field *field,
if (hist && hist->is_usable(thd))
{
sel= hist->range_selectivity(field, min_endp, max_endp);
- set_if_bigger(res, col_stats->get_avg_frequency());
- } else
+ }
+ else
{
double min_mp_pos, max_mp_pos;
if (min_endp && !(field->null_ptr && min_endp->key[0]))
@@ -4395,6 +4395,7 @@ double get_column_range_cardinality(Field *field,
sel = (max_mp_pos - min_mp_pos);
}
res= col_non_nulls * sel;
+ set_if_bigger(res, col_stats->get_avg_frequency());
}
else
res= col_non_nulls;
1
0
[Commits] 8c6c1b80a0b: Range Locking: Move locking secondary keys to right place
by psergey 23 Aug '21
by psergey 23 Aug '21
23 Aug '21
revision-id: 8c6c1b80a0b08b896de495272a41c33fa5dd406e (percona-202103-114-g8c6c1b80a0b)
parent(s): a234810d9a7510f2d27da922d9229ac946c3d99c
author: Sergei Petrunia
committer: Sergei Petrunia
timestamp: 2021-08-23 22:03:40 +0300
message:
Range Locking: Move locking secondary keys to right place
>From ha_rocksdb::update_write_sk into ha_rocksdb::check_and_lock_sk
---
storage/rocksdb/ha_rocksdb.cc | 70 ++++++++++++++++++++++++++++++++-----------
storage/rocksdb/ha_rocksdb.h | 4 +++
2 files changed, 57 insertions(+), 17 deletions(-)
diff --git a/storage/rocksdb/ha_rocksdb.cc b/storage/rocksdb/ha_rocksdb.cc
index b685bc11eb5..4bda73ff3d2 100644
--- a/storage/rocksdb/ha_rocksdb.cc
+++ b/storage/rocksdb/ha_rocksdb.cc
@@ -10995,6 +10995,8 @@ int ha_rocksdb::check_and_lock_sk(
lock for this key.
*/
if (!(key_info->flags & HA_NOSAME)) {
+ if (rocksdb_use_range_locking)
+ return check_and_lock_non_unique_sk(key_id, row_info);
return HA_EXIT_SUCCESS;
}
@@ -11111,6 +11113,57 @@ int ha_rocksdb::check_and_lock_sk(
return rc;
}
+
+/**
+ @brief
+ Lock the non-unique sk for range locking
+*/
+int ha_rocksdb::check_and_lock_non_unique_sk(
+ const uint key_id, const struct update_row_info &row_info) {
+
+ DBUG_ASSERT(rocksdb_use_range_locking);
+ const Rdb_key_def &kd = *m_key_descr_arr[key_id];
+ bool store_row_debug_checksums = should_store_row_debug_checksums();
+
+ if (row_info.old_data != nullptr) {
+ rocksdb::Slice old_key_slice;
+ int old_packed_size;
+
+ old_packed_size = kd.pack_record(
+ table, m_pack_buffer, row_info.old_data, m_sk_packed_tuple_old,
+ &m_sk_tails_old, store_row_debug_checksums, row_info.hidden_pk_id, 0,
+ nullptr, m_ttl_bytes);
+
+ old_key_slice = rocksdb::Slice(
+ reinterpret_cast<const char *>(m_sk_packed_tuple_old), old_packed_size);
+
+ auto s= row_info.tx->lock_singlepoint_range(kd.get_cf(), old_key_slice);
+ if (!s.ok()) {
+ return (row_info.tx->set_status_error(table->in_use, s, kd,
+ m_tbl_def, m_table_handler));
+ }
+ }
+
+ int new_packed_size;
+ rocksdb::Slice new_key_slice;
+ rocksdb::Slice new_value_slice;
+ new_packed_size =
+ kd.pack_record(table, m_pack_buffer, row_info.new_data,
+ m_sk_packed_tuple, &m_sk_tails, 0,
+ row_info.hidden_pk_id, 0, nullptr, m_ttl_bytes);
+ new_key_slice = rocksdb::Slice(
+ reinterpret_cast<const char *>(m_sk_packed_tuple), new_packed_size);
+
+ auto s= row_info.tx->lock_singlepoint_range(kd.get_cf(), new_key_slice);
+ if (!s.ok()) {
+ return (row_info.tx->set_status_error(table->in_use, s, kd,
+ m_tbl_def, m_table_handler));
+ }
+
+ return HA_EXIT_SUCCESS;
+}
+
+
/**
Enumerate all keys to check their uniquess and also lock it
@@ -11428,15 +11481,6 @@ int ha_rocksdb::update_write_sk(const TABLE *const table_arg,
old_key_slice = rocksdb::Slice(
reinterpret_cast<const char *>(m_sk_packed_tuple_old), old_packed_size);
- /* Range locking: lock the index tuple being deleted */
- if (rocksdb_use_range_locking) {
- auto s= row_info.tx->lock_singlepoint_range(kd.get_cf(), old_key_slice);
- if (!s.ok()) {
- return (row_info.tx->set_status_error(table->in_use, s, kd,
- m_tbl_def, m_table_handler));
- }
- }
-
// TODO(mung) - If the new_data and old_data below to the same partial index
// group (ie. have the same prefix), we can make use of the read below to
// determine whether to issue SingleDelete or not.
@@ -11482,14 +11526,6 @@ int ha_rocksdb::update_write_sk(const TABLE *const table_arg,
if (bulk_load_sk && row_info.old_data == nullptr) {
rc = bulk_load_key(row_info.tx, kd, new_key_slice, new_value_slice, true);
} else {
- /* Range locking: lock the index tuple being inserted */
- if (rocksdb_use_range_locking) {
- auto s= row_info.tx->lock_singlepoint_range(kd.get_cf(), new_key_slice);
- if (!s.ok()) {
- return (row_info.tx->set_status_error(table->in_use, s, kd,
- m_tbl_def, m_table_handler));
- }
- }
row_info.tx->get_indexed_write_batch()->Put(kd.get_cf(), new_key_slice,
new_value_slice);
}
diff --git a/storage/rocksdb/ha_rocksdb.h b/storage/rocksdb/ha_rocksdb.h
index ebe14103de1..48ba50efd3b 100644
--- a/storage/rocksdb/ha_rocksdb.h
+++ b/storage/rocksdb/ha_rocksdb.h
@@ -758,6 +758,10 @@ class ha_rocksdb : public my_core::handler {
const struct update_row_info &row_info,
bool *const found, const bool skip_unique_check)
MY_ATTRIBUTE((__warn_unused_result__));
+
+ int check_and_lock_non_unique_sk(const uint key_id,
+ const struct update_row_info &row_info)
+ MY_ATTRIBUTE((__warn_unused_result__));
int check_uniqueness_and_lock(const struct update_row_info &row_info,
bool pk_changed, const bool skip_unique_check)
MY_ATTRIBUTE((__warn_unused_result__));
1
0