Commit graph

28298 commits

Author SHA1 Message Date
Igor Babaev
c05e5b9c65 Fixed LP bug #887479.
The function setup_semijoin_dups_elimination erroneously assumed
that if join_cache_level is set to 3 or 4 then the type of the
access to a table cannot be JT_REF or JT_EQ_REF. This could lead
to wrong query result sets.
2011-11-16 06:11:25 -08:00
Igor Babaev
4d358f48c9 Merge. 2011-11-15 14:35:36 -08:00
Igor Babaev
b4b7d941fe Fixed LP bug #889750.
If the optimizer switch 'semijoin_with_cache' is set to 'off' then 
join cache cannot be used to join inner tables of a semijoin.

Also fixed a bug in the function check_join_cache_usage() that led
to wrong output of the EXPLAIN commands for some test cases.
2011-11-15 13:03:00 -08:00
unknown
147721bbb6 Fix bug lp:889744
MariaDB 5.5 merges changes from MySQL 5.5 where all constant
expressions are wrapped into an Item_cache. As a result, constant
single-row subqueries were also wrapped in an Item_cache.
When analyzing the where clause for constant expressions that
can be evaluated during optimization, subqueries wrapped into
an Item_cache did not appear as expensive, and were therefore
evaluated during optimization. Such evaluation is against the
current architecture of MariaDB 5.3 where subquries are executed
during the execute phase.

The patch adds the is_expensive() predicate to Item_cache.
This makes Item_cache consistent with other wrapping Item
classes that need to look at the properties of the wrapped
object.
2011-11-14 19:24:36 +02:00
unknown
f76bfc40ea Fix for LP BUG#824425: Prohibiting subqueries in rows for left part of IN/ALL/ANY
Fix for walk() method of subqueries: always call the method on the subquery.
2011-11-13 12:02:13 +02:00
Sergei Golubchik
557f0d3ad0 5.2->5.3 merge 2011-11-12 18:08:12 +01:00
Sergei Golubchik
27095a24f6 5.1 merge 2011-11-12 16:47:14 +01:00
Igor Babaev
db0aed9348 Merge. 2011-11-12 03:57:46 -08:00
Igor Babaev
28b2eaa81a Fixed LP bug #823301.
A bug in the code of the function key_or could lead to a situation
when performing of an OR operation for one index changes the result
the operation for another index. This bug is fixed with this patch.

Also corrected the specification and the code of the function 
or_sel_tree_with_checks.
2011-11-12 02:20:44 -08:00
unknown
1d721d0106 Fix MySQL BUG#12329653
In MariaDB, when running in ONLY_FULL_GROUP_BY mode,
the server produced in incorrect error message that there
is an aggregate function without GROUP BY, for artificially
created MIN/MAX functions during subquery MIN/MAX optimization.

The fix introduces a way to distinguish between artifially
created MIN/MAX functions as a result of a rewrite, and normal
ones present in the query. The test for ONLY_FULL_GROUP_BY violation
now tests in addition if a MIN/MAX function was part of a MIN/MAX
subquery rewrite.

In order to be able to distinguish these MIN/MAX functions, the
patch introduces an additional flag in Item_in_subselect::in_strategy -
SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its
final choice of a subuqery strategy. In order to make the choice
consistent, access to Item_in_subselect::in_strategy is provided
via new class methods.
******
Fix MySQL BUG#12329653

In MariaDB, when running in ONLY_FULL_GROUP_BY mode,
the server produced in incorrect error message that there
is an aggregate function without GROUP BY, for artificially
created MIN/MAX functions during subquery MIN/MAX optimization.

The fix introduces a way to distinguish between artifially
created MIN/MAX functions as a result of a rewrite, and normal
ones present in the query. The test for ONLY_FULL_GROUP_BY violation
now tests in addition if a MIN/MAX function was part of a MIN/MAX
subquery rewrite.

