diff options
author | Varun Gupta <varun.gupta@mariadb.com> | 2021-02-15 16:30:55 +0530 |
---|---|---|
committer | Varun Gupta <varun.gupta@mariadb.com> | 2021-02-16 11:53:13 +0530 |
commit | 3544643f0999081dcea022b67ecf7758c37b3ce9 (patch) | |
tree | b5200007e66e82616e03a771ce223b098a49daf7 /sql/item_subselect.cc | |
parent | 7e9a6b7f09bfb00e781d8ca63dfe7701900c368b (diff) | |
download | mariadb-git-3544643f0999081dcea022b67ecf7758c37b3ce9.tar.gz |
MDEV-23291: SUM column from a derived table returns invalid values
The issue here was the read_set bitmap was not set for a field which
was used as a reference in an inner select.
We need to make sure that if we are in an inner select and we have
references from outer select then we update the table bitmaps for
such references.
Introduced a function in the class Item_subselect that would
update bitmaps of table for the references within a
subquery that are defined in outer selects.
Diffstat (limited to 'sql/item_subselect.cc')
-rw-r--r-- | sql/item_subselect.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index 1ef74d19172..3424df1eb91 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -437,6 +437,26 @@ bool Item_subselect::mark_as_dependent(THD *thd, st_select_lex *select, /* + @brief + Update the table bitmaps for the outer references used within a subquery +*/ + +bool Item_subselect::update_table_bitmaps_processor(void *arg) +{ + List_iterator<Ref_to_outside> it(upper_refs); + Ref_to_outside *upper; + + while ((upper= it++)) + { + if (upper->item && + upper->item->walk(&Item::update_table_bitmaps_processor, FALSE, arg)) + return TRUE; + } + return FALSE; +} + + +/* Adjust attributes after our parent select has been merged into grandparent DESCRIPTION |