summaryrefslogtreecommitdiff
path: root/sql/sql_const.h
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2019-05-27 19:08:00 -0700
committerIgor Babaev <igor@askmonty.org>2019-05-27 19:08:23 -0700
commit0955462d0aafab01def9c1a5ec131eb641cb9e68 (patch)
treef9224c83f1812b08b7977e111da9e1a34093f513 /sql/sql_const.h
parent4584c186312a6e9b16271c5d863c76f939d4df53 (diff)
downloadmariadb-git-0955462d0aafab01def9c1a5ec131eb641cb9e68.tar.gz
MDEV-18479 Assertion `join->best_read < double(1.79769313486231570815e+308L)'
or server crashes in JOIN::fix_all_splittings_in_plan after EXPLAIN This patch resolves the problem of overflowing when performing calculations to estimate the cost of an evaluated query execution plan. The overflowing in a non-debug build could cause different kind of problems uncluding crashes of the server.
Diffstat (limited to 'sql/sql_const.h')
-rw-r--r--sql/sql_const.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/sql_const.h b/sql/sql_const.h
index 96b64481936..c3b03dd7848 100644
--- a/sql/sql_const.h
+++ b/sql/sql_const.h
@@ -214,6 +214,14 @@
#define HEAP_TEMPTABLE_LOOKUP_COST 0.05
#define DISK_TEMPTABLE_LOOKUP_COST 1.0
+
+#define COST_MAX (DBL_MAX * (1.0 - DBL_EPSILON))
+
+#define COST_ADD(c,d) (COST_MAX - (d) > (c) ? (c) + (d) : COST_MAX)
+
+#define COST_MULT(c,f) (COST_MAX / (f) > (c) ? (c) * (f) : COST_MAX)
+
+
#define MY_CHARSET_BIN_MB_MAXLEN 1
/** Don't pack string keys shorter than this (if PACK_KEYS=1 isn't used). */