Commit graph

33 commits

Author SHA1 Message Date
Sergey Petrunya
409902f884 MWL#90: address review feedback: more test coverage
- Forgot to add .result file
2011-04-05 11:16:28 +04:00
Sergey Petrunya
8fb724281e Merge MWL#90 with main 5.3 tree 2011-04-02 14:09:00 +04:00
unknown
428b52f503 Fix LP BUG#719198, LP BUG#730604
Analysis (BUG#719198):
The assert failed because the execution code for
partial matching is designed with the assumption that
NULLs on the left side are detected as early as possible,
and a NULL result is returned before any lookups are
performed at all.

However, in the case of an Item_cache object on the left
side, null was not detected properly, because detection
was done via Item::is_null(), which is not implemented at
all for Item_cache, and resolved to the default Item::is_null()
which always returns FALSE.

Solution:
Imlpement Item::is_null().

******

Analysis (BUG#730604):
The method Item_field::is_null() determines if an item is NULL from its
Item_field::field object. However, for Item_fields that represent internal
temporary tables, Item_field::field represents the field of the original
table that was the source for the temporary table (in this case t1.f3).
Both in the committed test case, and in the original bug report the current
value of t1.f3 is not NULL. This results in an incorrect count of NULLs
for this column. As a consequence, all related Ordered_key buffers are
allocated with incorrect sizes. Depending on the exact query and data,
these incorrect sizes result in various crashes or failed asserts.

Solution:
The correct value of the current field of the internal temp table is
in Item_field::result_field. This value is determined by
Item::is_null_result().
2011-03-13 15:03:26 +00:00
Sergey Petrunya
b8f00542e2 BUG#724228: Wrong result with materialization=on and three aggregates in maria-5.3-mwl90
- In join buffering code, call join_tab_execution_startup() (#1) before we call join_tab_scan->open() (#2).
  This is important with SJ-Materialization because #1 fills the materialized table, while
  #2 will actually try to read the first row. Attempt to read the first row before we have
  populated the materialized table would cause zero rows to be returned when actually there were matches.
2011-03-01 12:01:10 +03:00
Sergey Petrunya
e4325ff60b MWL#90: Subqueries: Inside-out execution for materialized non-sj subqueries
- Merge with 5.3 (3)
2011-02-15 20:29:57 +03:00
Sergey Petrunya
b1e0e22e6d Testcase backport: BUG#46548 IN-subqueries return 0 rows with materialization=on
(the bug itself was fixed during the subquery code backport)
2011-01-14 13:51:30 +03:00
Igor Babaev
7f52af655a Merge. 2010-12-10 23:23:34 -08:00
Sergey Petrunya
1bf3964fbe MWL#90: Subqueries: Inside-out execution for materialized non-sj subqueries
- Merge into 5.3-main
2010-12-09 18:07:59 +03:00
unknown
970b46b1dc Fix LP BUG#611622
Fix MySQL BUG#52344 - Subquery materialization: Assertion if subquery in on-clause of outer join

Original fix and comments from Oysten, adjusted for the different
subquery optimization in MariaDB.
"
Problem: If tables of an outer join are constant tables,
the associated on-clause will be evaluated in the optimization
phase. If the on-clause contains a query that is to be
executed with subquery materialization, this will not work
since the infrastructure for such execution is not yet set up.
      
Solution: Do not evaluate on-clause in optimization phase if
is_expensive() returns true for this clause.  This is how the
problem is currently avoided for where-clauses.  This works
because, Item_in_subselect::is_expensive_processor returns true
if query is to be executed with subquery materialization.
"
In addition, after MWL#89, in MariaDB if the IN-EXISTS strategy
is chosen, the in-to-exists predicates are insterted after
join_read_const_table() is called, resulting in evaluation of
the subquery without the in-to-exists predicates.
2010-11-25 11:43:23 +02:00
Igor Babaev
0b72fd88a1 Merge. 2010-10-30 06:07:45 -07:00
Igor Babaev
4f75a8254a Merge 5.3-mwl128 -> 5.3 2010-10-27 16:31:22 -07:00
unknown
db4738a18a Fixed LP bug #609121
The bug was a result of missing logic to handle the case
when there are 'expensive' predicates that are not evaluated
during constant table optimization. Such is the case for
the IN predicate, which is considered expensive if it is
computed via materialization. In general this bug can be
triggered with any expensive predicate instead of IN.

When FALSE constant predicates are not evaluated during constant
optimization, the execution path changes so that instead of
setting JOIN::zero_result_cause after make_join_select, and
exiting JOIN::exec via the call to return_zero_rows(), execution
ends in JOIN::exec in the branch:
if (join->tables == join->const_tables)
{
  ...
  else if (join->send_row_on_empty_set())
     ...
     rc= join->result->send_data(*columns_list);
}
Unlike return_zero_rows(), this branch didn't evaluate the
having clause of the query.

The patch adds a call to evaluate the HAVING clause of a query even
when all tables are constant, because even for an empty result set
some aggregate functions may produce a NULL value.
2010-10-25 23:48:43 +03:00
Igor Babaev
25f5debdc7 MWL#128: Added into EXPLAIN output info about types of the used join buffers and
about the employed join algorithms.
Refactored constructors of the JOIN_CACHE* classes.
2010-10-18 13:33:05 -07:00
unknown
d6a9b52269 Fixed LP BUG#615760: Check on double cache assignment added into the transformation methods.
Cache parameters print added in EXPLAIN EXTENDED output.

mysql-test/r/compare.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/group_by.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect3.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect3_jcl6.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect4.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect_cache.result:
  Added test suite for LP BUG#615760
mysql-test/r/subselect_mat.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect_no_mat.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect_no_opts.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect_no_semijoin.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect_sj.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/r/subselect_sj_jcl6.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/suite/pbxt/r/subselect.result:
  Cache parameters print added in EXPLAIN EXTENDED output.
mysql-test/t/subselect_cache.test:
  Cache parameters print added in EXPLAIN EXTENDED output.
sql/item.cc:
  Item::set_expr_cache result fixed according to its description.
  
  Cache parameters print added in EXPLAIN EXTENDED output.
sql/item.h:
  Cache parameters print added in EXPLAIN EXTENDED output.
sql/item_cmpfunc.cc:
  Check on double cache assignment added into the transformation methods.
sql/item_cmpfunc.h:
  Check on double cache assignment added into the transformation methods.
sql/item_subselect.cc:
  Check on double cache assignment added into the transformation methods.
sql/item_subselect.h:
  Check on double cache assignment added into the transformation methods.
sql/sql_expression_cache.cc:
  Cache parameters print added.
sql/sql_expression_cache.h:
  Cache parameters print added.
sql/sql_select.cc:
  Removed unused method (now it is impossible to make double transformation with the cache).
sql/sql_select.h:
  Removed unused method.
2010-09-06 15:34:24 +03:00
unknown
97199ad56d LP BUG#615752 fix. Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/compare.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/explain.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/group_by.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect3.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect3_jcl6.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect4.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect_mat.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect_no_mat.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect_no_opts.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect_no_semijoin.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect_sj.result:
  Expression cache added to EXPLAIN EXTENDED output.
mysql-test/r/subselect_sj_jcl6.result:
  Expression cache added to EXPLAIN EXTENDED output.
sql/item.h:
  Expression cache added to EXPLAIN EXTENDED output.
2010-08-31 16:16:10 +03:00
unknown
2d78ffb8d5 Fixed a problem where the temp table of a materialized subquery
was not cleaned up between PS re-executions. The reason was two-fold:
- a merge with mysql-6.0 missed select_union::cleanup() that should
  have cleaned up the temp table, and
- the subclass of select_union used by materialization didn't call
  the base class cleanup() method.
2010-07-16 14:02:15 +03:00
psergey
3a9aabaa26 MWL#90: Subqueries: Inside-out execution for materialized non-sj subqueries
- Merge with MariaDB 5.3 -main
2010-07-11 19:18:43 +04:00
Sergey Petrunya
27f9fc063c MariaDB 5.2 -> MariaDB 5.3 merge 2010-06-26 14:05:41 +04:00
Sergey Petrunya
0390412782 Fix test results and testuite valgrind failures 2010-06-11 16:57:41 +04:00
Sergey Petrunya
fe7bfbe5c2 Update test results for the previous push 2010-06-10 23:10:51 +04:00
Sergey Petrunya
b33826e555 MWL#90, code cleanup
- Unify EXPLAIN printout for <subqueryN> tables with regular tables
- Update test results for <subqueryN> tables:
  s/unique_key/distinct_key/g
  s/1.0/100.0/ for "filtered" column
2010-06-09 18:43:52 +04:00
Sergey Petrunya
0cc3724697 MWL#90: Subqueries: Inside-out execution for non-semijoin materialized subqueries that are AND-parts of the WHERE
- Change "SUBQUERY#n" to "<subquery{n}>" in EXPLAIN output. We need to it to be
  lowercase so that EXPLAIN results do not differ in case between systems with
  case-sensitive and case-insensitive filesystems.
- Remove garbage comments, add better comments.
2010-05-27 16:14:25 +04:00
Sergey Petrunya
62bf7f6124 MWL#90: Subqueries: Inside-out execution for non-semijoin materialized subqueries that are AND-parts of the WHERE
- Code cleanu.
- Make MWL#90 code require @@optimizer_switch='semijoin=on'
- Update test results with the above
- Fork subselect_mat.test - we want to check both semi-join materialization, 
  which now has broader scope and non-semijoin materialization.
2010-05-25 10:32:15 +04:00
Sergey Petrunya
5a53be655c MWL#90: Subqueries: Inside-out execution for non-semijoin materialized subqueries that are AND-parts of the WHERE
- Merge into 5.3-subqueries
2010-05-24 15:24:20 +04:00
Sergey Petrunya
3f595889d3 Subqueries: Inside-out execution for non-semijoin materialized subqueries that are AND-parts of the WHERE
- Code cleanup
- Query plan change is due to s/ha_rows JOIN_TAB::read_time/double JOIN_TAB::read_time/
2010-05-23 23:13:18 +04:00
Sergey Petrunya
30bac79806 Always refer to materialized table as "SUBSELECT#%d" where %d is select number
- for Item-based materialization, it was "materialized subselect"
- for SJ-Materialization it was "subquery%d"
2010-04-07 01:29:09 +04:00
Sergey Petrunya
f46c5de011 MWL#90: Subqueries: Inside-out execution for non-semijoin materialized
subqueries that are AND-parts of the WHERE
- Make test results handle same-cost QEP races
2010-04-06 14:35:33 +04:00
unknown
3b05fc78e5 Fixed a problem where the temp table of a materialized subquery
was not cleaned up between PS re-executions. The reason was two-fold:
- a merge with mysql-6.0 missed select_union::cleanup() that should
  have cleaned up the temp table, and
- the subclass of select_union used by materialization didn't call
  the base class cleanup() method.
2010-04-06 00:15:15 +03:00
Sergey Petrunya
2775f80f7d MWL#90: Subqueries: Inside-out execution for non-semijoin materialized
subqueries that are AND-parts of the WHERE
- First code (needs cleanup).
2010-04-06 00:16:45 +04:00
Sergey Petrunya
8a06a7e3a7 MWL#110: Make EXPLAIN always show materialization separately
- Add Item_in_subselect::get_identifier() that returns subquery's id
- Change select_describe() to produce output in new format
- Update test results (checked)
2010-03-29 18:04:35 +04:00
Sergey Petrunya
ea982e336d Apply fix by oystein.grovlen@sun.com 2010-03-12:
Bug#48213 Materialized subselect crashes if using GEOMETRY type

The problem occurred because during semi-join a materialized table
was created which contained a GEOMETRY column, which is a specialized
BLOB column.  This caused an segmentation fault because such tables will
have extra columns, and the semi-join code was not prepared for that.

The solution is to disable materialization when Blob/Geometry columns would 
need to be materialized.  Blob columns cannot be used for index look-up 
anyway, so it does not makes sense to use materialization.

This fix implies that it is detected earlier that subquery materialization
can not be used.  The result of that is that in->exist optimization may
be performed for such queries.  Hence, extended query plans for such
queries had to be updated.

mysql-test/r/subselect_mat.result:
  Update extended query plan for subqueries that cannot use materialization
  due to Blobs.
mysql-test/r/subselect_sj.result:
  Updated result file.
mysql-test/r/subselect_sj_jcl6.result:
  Update result file.
mysql-test/t/subselect_sj.test:
  Add test case for Bug#48213 that verifies that semi-join works when subquery select list contain Blob columns.  Also verify that materialization is not
  used.
sql/opt_subselect.cc:
  Disable materialization for semi-join/subqueries when the subquery select list
  contain Blob columns.
2010-03-14 00:11:06 +03:00
Sergey Petrunya
02e9fa62e7 BUG#45174: XOR in subqueries produces differing results in 5.1 and 5.4
BUG#50019: Wrong result for IN-subquery with materialization
- Fix equality substitution in presense of semi-join materialization, lookup and scan variants
  (started off from fix by Evgen Potemkin, then modified it to work in all cases)
2010-03-13 23:04:52 +03:00
Sergey Petrunya
b83cb52e9e Backport of subquery optimizations to 5.3.
There are still test failures because of:
- Wrong query results in outer join + semi join
- EXPLAIN output differences
2010-01-17 17:51:10 +03:00