Commit graph

129 commits

Author SHA1 Message Date
Sergey Petrunya
92003f0166 MDEV-4836: Merge into 5.5-main 2013-09-03 18:41:07 +04:00
Igor Babaev
59af095da4 Merge 5.3->5.5 2013-08-29 12:32:09 -07:00
Igor Babaev
37f18d2318 Fixed bug mdev-4962.
When a non-nullable datetime field is used under an IS NULL predicate
of the WHERE condition in a query with outer joins the remove_eq_conds
function should check whether this field belongs to an inner table
of any outer join that can be, in a general case, a nested outer join.
2013-08-29 10:56:12 -07:00
Sergey Petrunya
d6f7649d3c mdev-4942: Add another testcase after merging with other fixes. 2013-08-28 21:21:12 +04:00
Sergey Petrunya
184df98582 Automatic merge of MDEV-4836 fix into 5.5 2013-08-28 20:31:23 +04:00
Igor Babaev
34aa69564d Merge 5.3->5.5 2013-08-27 22:19:14 -07:00
Igor Babaev
650d3266bb Fixed bug mdev-4952
When in function remove_eq_conds() a sub-formula of the processed condition
is replaced for another formula we should ensure that in the resulting
formula AND/OR levels must alternate.
2013-08-26 15:51:47 -07:00
Sergey Petrunya
edd980225a Fix for MDEV-4836 fix: take into account situation where "notnull_col IS NULL" is not
a direct child of the WHERE clause item, but rather is embedded inside Item_cond_and or 
Item_cond_or.
2013-08-26 21:38:04 +04:00
Sergey Petrunya
af753c2188 Fix for MDEV-4836: Merge with current 5.5 2013-08-26 16:31:58 +04:00
Sergey Petrunya
7907b9b4da Merge fix for MDEV-4942, 5.3->5.5 2013-08-26 16:23:14 +04:00
Igor Babaev
dbc84ff96c Fixed bug mdev-4942.
Made sure that degenerate conjunctions/disjunctions are obtained from
AND/OR conditions.
2013-08-23 22:17:02 -07:00
Sergey Petrunya
970542ec90 MDEV-4836: Wrong result on <not null date column> IS NULL (old documented hack stopped working)
- When applying optimization introduced by MDEV-4817, ignore the conditions that have form
  "datetime_not_null_col IS NULL".
2013-08-23 16:32:56 +04:00
Sergey Petrunya
04684b7709 MDEV-4817: Optimizer fails to optimize expression of the form 'FOO' IS NULL
- Modify the way Item_cond::fix_fields() and Item_cond::eval_not_null_tables() 
  calculate bitmap for Item_cond_or::not_null_tables():
  if they see a "... OR inexpensive_const_false_item OR ..." then the item can
  be ignored.
- Updated test results. There can be more warnings produced since parts of WHERE 
  are evaluated more times.
2013-07-31 17:24:52 +04:00
Sergei Golubchik
b381cf843c mysql-5.5.31 merge 2013-05-07 13:05:09 +02:00
Igor Babaev
75befe7526 Merge 5.3->5.5 2013-05-04 21:56:45 -07:00
Igor Babaev
920c479c6e Fixed bug mdev-4336.
When iterating over a list of conditions using List_iterator
the function remove_eq_conds should skip all predicates that
replace a condition from the list. Otherwise it can come to
an infinite recursion.
2013-05-03 22:46:45 -07:00
Chaithra Gopalareddy
cb72ecbe2c Merge from 5.1 to 5.5 2013-01-11 06:36:53 +05:30
Chaithra Gopalareddy
8b41f491c8 Bug#11760726: LEFT JOIN OPTIMIZED INTO JOIN LEADS TO
INCORRECT RESULTS

This is a backport of fix for Bug#13068506.

mysql-test/r/join_outer.result:
  Added test result for Bug#13068506
mysql-test/t/join_outer.test:
  Added test case for Bug#13068506
sql/item.h:
  Implement Item_outer_ref::not_null_tables()