In order to be able to distinguish these MIN/MAX functions, the
patch introduces an additional flag in Item_in_subselect::in_strategy -
SUBS_STRATEGY_CHOSEN. This flag is set when the optimizer makes its
final choice of a subuqery strategy. In order to make the choice
consistent, access to Item_in_subselect::in_strategy is provided
via new class methods.
2011-11-12 11:29:12 +02:00
Igor Babaev
b91a6bd88b Fixed LP bug #879871.
The function add_ref_to_table_cond missed updating the value of
join_tab->pre_idx_push_select_cond after having updated the value
of join_tab->select->pre_idx_push_select_cond.
2011-11-11 14:53:26 -08:00
Sergei Golubchik
04f3ecf632 typos fixed
(thanks viva64.com)
2011-11-08 23:07:19 +01:00
Sergey Petrunya
7c7611d728 BUG#887026: Wrong result with ICP, outer join, subquery in maria-5.3-icp
- Do not push index condition if we're using a triggered ref access.
2011-11-07 23:30:03 +04:00
Igor Babaev
e0500dbc3a Merge. 2011-11-06 13:44:59 -08:00
Igor Babaev
e0c1b3f242 Fixed LP bug #886145.
The bug happened because in some cases the function JOIN::exec
did not save the value of TABLE::pre_idx_push_select_cond in
TABLE::select->pre_idx_push_select_cond for the sort table.

Noticed and fixed a bug in the function make_cond_remainder
that builds the remainder condition after extraction of an index
pushdown condition from the where condition. The code
erroneously assumed that the function make_cond_for_table left
the value of ICP_COND_USES_INDEX_ONLY in sub-condition markers.
Adjusted many result files from the regression test suite
after this fix .
2011-11-06 01:23:03 -07:00
Igor Babaev
928e94fb98 Fixed LP bug #885168.
The call of the virtual function cancel_pushed_idx_cond in the code of
the function test_if_skip_sort_order was misplaced when backporting the
fix for bug 58816.
2011-11-04 05:39:45 -07:00
unknown
755cd443f9 Merge of gcc 4.6 fixes 2011-11-04 12:41:27 +02:00
Michael Widenius
ff92a3af8b Fixed that test doesn't abort if 'var' points to a deleted directory (common case when using --mem)
Better error message if --log-bin is used without --log-bin-index

mysql-test/lib/v1/mysql-test-run.pl:
  Fixed that test doesn't abort if 'var' points to a deleted directory (common case when using --mem)
sql/mysqld.cc:
  Better error message if --log-bin is used without --log-bin-index
2011-11-04 12:04:12 +02:00
Sergei Golubchik
6c27730adb rename binlog_dbug_fsync_sleep -> debug_binlog_fsync_sleep 2011-11-03 13:00:25 +01:00
Sergey Petrunya
178c6eced6 Merge 2011-11-02 22:06:22 +04:00
Sergey Petrunya
9b761df393 BUG#878753: Assertion '0' failed in replace_where_subcondition with derived_merge
- Remove the assert in replace_where_subcondition (the patch has explanation why)
2011-11-02 22:05:08 +04:00
Sergey Petrunya
64351feaac Merge 2011-11-02 13:51:47 +04:00
Sergey Petrunya
47861a6577 Change the default @@optimizer_switch settings:
- semijoin=on
- firstmatch=on
- loosescan=on
2011-11-02 13:48:41 +04:00
Igor Babaev
c1ebb566b3 Merge. 2011-11-02 01:22:11 -07:00
unknown
e6d01ad3b9 Merge of LP BUG#872775 fix 2011-11-02 10:05:07 +02:00
unknown
6498687325 Fix bug lp:833702
Analysis:
Equality propagation propagated the constant '7' into
args[0] of the Item_in_optimizer that stands for the
"< ANY" predicate. At the same the min/max subquery
rewrite swapped the order of the left and right operands
of the "<" predicate, but used Item_in_subselect::left_expr.

As a result, when the <ANY predicate is executed early in the
execution phase as a contant condition, instead of a constant
right (swapped) argument of the < predicate, there was a field
(t3.a). This field had no data, since the whole predicate is
considered constant, and it is evaluated before any tables are
read. Having junk in the field row buffer produced wrong result

