From a01c883e074cdd68d1155ec4280114a1f87cf7a7 Mon Sep 17 00:00:00 2001 From: drrtuy Date: Fri, 18 Jul 2025 15:55:22 +0000 Subject: [PATCH] feat(rbo,rules): mock Histogram for ES < 11.4 --- dbcon/mysql/ha_mcs_execplan.cpp | 7 +++++++ dbcon/mysql/idb_mysql.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/dbcon/mysql/ha_mcs_execplan.cpp b/dbcon/mysql/ha_mcs_execplan.cpp index c3082ba5d..148a9ccba 100644 --- a/dbcon/mysql/ha_mcs_execplan.cpp +++ b/dbcon/mysql/ha_mcs_execplan.cpp @@ -6291,6 +6291,8 @@ int processLimitAndOffset(SELECT_LEX& select_lex, gp_walk_info& gwi, SCSEP& csep // Loop over available indexes to find and extract corresponding EI column statistics // for the first column of the index if any. // Statistics is stored in GWI context. +// Mock for ES 10.6 +#if MYSQL_VERSION_ID >= 110401 void extractColumnStatistics(Item_field* ifp, gp_walk_info& gwi) { for (uint j = 0; j < ifp->field->table->s->keys; j++) @@ -6313,6 +6315,11 @@ void extractColumnStatistics(Item_field* ifp, gp_walk_info& gwi) } } } +#else +void extractColumnStatistics(Item_field* ifp, gp_walk_info& gwi) +{ +} +#endif /*@brief Process SELECT part of a query or sub-query */ /*********************************************************** diff --git a/dbcon/mysql/idb_mysql.h b/dbcon/mysql/idb_mysql.h index 89c0291c3..efc4260e3 100644 --- a/dbcon/mysql/idb_mysql.h +++ b/dbcon/mysql/idb_mysql.h @@ -74,7 +74,37 @@ #include "rpl_rli.h" #include "my_dbug.h" #include "sql_show.h" +#if MYSQL_VERSION_ID >= 110401 #include "opt_histogram_json.h" +#else +// Mock Histogram_bucket for MySQL < 11.4 +struct Histogram_bucket +{ + std::string start_value; + + double cum_fract; + + longlong ndv; +}; + +class Histogram_json_hb final : public Histogram_base +{ + std::vector buckets; + + std::string last_bucket_end_endp; + +public: + const std::vector& get_json_histogram() const + { + return buckets; + } + + const std::string& get_last_bucket_end_endp() const + { + return last_bucket_end_endp; + } +}; +#endif #pragma GCC diagnostic pop // Now clean up the pollution as best we can...