2013-01-10 16:17:13 +05:30
unknown
e10fecc02f Merge 5.2->5.3 2012-05-11 11:40:23 +03:00
Sergei Golubchik
1185420da0 5.3 merge 2012-05-21 20:54:41 +02:00
unknown
f2cbc014d9 fix for LP bug#994392
The not_null_tables() of Item_func_not_all and Item_in_optimizer was inherited from
Item_func by mistake. It made the optimizer think that  subquery
predicates with ALL/ANY/IN were null-rejecting. This could trigger invalid
conversions of outer joins into inner joins.
2012-05-11 09:35:46 +03:00
Sergei Golubchik
a3073ecd96 merge 2012-04-05 23:07:18 +02:00
Sergei Golubchik
dea3544b2d mysql-5.1.62 merge 2012-04-05 10:49:38 +02:00
Sergei Golubchik
20e706689d mysql-5.5.22 merge
mysql-test/suite/innodb/t/group_commit_crash.test:
  remove autoincrement to avoid rbr being used for insert ... select
mysql-test/suite/innodb/t/group_commit_crash_no_optimize_thread.test:
  remove autoincrement to avoid rbr being used for insert ... select
mysys/my_addr_resolve.c:
  a pointer to a buffer is returned to the caller -> the buffer cannot be on the stack
mysys/stacktrace.c:
  my_vsnprintf() is ok here, in 5.5
2012-03-28 01:04:46 +02:00
Igor Babaev
8b469eb515 Merge 5.3->5.5. 2012-03-01 14:22:22 -08:00
Igor Babaev
000deedf3b Fixed LP bug #943543.
This bug appeared after the patch for bug 939009 that in the
function merge_key_fields forgot to reset a proper value for
the val field in the result of the merge operation of the key
field created for a regular key access and  the key field
created to look for a NULL key.

Adjusted the results of the test case for bug 939009 that
actually were incorrect.
2012-02-29 23:28:16 -08:00
Martin Hansson
bb9a3be632 Merge of fix for Bug#11765810. 2012-02-07 17:32:04 +01:00
Martin Hansson
9ada2f8ec5 Bug #11765810 58813: SERVER THREAD HANGS WHEN JOIN + WHERE + GROUP BY
IS EXECUTED TWICE FROM P

This bug is a duplicate of bug 12567331, which was pushed to the
optimizer backporting tree on 2011-06-11. This is just a back-port of
the fix. Both test cases are included as they differ somewhat.
2012-02-07 14:16:09 +01:00
Sergei Golubchik
4f435bddfd 5.3 merge 2012-01-13 15:50:02 +01:00
Igor Babaev
a910e8ef5b Made join_cache_level == 2 by default. 2011-12-15 14:26:59 -08:00
Igor Babaev
f5dac20f38 Made the optimizer switch flags 'outer_join_with_cache', 'semijoin_with_cache'
set to 'on' by default.
2011-12-15 00:21:15 -08:00
Sergei Golubchik
d2755a2c9c 5.3->5.5 merge 2011-11-22 18:04:38 +01:00
Sergei Golubchik
76f0b94bb0 merge with 5.3
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
2011-10-19 21:45:18 +02:00
Igor Babaev
715dc5f99d Fixed a cost estimation bug introduced into in the function best_access_path
of the 5.3 code line after a merge with 5.2 on 2010-10-28
in order not to allow the cost to access a joined table to be equal
to 0 ever.

Expanded data sets for many test cases to get the same execution plans
as before.
2011-09-30 18:55:02 -07:00
Igor Babaev
da59130ec1 Fixed LP bug #838633.
For any query JOIN::optimize() should call the method
SELECT::save_leaf_tables after the last transformation
that utilizes the statement memory rather than the 
execution memory.
2011-09-06 07:17:39 -07:00
Igor Babaev
249a10c7dd Fixed LP bug #825035.
The value of maybe_null flag should be saved for the second execution
of a prepared statement from SELECT that uses an outer join.
2011-08-16 22:48:35 -07:00
unknown
a6037394e3 Fix bug lp:817384
This bug is a special case of lp:813447.

