summaryrefslogtreecommitdiff
path: root/sql/opt_sum.cc
Commit message (Collapse)AuthorAgeFilesLines
* 5.3 mergeSergei Golubchik2012-05-211-1/+3
|\
| * Merge 5.2->5.3unknown2012-05-111-1/+3
| |\
| | * Fix for LP bug#993726unknown2012-05-071-1/+3
| | | | | | | | | | | | Optimization of aggregate functions detected constant under max() and evalueted it, but condition in the WHWRE clause (which is always FALSE) was not taken into account
* | | Merge 5.3->5.5Igor Babaev2012-03-171-2/+8
|\ \ \ | |/ /
| * | Merge 5.2->5.3unknown2012-03-141-2/+8
| |\ \ | | |/
| | * Fixed LP bug #884175.Igor Babaev2012-03-081-2/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If in the where clause of the a query some comparison conditions on the field under a MIN/MAX aggregate function contained constants whose sizes exceeded the size of the field then the query could return a wrong result when the optimizer had chosen to apply the MIN/MAX optimization. With such conditions the MIN/MAX optimization still could be applied, yet it would require a more thorough analysis of the keys built to find the value of MIN/MAX aggregate functions with index look-ups. The current patch just prohibits using the MIN/MAX optimization in this situation.
* | | Merge MWL #247 from mariadb 5.3 -> mariadb 5.5.Igor Babaev2012-03-021-2/+2
|\ \ \
| * \ \ Merge.Igor Babaev2012-02-221-1/+6
| |\ \ \ | | |/ /
| * | | Merged MWL#247 into the latest 5.3.Igor Babaev2011-12-311-2/+2
| |\ \ \
| | * | | Implementation of the MWL#247: Make the optimizer use extended keys.Igor Babaev2011-12-311-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | The main patch. .
* | | | | 5.3.4 mergeSergei Golubchik2012-02-151-1/+6
|\ \ \ \ \ | | |_|/ / | |/| | |
| * | | | Merge 5.2->5.3 in preparation for the release of mariadb-5.3.4-rc.Igor Babaev2012-02-011-1/+6
| |\ \ \ \ | | |/ / / | |/| | / | | | |/ | | |/|
| | * | Fixed LP bug #879860.Igor Babaev2011-12-271-0/+4
| | | | | | | | | | | | | | | | | | | | The MIN/MAX optimization cannot be applied to a subquery if its WHERE clause contains a conjunctive condition depending on an outer reference.
| | * | Fixed LP bug #904345.Igor Babaev2011-12-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The MIN/MAX optimizer code from the function opt_sum_query erroneously did not take into account conjunctive conditions that did not depend on any table, yet were not identified as constant items. These could be items containing rand() or PS/SP parameters. These items are supposed to be evaluated at the execution phase. That's why if such conditions can be extracted from the WHERE condition the MIN/MAX optimization is not applied as currently it is always done at the optimization phase. (In 5.3 expensive subqueries are also evaluated only at the execution phase. So, if a constant condition with such subquery can be extracted from the WHERE clause the MIN/MAX optimization should not be applied in 5.3.) IF an IN/ALL/SOME predicate with a constant left part is transformed into an EXISTS subquery the resulting subquery should not be considered uncacheable if the right part of the predicate is not uncacheable. Backported the function dbug_print_item() from 5.3. The function is used only for debugging.
* | | | 5.3 mergeSergei Golubchik2012-01-131-3/+4
|\ \ \ \ | |/ / /
| * | | Merge with 5.1 & fixes to IGNORE handlingMichael Widenius2011-12-111-2/+4
| |\ \ \
| | * \ \ Merge with 5.2.Michael Widenius2011-12-111-2/+4
| | |\ \ \ | | | |/ / | | | | / | | | |/ | | |/| no_error handling for select (used by INSERT ... SELECT) still needs to be fixed, but I will do that in a separate commit
| | | * Merge with MariaDB 5.1Michael Widenius2011-11-241-2/+4
| | | |\
| | | | * Initail merge with MySQL 5.1 (XtraDB still needs to be merged)Michael Widenius2011-11-211-2/+4
| | | | |\ | | | | | | | | | | | | | | | | | | Fixed up copyright messages.
| | | | | * Updated/added copyright headersKent Boortz2011-07-031-13/+32
| | | | | |\
| * | | | | | BUG#901032: Wrong result for MIN/MAX on an indexed column with ↵Sergey Petrunya2011-12-081-1/+2
| |/ / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | materialization and semijoin - opt_sum_query() should not assume that join tables from sj-materialization have known numbers of rows.
* | | | | | 5.3->5.5 mergeSergei Golubchik2011-11-221-0/+4
|\ \ \ \ \ \ | |/ / / / /
| * | | | | Fix bug lp:858148.unknown2011-09-281-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Analysis: The crash is a result of the same cause as all similar bugs (lp:827416, lp:718763, lp:778413, lp:806943, lp:611690). The general pattern is that some optimization requires the evaluation of some condition (e.g. the WHERE clause), and this condition contains a subquery, such that the subquery itself requires a temporary table for its execution. During the subquery execution the original tables in the FROM clause are replaced by the temporary table needed for the final GROUP or ORDER operation. All this happens during optimization of the outer query. Later when EXPLAIN is run for the subquery, explain attempts to print the name of the tables in the FROM clause, but it finds there a temporary table without a corresponding TABLE_LIST object. The attempt to print the name of a NULL table list results in a crash. Solution: This patch extends the fix to bug lp:702301, and dissalows constant substitution of aggregate functions if the filter condition used to check MIN/MAX keys is an expensive condition.
| * | | | | Merge with 5.2Michael Widenius2011-09-101-0/+2
| |\ \ \ \ \ | | |/ / / /
| | * | | | LP BUG#813418 fix.unknown2011-09-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem was that optimization code did not take into account later feature when instad of NOT before BETWEEN it has negated flag into the Item_func_between inherited from Item_func_neg_opt. So optimizer tried process NOT BETWEEN as BETWEEN. The patch just switches off the optimisation for NOT BETWEEN as it was before when NOT function was really used.
* | | | | | mysql-5.5.18 mergeSergei Golubchik2011-11-031-1/+2
|\ \ \ \ \ \
| * \ \ \ \ \ Updated/added copyright headersKent Boortz2011-06-301-1/+1
| |\ \ \ \ \ \ | | | |_|_|/ / | | |/| | | |
| | * | | | | Updated/added copyright headersKent Boortz2011-06-301-2/+3
| | |\ \ \ \ \
| | | * | | | | Updated/added copyright headersKent Boortz2011-06-301-2/+3
| | | | | | | |
* | | | | | | | merge with 5.3Sergei Golubchik2011-10-191-23/+36
|\ \ \ \ \ \ \ \ | | |_|_|/ / / / | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sql/sql_insert.cc: CREATE ... IF NOT EXISTS may do nothing, but it is still not a failure. don't forget to my_ok it. ****** CREATE ... IF NOT EXISTS may do nothing, but it is still not a failure. don't forget to my_ok it. sql/sql_table.cc: small cleanup ****** small cleanup
| * | | | | | | Fixed LP bug #702301.Igor Babaev2011-07-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function matching_cond should take into account that there may be always false constant conjunctive conditions that has not been evaluated yet,for example, conjunctive conditions with non-correlated subqueries.
| * | | | | | | Fixed LP bug #802023.Igor Babaev2011-06-251-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Made mergeable views and mergeable derived tables transparent for the MIN/MAX optimization.
| * | | | | | | Fixed LP bug #800518.Igor Babaev2011-06-231-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The function simple_pred did not take into account that a multiple equality could include ref items (more exactly items of the class Item_direct_view_ref). It caused crashes for queries over derived tables or views if the min/max optimization could be applied to these queries.
| * | | | | | | MergeIgor Babaev2011-05-201-5/+17
| |\ \ \ \ \ \ \
| | * \ \ \ \ \ \ Merged the code of MWL#106 into 5.3Igor Babaev2011-05-161-5/+17
| | |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolved all conflicts, bad merges and fixed a few minor bugs in the code. Commented out the queries from multi_update, view, subselect_sj, func_str, derived_view, view_grant that failed either with crashes in ps-protocol or with wrong results. The failures are clear indications of some bugs in the code and these bugs are to be fixed.
| | | * \ \ \ \ \ \ Merge of the mwl106 tree into the latest 5.3 tree.Igor Babaev2010-09-231-5/+17
| | | |\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Resolved conflicts. Adjusted some test results
| | | | * | | | | | | MWL#106: Backport optimizations for derived tables and views.Igor Babaev2010-05-261-5/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main consolidated patch.
| * | | | | | | | | | Merge with MariaDB 5.2Michael Widenius2011-05-101-12/+30
| |\ \ \ \ \ \ \ \ \ \ | | |/ / / / / / / / / | |/| | | | | | / / / | | | |_|_|_|_|/ / / | | |/| | | | | | |
| | * | | | | | | | Merge with MariaDB 5.1Michael Widenius2011-05-031-12/+30
| | |\ \ \ \ \ \ \ \ | | | | |_|_|_|_|/ / | | | |/| | | | | |
| | | * | | | | | | Merge with MySQL 5.1.57/58Michael Widenius2011-05-021-12/+30
| | | |\ \ \ \ \ \ \ | | | | | |_|_|_|_|/ | | | | |/| | | | | | | | | | | | | | | Moved some BSD string functions from Unireg
| * | | | | | | | | MergeIgor Babaev2011-04-261-1/+1
| |\ \ \ \ \ \ \ \ \ | | |/ / / / / / / / | |/| | | | | | | |
| | * | | | | | | | Fixed LP bugs #717577, #724942.Igor Babaev2011-04-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Both these two bugs happened due to the following problem. When a view column is referenced in the query an Item_direct_view_ref object is created that is refers to the Item_field for the column. All references to the same view column refer to the same Item_field. Different references can belong to different AND/OR levels and, as a result, can be included in different Item_equal object. These Item_equal objects may include different constant objects. If these constant objects are substituted for the Item_field created for a view column we have a conflict situation when the second substitution annuls the first substitution. This leads to wrong result sets returned by the query. Bug #724942 demonstrates such an erroneous behaviour. Test case of the bug #717577 produces wrong result sets because best equal fields of the multiple equalities built for different OR levels of the WHERE condition differs. The subsitution for the best equal field in the second OR branch overwrites the the substitution made for the first branch. To avoid such conflicts we have to substitute for the references to the view columns rather than for the underlying field items. To make such substitutions possible we have to include into multiple equalities references to view columns rather than field items created for such columns. This patch modifies the Item_equal class to include references to view columns into multiple equality objects. It also performs a clean up of the class methods and adds more comments. The methods of the Item_direct_view_ref class that assist substitutions for references to view columns has been also added by this patch.
| * | | | | | | | | Merge with 5.1 to get in changes from MySQL 5.1.55Michael Widenius2011-02-281-1/+1
| |\ \ \ \ \ \ \ \ \ | | |/ / / / / / / / | |/| / / / / / / / | | |/ / / / / / /
| | * | | | | | | Merge with MySQL 5.1.55Michael Widenius2011-02-201-1/+1
| | |\ \ \ \ \ \ \ | | | | |_|_|_|/ / | | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Fixed some issues with partitions and connection_string, which also fixed lp:716890 "Pre- and post-recovery crash in Aria" - Fixed wrong assert in Aria Now need to merge with latest xtradb before pushing sql/ha_partition.cc: Ensure that m_ordered_rec_buffer is not freed before close. sql/mysqld.cc: Changed to use opt_stack_trace instead of opt_pstack. Removed references to pstack sql/partition_element.h: Ensure that connect_string is initialized storage/maria/ma_key_recover.c: Fixed wrong assert
* | | | | | | | | 5.5-mergeSergei Golubchik2011-07-021-13/+32
|\ \ \ \ \ \ \ \ \ | | |_|_|_|_|_|/ / | |/| | | | | | |
| * | | | | | | | Merge fix for Bug#11765713 from 5.1Tor Didriksen2011-04-151-12/+31
| |\ \ \ \ \ \ \ \ | | | |_|_|/ / / / | | |/| | | | | |
| | * | | | | | | Bug#11765713 58705: OPTIMIZER LET ENGINE DEPEND ON UNINITIALIZED VALUES ↵Tor Didriksen2011-04-141-12/+31
| | | |_|/ / / / | | |/| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | CREATED BY OPT_SUM_QU Valgrind warnings were caused by comparing index values to an un-initialized field. mysql-test/r/subselect.result: New test cases. mysql-test/t/subselect.test: New test cases. sql/opt_sum.cc: Add thd to opt_sum_query enabling it to test for errors. If we have a non-nullable index, we cannot use it to match null values, since set_null() will be ignored, and we might compare uninitialized data. sql/sql_select.cc: Add thd to opt_sum_query, enabling it to test for errors. sql/sql_select.h: Add thd to opt_sum_query, enabling it to test for errors.
| * | | | | | | Bug #57954: BIT_AND function returns incorrect results Georgi Kodinov2010-12-081-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | when semijoin=on When setting the aggregate function as having no rows to report the function no_rows_in_result() was calling Item_sum::reset(). However this function in addition to cleaning up the aggregate value by calling aggregator_clear() was also adding the current value to the aggregate value by calling aggregator_add(). Fixed by making no_rows_in_result() to call aggregator_clear() directly. Renamed Item_sum::reset to Item_sum::reset_and_add() to and added a comment to avoid misinterpretation of what the function does.
* | | | | | | | merge.Sergei Golubchik2010-11-251-34/+29
|\ \ \ \ \ \ \ \ | |/ / / / / / / |/| | / / / / / | | |/ / / / / | |/| | | | | | | | | | | | checkpoint. does not compile.
| * | | | | | Merge with MariaDB 5.1.49Michael Widenius2010-08-051-175/+163
| |\ \ \ \ \ \ | | | |/ / / / | | |/| / / / | | |_|/ / / | |/| | | | Removed references to HA_END_SPACE_KEY (which has been 0 for a long time)