summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorGeorgi Kodinov <kgeorge@mysql.com>2008-10-17 13:55:16 +0300
committerGeorgi Kodinov <kgeorge@mysql.com>2008-10-17 13:55:16 +0300
commitf1a1e89f5a16f7b48cbd2b47e9de5d881448fcb4 (patch)
tree6e18641ac6cca2fb89f3402f3b7e299c9ecbe1a9 /sql/item.h
parent4ab10baace0960f18a843beb880c99b6cd9ca2e3 (diff)
downloadmariadb-git-f1a1e89f5a16f7b48cbd2b47e9de5d881448fcb4.tar.gz
Bug #38637: COUNT DISTINCT prevents NULL testing in HAVING clause
IS NULL was not checking the correct row in a HAVING context. At the first row of a new group (where the HAVING clause is evaluated) the column and SELECT list references in the HAVING clause should refer to the last row of the previous group and not to the current one. This was not done for IS NULL, because it was using Item::is_null() doesn't have a Item_is_null_result() counterpart to access the data from the last row of the previous group. Note that all the Item::val_xxx() functions (e.g. Item::val_int()) have their _result counterparts (e.g. Item::val_int_result()). Fixed by implementing a is_null_result() (similarly to int_result()) and calling this instead of is_null() column and SELECT list references inside the HAVING clause.
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/sql/item.h b/sql/item.h
index 250bb3f67ef..1058cc5dbb8 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -652,6 +652,7 @@ public:
virtual my_decimal *val_decimal_result(my_decimal *val)
{ return val_decimal(val); }
virtual bool val_bool_result() { return val_bool(); }
+ virtual bool is_null_result() { return is_null(); }
/* bit map of tables used by item */
virtual table_map used_tables() const { return (table_map) 0L; }
@@ -1301,6 +1302,7 @@ public:
String *str_result(String* tmp);
my_decimal *val_decimal_result(my_decimal *);
bool val_bool_result();
+ bool is_null_result();
bool send(Protocol *protocol, String *str_arg);
void reset_field(Field *f);
bool fix_fields(THD *, Item **);
@@ -1942,6 +1944,7 @@ public:
String *str_result(String* tmp);
my_decimal *val_decimal_result(my_decimal *);
bool val_bool_result();
+ bool is_null_result();
bool send(Protocol *prot, String *tmp);
void make_field(Send_field *field);
bool fix_fields(THD *, Item **);