summaryrefslogtreecommitdiff
path: root/sql/item.h
diff options
context:
space:
mode:
authorIgor Babaev <igor@askmonty.org>2021-06-02 08:40:30 -0700
committerIgor Babaev <igor@askmonty.org>2021-06-02 08:47:06 -0700
commit2e7891080667c59ac80f788eef4d59d447595772 (patch)
treeba18132163cbd715cfb20dd75cc61125de52c3cf /sql/item.h
parenta8434c6c59e291b65f1e294cafa4555470c3094c (diff)
downloadmariadb-git-2e7891080667c59ac80f788eef4d59d447595772.tar.gz
MDEV-25635 Assertion failure when pushing from HAVING into WHERE of view
This bug could manifest itself after pushing a where condition over a mergeable derived table / view / CTE DT into a grouping view / derived table / CTE V whose item list contained set functions with constant arguments such as MIN(2), SUM(1) etc. In such cases the field references used in the condition pushed into the view V that correspond set functions are wrapped into Item_direct_view_ref wrappers. Due to a wrong implementation of the virtual method const_item() for the class Item_direct_view_ref the wrapped set functions with constant arguments could be erroneously taken for constant items. This could lead to a wrong result set returned by the main select query in 10.2. In 10.4 where a possibility of pushing condition from HAVING into WHERE had been added this could cause a crash. Approved by Sergey Petrunya <sergey.petrunya@mariadb.com>
Diffstat (limited to 'sql/item.h')
-rw-r--r--sql/item.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/sql/item.h b/sql/item.h
index c94709c733e..76be66d2a7c 100644
--- a/sql/item.h
+++ b/sql/item.h
@@ -4952,7 +4952,10 @@ public:
table_map used_tables() const;
void update_used_tables();
table_map not_null_tables() const;
- bool const_item() const { return used_tables() == 0; }
+ bool const_item() const
+ {
+ return (*ref)->const_item() && (null_ref_table == NO_NULL_TABLE);
+ }
TABLE *get_null_ref_table() const { return null_ref_table; }
bool walk(Item_processor processor, bool walk_subquery, void *arg)
{