From 6e15518dadff2357f1337f3d363899d4ffd35ee6 Mon Sep 17 00:00:00 2001
From: Prasanth R <prasanth.r@timesys.com>
Date: Fri, 22 Nov 2019 18:27:03 +0530
Subject: [PATCH] mariadb: uClibc fix

Found error
sql/sql_statistics.cc:2594:15: error: 'fmax' is not a member of 'std'
         val = std::fmax(estimate_total_distincts * (rows - nulls) /
rows, 1.0);

---
 sql/sql_statistics.cc | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/sql/sql_statistics.cc b/sql/sql_statistics.cc
index d300fe43..a4eb9d2f 100644
--- a/sql/sql_statistics.cc
+++ b/sql/sql_statistics.cc
@@ -37,6 +37,14 @@
 #include <vector>
 #include <string>
 
+#if defined __UCLIBC__
+#define STD_FMAX fmax
+#define STD_FMIN fmin
+#else
+#define STD_FMAX std::fmax
+#define STD_FMIN std::fmin
+#endif
+
 /*
   The system variable 'use_stat_tables' can take one of the
   following values:
@@ -2542,7 +2550,7 @@ bool Column_statistics_collected::finish(MEM_ROOT *mem_root, ha_rows rows,
         double estimate_total_distincts= total_number_of_rows /
                 (distincts /
                  (1.0 - (1.0 - sample_fraction) * fraction_single_occurence));
-        val = std::fmax(estimate_total_distincts * (rows - nulls) / rows, 1.0);
+        val = STD_FMAX(estimate_total_distincts * (rows - nulls) / rows, 1.0);
       }
 
       set_avg_frequency(val);
@@ -2747,7 +2755,7 @@ int collect_statistics_for_table(THD *thd, TABLE *table)
     }
     else
     {
-      sample_fraction= std::fmin(
+      sample_fraction= STD_FMIN(
                   (MIN_THRESHOLD_FOR_SAMPLING + 4096 *
                    log(200 * file->records())) / file->records(), 1);
     }
-- 
2.25.1