Solution:
Fix create_swap to pick the correct Item_in_optimizer left
argument.
2011-11-01 18:19:19 +02:00
unknown
b40bc2b3e3 Fix of LP BUG#872775.
The problem was that merged views has its own nest_level numbering =>
when we compare nest levels we should take into considiration basis (i.e. 0 level),
if it is different then nest levels are not comparable.
2011-11-01 17:42:52 +02:00
Igor Babaev
a70f7aa5fe Backported the fix and the test case for bug 12822678 from the mysql-5.6 code line.
Fixed a bug in select_describe.
Adjusted results for affected test cases.
2011-11-01 07:00:55 -07:00
unknown
9c5644e6b7 Fix of typo. 2011-11-01 13:22:09 +02:00
Sergey Petrunya
f2b6f4e3df BUG#884184: Wrong result with RIGHT JOIN + derived_merge
- Make eliminate_tables_for_list() take into account that it is not possible
  to eliminate a table if it is used in the upper-side ON expressions. Example:

    xxx JOIN (t1 LEFT JOIN t2 ON cond ) ON func(t2.columns)

  Here it would eliminate t2 which is not possible because of use of t2.columns.
2011-11-01 12:36:43 +04:00
Sergey Petrunya
acb2d4aad8 BUG#884631: Table elimination works 5.3 release builds even if turned off
- Make table elimination to actually switch itself on/off in release builds.
2011-11-01 12:04:11 +04:00
Sergey Petrunya
57b3fefa03 BUG#882994: Crash in QUICK_RANGE_SELECT::reset with derived_with_keys
- The bug was caused by the following scenario:
  = a quick select is created with get_quick_select_for_ref. The quick 
    select refers to temporary (derived) table. It saves table->file, which
    refers to a ha_heap object.
  = When temp table is populated, ha_heap reaches max. size and is converted
    to a ha_myisam.  However, quick->file remains pointing to where ha_heap 
    was. 
  = Attempt to use the quick select causes crash.
- Fixed by introducing QUICK_SELECT_I::replace_handler(). Note that it will 
  not work for index_merge quick selects. Which is fine, because these
  quick selects are never created for derived tables.
2011-10-31 15:07:43 +04:00
Igor Babaev
7bc6a83b02 Backported the fix and the test case for bug #58816 from mysql-5.6 code line. 2011-10-29 15:36:24 -07:00
Igor Babaev
a8f5b5e866 Merge. 2011-10-28 05:19:45 -07:00
Igor Babaev
4b4dfd57f5 Merge. 2011-10-28 04:07:11 -07:00
Sergey Petrunya
3694bb90a4 - Let t/myisam_icp.test run include/icp_tests.inc with MRR/ICP turned ON (not OFF)
- Fix the compile-time-default value of optimizer_switch printed by mysqld --help --defaults
2011-10-28 12:38:36 +04:00
unknown
26387734fd Fix gcc 4.6 warning after merge with 5.1 2011-10-27 19:18:25 +03:00
Igor Babaev
aaa47b88a6 Merge. 2011-10-27 09:14:45 -07:00
Igor Babaev
2a3858d9d0 Fixed LP bug #874035.
The function Item_direct_view_ref::fix_fields erroneously did not correct
the value of the flag maybe_null when the view for which the item was
being fixed happened to be an inner table of an outer join.
2011-10-27 08:32:24 -07:00
unknown
dd564da398 5.1->5.2 merge (gcc 4.6 warnings and apple hwaddress fixes). 2011-10-27 17:51:30 +03:00
unknown
28e2777991 Fix gcc 4.6 warnings about assigned but not used variables.
Fixed my_gethwaddr.c to allow compilation on Mac OS X.
2011-10-27 15:22:52 +03:00
Sergey Petrunya
08e9e6a790 BUG#882472: subselect4.test fails in current 5.3
- The problem was that the value of READ_RECORD::file was not updated when the underlying table
  was temporary and was converted from heap to myisam. Resolved by eliminating READ_RECORD::file,
  always use READ_RECORD::table->file
2011-10-27 13:54:28 +04:00
Michael Widenius
fa36a7426b Fixed lp:879939 "assertion in ha_maria::enable_indexes with derived_with_keys=on"
Honor unique/not unique when creating keys for internal tempory tables.
Added new variables to be used to limit how keys are created for internal temporary tables.


