summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorAlexander Barkov <bar@mariadb.com>2019-03-26 11:37:18 +0400
committerAlexander Barkov <bar@mariadb.com>2019-03-26 11:37:18 +0400
commit6fbbb0853e7e58621f73f0afc600cd95995413ed (patch)
tree5206eecee6f4a398db8a24f7273c08f7d1e7afaa /sql
parented643f4bb31d8e5a9c0bc161583b8c9b2a08c26b (diff)
downloadmariadb-git-6fbbb0853e7e58621f73f0afc600cd95995413ed.tar.gz
MDEV-18968 Both (WHERE 0.1) and (WHERE NOT 0.1) return empty set
Diffstat (limited to 'sql')
-rw-r--r--sql/item.h7
-rw-r--r--sql/item_cmpfunc.cc2
-rw-r--r--sql/item_func.cc12
-rw-r--r--sql/item_func.h1
-rw-r--r--sql/sql_select.cc4
5 files changed, 10 insertions, 16 deletions
diff --git a/sql/item.h b/sql/item.h
index 79cde008946..75ebcdb624c 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -1000,6 +1000,13 @@ public:
virtual bool val_bool();
virtual String *val_nodeset(String*) { return 0; }
+ bool eval_const_cond()
+ {
+ DBUG_ASSERT(const_item());
+ DBUG_ASSERT(!is_expensive());
+ return val_bool();
+ }
+
/*
save_val() is method of val_* family which stores value in the given
field.
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 2c1320f82b3..28e94275c85 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -4667,7 +4667,7 @@ Item_cond::fix_fields(THD *thd, Item **ref)
if (item->const_item() && !item->with_param &&
!item->is_expensive() && !cond_has_datetime_is_null(item))
{
- if (item->val_int() == is_and_cond && top_level())
+ if (item->eval_const_cond() == is_and_cond && top_level())
{
/*
a. This is "... AND true_cond AND ..."
diff --git a/sql/item_func.cc b/sql/item_func.cc
index 169eb76d802..e995903b940 100644
--- a/sql/item_func.cc
+++ b/sql/item_func.cc
@@ -69,18 +69,6 @@ bool check_reserved_words(LEX_STRING *name)
/**
- @return
- TRUE if item is a constant
-*/
-
-bool
-eval_const_cond(COND *cond)
-{
- return ((Item_func*) cond)->val_int() ? TRUE : FALSE;
-}
-
-
-/**
Test if the sum of arguments overflows the ulonglong range.
*/
static inline bool test_if_sum_overflows_ull(ulonglong arg1, ulonglong arg2)
diff --git a/sql/item_func.h b/sql/item_func.h
index e3eab02f213..c387c56f3b4 100644
--- a/sql/item_func.h
+++ b/sql/item_func.h
@@ -2279,7 +2279,6 @@ extern enum_field_types agg_field_type(Item **items, uint nitems,
Item *find_date_time_item(Item **args, uint nargs, uint col);
double my_double_round(double value, longlong dec, bool dec_unsigned,
bool truncate);
-bool eval_const_cond(COND *cond);
extern bool volatile mqh_used;
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 280de2b2ef1..62365f48404 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -15644,7 +15644,7 @@ Item::remove_eq_conds(THD *thd, Item::cond_result *cond_value, bool top_level_ar
{
if (const_item() && !is_expensive())
{
- *cond_value= eval_const_cond(this) ? Item::COND_TRUE : Item::COND_FALSE;
+ *cond_value= eval_const_cond() ? Item::COND_TRUE : Item::COND_FALSE;
return (COND*) 0;
}
*cond_value= Item::COND_OK;
@@ -15658,7 +15658,7 @@ Item_bool_func2::remove_eq_conds(THD *thd, Item::cond_result *cond_value,
{
if (const_item() && !is_expensive())
{
- *cond_value= eval_const_cond(this) ? Item::COND_TRUE : Item::COND_FALSE;
+ *cond_value= eval_const_cond() ? Item::COND_TRUE : Item::COND_FALSE;
return (COND*) 0;
}
if ((*cond_value= eq_cmp_result()) != Item::COND_OK)