Analysis:
Constant optimization finds that the condition t2.a = 1
can be used to access the primary key of table 't2'. As
a result both outer table t1,t2 are considered as constant
when we reach the execution phase. At the same time, during
constant optimization, the IN predicate is not evaluated
because it is expensive.

When execution of the outer query reaches do_select(),
control flow enter the branch:
if (join->table_count == join->const_tables)
{ ... }
This branch checks only the WHERE and HAVING clauses,
but doesn't check the ON clauses of the query. Since the
IN predicate was not evaluated during optimization, it is
not evaluated at all, thus execution doesn't detect that
the ON clause is FALSE.

Solution:
Similar to the patch for bug lp:813447, exclude system
tables from constant substitution based on unique key
lookups if there is an expensive ON condition on the
inner table.
2011-08-09 10:28:57 +03:00
Igor Babaev
4a03a1d777 Fixed LP bug #813447.
Do not make substitution of a single-row table if it is an inner
table of an outer join with on expression containing an expensive
subquery.
2011-07-21 00:43:37 -07:00
Sergei Golubchik
b4a0b2c2f8 post-merge fixes.
most tests pass.
5.3 merge is next
2011-07-02 22:12:12 +02:00
Sergei Golubchik
9809f05199 5.5-merge 2011-07-02 22:08:51 +02:00
Ole John Aske
ed74edada2 Fix for bug#58490, 'Incorrect result in multi level OUTER JOIN
in combination with IS NULL'
      
As this bug is a duplicate of bug#49322, it also includes test cases
covering this bugreport
      
Qualifying an OUTER JOIN with the condition 'WHERE <column> IS NULL',
where <column> is declared as 'NOT NULL' causes the
'not_exists_optimize' to be enabled by the optimizer.
      
In evaluate_join_record() the 'not_exists_optimize' caused
'NESTED_LOOP_NO_MORE_ROWS' to be returned immediately
when a matching row was found.
      
However, as the 'not_exists_optimize' is derived from
'JOIN_TAB::select_cond', the usual rules for condition guards
also applies for 'not_exist_optimize'. It is therefore incorrect
to check 'not_exists_optimize' without ensuring that all guards
protecting it is 'open'.
      
This fix uses the fact that 'not_exists_optimize' is derived from
a 'is_null' predicate term in 'tab->select_cond'. Furthermore,
'is_null' will evaluate to 'false' for any 'non-null' rows
once all guards protecting the is_null is open.
      
We can use this knowledge as an implicit guard check for the
'not_exists_optimize' by moving 'if (...not_exists_optimize)'
inside the handling of 'select_cond==false'. It will then
not take effect before its guards are open.
      
We also add an assert which requires that a
'not_exists_optimize' always comes together with
a select_cond. (containing 'is_null').
2011-02-01 15:19:34 +01:00
Michael Widenius
050c004f5e Merge with 5.1
Fixes to get Aria handler tests to work.
Fixes LP#697597 "HANDLER + Aria asserts in maria-5.3-handler"
2011-01-11 15:36:41 +02:00
Ole John Aske
a6c4129150 Fix for Bug#57034 incorrect OUTER JOIN result when joined on unique key
Item_equal::val_int() checked for NULL-values by checking Item::null_value
*before* the respective ::store_value() and ::cmp(Item*) metods where called.

As Item::null_value is set by these metods, the value of 'null_value' 
is not valid until *after* ::store_value() or ::cmp() has
been called for the Item object.
      
Fix is to swap order of ::store_value()/::cmp() and checking of Item::null_value.
This pattern is widely used other places inside item_cmpfunc.cc .
2011-01-13 09:33:30 +01:00
unknown
92fc426386 Speed up mtr --parallel=<lots> by scheduling some slow tests earlier.
The patch also fixes a race in rpl_stop_slave.test.

On machines with lots of CPU and memory, something like `mtr --parallel=10`
can speed up the test suite enormously. However, we have a few test cases
that run for long (several minutes), and if we are unlucky and happen to
schedule those towards the end of the test suite, we end up with most
workers idle while waiting for the last slow test to end, significantly
delaying the finish of the entire suite.