include/maria.h:
  Added maria_max_key_length() and maria_max_key_segments()
include/myisam.h:
  Added myisam_max_key_length() and myisam_max_key_segments()
mysql-test/r/mysql.result:
  Drop all used tables
mysql-test/r/subselect4.result:
  Added test case for lp:879939
mysql-test/t/mysql.test:
  Drop all used tables
mysql-test/t/subselect4.test:
  Added test case for lp:879939
sql/mysql_priv.h:
  Added internal_tmp_table_max_key_length and internal_tmp_table_max_key_segments to be used to limit how keys for derived tables are created.
sql/mysqld.cc:
  Added internal_tmp_table_max_key_length and internal_tmp_table_max_key_segments to be used to limit how keys for derived tables are created.
sql/share/errmsg.txt:
  Added new error message for internal errors
sql/sql_select.cc:
  Give error if we try to create a wrong key (this error should never happen)
  Honor unique/not unique when creating keys for internal tempory tables.
storage/maria/ha_maria.cc:
  Added change_table_ptr() to ensure that external_ref points always to the correct table.
  (Not having this caused an assert in the included test)
storage/maria/ha_maria.h:
  Added change_table_ptr() to ensure that external_ref points always to the correct table.
storage/maria/ma_check.c:
  Fixed bug in Duplicate key error printing (now row position is printed correctly)
storage/maria/ma_create.c:
  maria_max_key_length() -> _ma_max_key_length()
storage/maria/ma_info.c:
  Added extern function maria_max_key_length() to calculate the max key length based on current block size.
storage/maria/ma_open.c:
  maria_max_key_length() -> _ma_max_key_length()
storage/maria/maria_def.h:
  maria_max_key_length() -> _ma_max_key_length()
storage/myisam/ha_myisam.cc:
  Added change_table_ptr() to ensure that external_ref points always to the correct table.
  (Not having this caused an assert in the included test)
storage/myisam/ha_myisam.h:
  Added change_table_ptr() to ensure that external_ref points always to the correct table.
2011-10-26 20:25:18 +03:00
Igor Babaev
16942bc5ca Fixed LP bug #881449.
The function SELECT_LEX::update_used_tables first must clean up
all bitmaps to be recalculated for all tables that require it
and only after this walk through on conditions attached to the
tables to update these bitmaps.
2011-10-26 04:27:09 -07:00
Sergey Petrunya
fbcff7a488 Merge fix for BUG#877288 2011-10-26 10:58:40 +04:00
Sergey Petrunya
8e6440df0b BUG#877288: Wrong result with semijoin + materialization + multipart key
- when create_ref_for_key() is constructing a ref access for
  a table that's inside a SJ-Materialization nest, it may not 
  use references to fields of tables that are unside the nest (because 
  these fields will not yet have values when ref access will be used)
  
  The check was performed in the first of create_ref_for_key's loops (the 
  one which counts how many key parts are usable) but not in the second
  (the one which actually fills the TABLE_REF structure).
2011-10-26 02:38:49 +04:00
Igor Babaev
a8f7c03c1e Fixed LP bug #881318.
If a materialized derived table / view is empty then for this table
the value of file->ref is 0. This was not taken into account by
the function JOIN_CACHE::write_record_data. As a result a query
using an empty materialized derived tables as inner tables of outer
joins and IN subqueries in WHERE conditions could cause server crashes
when the optimizer employed join caches and duplicate elimination for
semi-joins.
2011-10-25 14:18:19 -07:00
Igor Babaev
c0a1bd1ed6 Fixed LP bug #880724.
Do not create KEYUSEs for a materialized view over a constant table.
2011-10-24 12:54:28 -07:00
Igor Babaev
391c5db1fc Fixed LP bug #879882.
This bug happened because the function Item_cond::eval_not_null_tables
erroneously did not initialize the value of not_null_tables_cache.
2011-10-23 05:46:03 -07:00
Igor Babaev
2b173bf894 Fixed LP bug #878769.
The method DsMrr_impl::dsmrr_init erroneously tried to get a KEY descriptor
for key with number MAX_KEY. This caused valgrind complains.
2011-10-22 07:19:43 -07:00