summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Petrunia <psergey@askmonty.org>2022-01-19 18:02:40 +0300
committerSergei Petrunia <psergey@askmonty.org>2022-01-19 18:14:07 +0300
commitce4956f3229a8b2c26a4913fdbc190b5c822cb8e (patch)
tree7f7ce9bb818d56679eaf034b52f05738b8d83da1
parentf7e49c98e6c1d86471cdc6da142a3cbf0fed9565 (diff)
downloadmariadb-git-ce4956f3229a8b2c26a4913fdbc190b5c822cb8e.tar.gz
Code cleanup
-rw-r--r--include/json_lib.h9
-rw-r--r--mysql-test/include/json_hb_histogram.inc2
-rw-r--r--sql/opt_histogram_json.cc2
-rw-r--r--sql/opt_histogram_json.h7
-rw-r--r--sql/sql_statistics.cc6
-rw-r--r--sql/sql_statistics.h6
-rw-r--r--strings/json_lib.c10
7 files changed, 14 insertions, 28 deletions
diff --git a/include/json_lib.h b/include/json_lib.h
index 34385bd8217..853c4a6f7fa 100644
--- a/include/json_lib.h
+++ b/include/json_lib.h
@@ -282,15 +282,6 @@ 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 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);
/*
json_skip_key() makes parser skip the content of the current
diff --git a/mysql-test/include/json_hb_histogram.inc b/mysql-test/include/json_hb_histogram.inc
index 0805a7f0e53..0820fb5fccb 100644
--- a/mysql-test/include/json_hb_histogram.inc
+++ b/mysql-test/include/json_hb_histogram.inc
@@ -1,3 +1,3 @@
-# The time on ANALYSE FORMAT=JSON is rather variable
+# Remove non-deterministic parts of JSON_HB histogram
--replace_regex /("(collected_at|collected_by)": )"[^"]*"/\1"REPLACED"/
diff --git a/sql/opt_histogram_json.cc b/sql/opt_histogram_json.cc
index 55848c58e2d..f2be4e5c0fb 100644
--- a/sql/opt_histogram_json.cc
+++ b/sql/opt_histogram_json.cc
@@ -914,7 +914,7 @@ double position_in_interval(Field *field, const uchar *key, uint key_len,
double Histogram_json_hb::point_selectivity(Field *field, key_range *endpoint,
- double avg_sel, double total_rows)
+ double avg_sel)
{
const uchar *key = endpoint->key;
if (field->real_maybe_null())
diff --git a/sql/opt_histogram_json.h b/sql/opt_histogram_json.h
index 48e9a29c8a5..e9b69869f4b 100644
--- a/sql/opt_histogram_json.h
+++ b/sql/opt_histogram_json.h
@@ -41,8 +41,8 @@
]
}
- The histogram is an object with single member named Histogram_json_hb::
- JSON_NAME. The value of that member is an array of buckets.
+ Histogram is a JSON object. It has some global properties and "histogram_hb"
+ member whose value is a JSON array of histogram buckets.
Each bucket is an object with these members:
"start" - the first value in the bucket.
@@ -126,8 +126,7 @@ public:
ulonglong size) override;
double point_selectivity(Field *field, key_range *endpoint,
- double avg_selection,
- double total_rows) override;
+ double avg_sel) override;
double range_selectivity(Field *field, key_range *min_endp,
key_range *max_endp, double avg_sel) override;
diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index fc8e38173c7..84d0902193b 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -3894,8 +3894,7 @@ double get_column_range_cardinality(Field *field,
{
res= col_non_nulls *
hist->point_selectivity(field, min_endp,
- avg_frequency / col_non_nulls,
- tab_records);
+ avg_frequency / col_non_nulls);
}
}
else if (avg_frequency == 0.0)
@@ -3989,8 +3988,7 @@ double get_column_range_cardinality(Field *field,
*/
double Histogram_binary::point_selectivity(Field *field, key_range *endpoint,
- double avg_sel,
- double total_records)
+ double avg_sel)
{
double sel;
Column_statistics *col_stats= field->read_stats;
diff --git a/sql/sql_statistics.h b/sql/sql_statistics.h
index 1950f3268a7..c0df15ea4ad 100644
--- a/sql/sql_statistics.h
+++ b/sql/sql_statistics.h
@@ -188,8 +188,7 @@ public:
virtual double point_selectivity(Field *field, key_range *endpoint,
- double avg_selectivity,
- double total_rows)=0;
+ double avg_sel)=0;
virtual double range_selectivity(Field *field, key_range *min_endp,
key_range *max_endp, double avg_sel)=0;
@@ -359,8 +358,7 @@ public:
Estimate selectivity of "col=const" using a histogram
*/
double point_selectivity(Field *field, key_range *endpoint,
- double avg_sel,
- double total_rows) override;
+ double avg_sel) override;
};
diff --git a/strings/json_lib.c b/strings/json_lib.c
index 0e7611528e1..836255bdf28 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -1868,8 +1868,8 @@ 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)
+static enum json_types smart_read_value(json_engine_t *je,
+ const char **value, int *value_len)
{
if (json_read_value(je))
goto err_return;
@@ -1909,7 +1909,7 @@ enum json_types json_type(const char *js, const char *js_end,
json_scan_start(&je, &my_charset_utf8mb4_bin,(const uchar *) js,
(const uchar *) js_end);
- return json_smart_read_value(&je, value, value_len);
+ return smart_read_value(&je, value, value_len);
}
@@ -1933,7 +1933,7 @@ enum json_types json_get_array_item(const char *js, const char *js_end,
{
case JST_VALUE:
if (c_item == n_item)
- return json_smart_read_value(&je, value, value_len);
+ return smart_read_value(&je, value, value_len);
if (json_skip_key(&je))
goto err_return;
@@ -1998,7 +1998,7 @@ enum json_types json_get_object_key(const char *js, const char *js_end,
json_string_set_str(&key_name, (const uchar *) key,
(const uchar *) key_end);
if (json_key_matches(&je, &key_name))
- return json_smart_read_value(&je, value, value_len);
+ return smart_read_value(&je, value, value_len);
if (json_skip_key(&je))
goto err_return;