Improve this by marking the offending tests as taking "long", and trying
to schedule those tests early. This reduces the time towards the end of
the test suite run where some workers are waiting with nothing to do for
the remaining workers each to finish their last test.

Also, the rpl_stop_slave test had a race which could cause it to take
a 300 seconds debug_sync timeout; this is fixed.

Testing on a 4-core 8GB machine, this patch speeds up the test suite with
around 30% for --parallel=10 (debug build), allowing to run the entire
suite in 5 minutes.
2011-01-03 15:33:39 +01:00
Igor Babaev
7f52af655a Merge. 2010-12-10 23:23:34 -08:00
Michael Widenius
b7b25dc666 Merge with 5.1-release.
- Fixed problem with oqgraph and 'make dist'

Note that after this merge we have a problem show in join_outer where we examine too many rows in one specific case (related to BUG#57024).
This will be fixed when mwl#128 is merged into 5.3.
2010-12-06 10:25:44 +02:00
Michael Widenius
1a6373e8e2 Merge with MySQL 5.1.53
Open issues:
- A better fix for #57688; Igor is working on this
- Test failure in index_merge_innodb.test ; Igor promised to look at this
- Some Innodb tests fails (need to merge with latest xtradb) ; Kristian promised to look at this.
 - Failing tests: innodb_plugin.innodb_bug56143 innodb_plugin.innodb_bug56632 innodb_plugin.innodb_bug56680 innodb_plugin.innodb_bug57255 
- Werror is disabled;  Should be enabled after merge with xtradb.
2010-11-25 00:57:34 +02:00
Sergey Glukhov
4a23ac20d9 Bug#57688 Assertion `!table || (!table->write_set || bitmap_is_set(table->write_set, field
Lines below which were added in the patch for Bug#56814 cause this crash:

+      if (table->table)
+        table->table->maybe_null= FALSE;

Consider following test case:
--
CREATE TABLE t1(f1 INT NOT NULL);
INSERT INTO t1 VALUES (16777214),(0);

SELECT COUNT(*) FROM t1 LEFT JOIN t1 t2
ON 1 WHERE t2.f1 > 1 GROUP BY t2.f1;

DROP TABLE t1;
--

We set TABLE::maybe_null to FALSE for t2 table
and in create_tmp_field() we create appropriate tmp table field
using create_tmp_field_from_item() function instead of
create_tmp_field_from_field. As a result we have
LONGLONG field. As we have GROUP BY clause we calculate
group buffer length, see calc_group_buffer().
Item from group list which is used for calculation
refer to the field from real tables and have LONG type.
So group buffer length become insufficient for storing of
LONGLONG value. It leads to overwriting of wrong memory
area in do_field_int() function which is called from
end_update().
After some investigation I found out that
create_tmp_field_from_item() is used only for OLAP
grouping and can not be used for common grouping
as it could be an incompatibility between tmp
table fields and group buffer length.
We can not remove create_tmp_field_from_item() call from
create_tmp_field as OLAP needs it and we can not use this
function for common grouping. So we should remove setting
TABLE::maybe_null to FALSE from simplify_joins().
In this case we'll get wrong behaviour of
list_contains_unique_index() back. To fix it we
could use Field::real_maybe_null() check instead of
Field::maybe_null() and add addition check of
TABLE_LIST::outer_join.


mysql-test/r/group_by.result:
  test case
mysql-test/r/join_outer.result:
  test case
mysql-test/t/group_by.test:
  test case
mysql-test/t/join_outer.test:
  test case
sql/sql_select.cc:
  --remove wrong code
  --use Field::real_maybe_null() check instead of
    Field::maybe_null() and add addition check of
    TABLE_LIST::outer_join
2010-10-29 12:23:06 +04:00
Igor Babaev
4f75a8254a Merge 5.3-mwl128 -> 5.3 2010-10-27 16:31:22 -07:00
Sergey Petrunya
508e75c259 Merge MariaDB 5.2 -> MariaDB 5.3
- post-merge fixes
2010-10-14 01:48:03 +04:00