1. 21 Jul, 2011 9 commits
    • unknown's avatar
      Merge from 5.2 · ef2b4b14
      unknown authored
      ef2b4b14
    • unknown's avatar
      Test fix merge. · 678f4b2d
      unknown authored
      678f4b2d
    • unknown's avatar
      Fixed PBXT test. · a11a2b24
      unknown authored
      a11a2b24
    • unknown's avatar
      Merge 5.1->5.2 · f675536a
      unknown authored
      f675536a
    • unknown's avatar
      Removed incorrect fix and its test suite (the test suit is duplicate). · ee06e4d6
      unknown authored
      Fixed explains of previous patch.
      
      mysql-test/r/explain.result:
        Fixed explains of previous patch.
      mysql-test/r/join_outer.result:
        Fixed explains of previous patch.
      mysql-test/r/negation_elimination.result:
        Fixed explains of previous patch.
      mysql-test/r/view.result:
        Fixed explains of previous patch.
      mysql-test/suite/innodb/r/innodb_mysql.result:
        Removed duplicate test suite.
      mysql-test/suite/innodb/t/innodb_mysql.test:
        Removed duplicate test suite.
      mysql-test/suite/innodb_plugin/r/innodb_mysql.result:
        Removed duplicate test suite.
      mysql-test/suite/innodb_plugin/t/innodb_mysql.test:
        Removed duplicate test suite.
      sql/opt_range.h:
        Removed incorrect fix.
      sql/records.cc:
        Removed incorrect fix.
      ee06e4d6
    • unknown's avatar
      The function description added. · cbf48eb4
      unknown authored
      cbf48eb4
    • unknown's avatar
      Fix of LP BUG#777809 · 20a2e1d0
      unknown authored
      There are 2 volatile condition constructions AND/OR constructions and fields(references) when first
      good supported to be top elements of conditions because it is normal practice
      (see copy_andor_structure for example) fields without any expression in the condition is really rare
      and mostly useless case however it could lead to problems when optimiser changes/moves them unaware
      of other variables referring to them. An easy solution of this problem is just to replace single field
      in a condition with equivalent expression well supported by the server (<field> -> <field> != 0).
      
      mysql-test/r/view.result:
        New test added.
      mysql-test/t/view.test:
        New test added.
      sql/sql_parse.cc:
        <field> -> <field> != 0
      sql/sql_yacc.yy:
        <field> -> <field> != 0
      20a2e1d0
    • Igor Babaev's avatar
      Fixed LP bug #813447. · 4a03a1d7
      Igor Babaev authored
      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.
      4a03a1d7
    • Igor Babaev's avatar
      Fixed LP bug #791761. · 2e8542f4
      Igor Babaev authored
      An aggregating query over an empty set of a join of two tables
      with a rejecting HAVING clause erroneously could return a row.
      It could happen in the cases when the optimizer made a conclusion
      that the aggregating set was empty.
      Wrong results were produced because the server missed initial
      setting for aggregation functions in the mentioned cases.
            
      2e8542f4
  2. 20 Jul, 2011 6 commits
    • Igor Babaev's avatar
      Merge. · 6dc1cdc2
      Igor Babaev authored
      6dc1cdc2
    • Igor Babaev's avatar
      Fixed LP bug #702301. · 57f4965f
      Igor Babaev authored
      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.
      57f4965f
    • Igor Babaev's avatar
      Adjusted the results of the pbxt.subselect test after the push · 5ab7adfc
      Igor Babaev authored
      of the patch for bug 780386.
      5ab7adfc
    • unknown's avatar
      Fix of LP BUG#780386. · 2b6a2344
      unknown authored
      ALL subquery should return TRUE if subquery rowa set is empty independently
      of left part.  The problem was that Item_func_(eq,ne,gt,ge,lt,le) do not
      call execution of second argument if first is NULL no in this case subquery
      will not be executed and when Item_func_not_all calls any_value() of the
      subquery or aggregation function which report that there was rows. So for
      NULL < ALL (SELECT...) result was FALSE instead of TRUE.
      
      Fix is just swapping of arguments of Item_func_(eq,ne,gt,ge,lt,le) (with
      changing the operation if it is needed) so that result will be the same
      (for examole a < b is equal to b > a). This fix exploit the fact that
      first argument will be executed in any case.
      
      mysql-test/r/subselect.result:
        The test suite added.
      mysql-test/r/subselect_no_mat.result:
        The test suite added.
      mysql-test/r/subselect_no_opts.result:
        The test suite added.
      mysql-test/r/subselect_no_semijoin.result:
        The test suite added.
      mysql-test/r/subselect_scache.result:
        The test suite added.
      mysql-test/t/subselect.test:
        The test suite added.
      sql/item_cmpfunc.cc:
        Swap arguments creation methods added.
      sql/item_cmpfunc.h:
        Swap arguments creation methods added.
      sql/item_subselect.cc:
        Swap arguments of the comparison.
      2b6a2344
    • Sergey Petrunya's avatar
    • Sergey Petrunya's avatar
      Merge fix for BUG##806524 · 837c6722
      Sergey Petrunya authored
      837c6722
  3. 19 Jul, 2011 8 commits
    • Sergey Petrunya's avatar
      BUG##806524: Assertion `join->best_read < 1.7976931348623157e+308 with... · b11eff40
      Sergey Petrunya authored
      BUG##806524: Assertion `join->best_read < 1.7976931348623157e+308 with table_elimination=on and derived_merge=on 
      reset_nj_counters() used to rely on the fact that join nests have 
      table->table==NULL. This ceased to be true wit new derived table
      optimizations. Use test for table->nested_join!=NULL instead.
      b11eff40
    • unknown's avatar
      Fixed LP BUG#800696. · 99cce189
      unknown authored
      The problem was that optimizer removes some outer references (it they are
      constant for example) and the list of outer items built during prepare phase is
      not actual during execution phase when we need it as the cache parameters.
      First solution was use pointer on pointer on outer reference Item and
      initialize temporary table on demand. This solved most problem except case
      when optimiser also reduce Item which contains outer references ('OR' in
      this bug test suite).
      
      The solution is to build the list of outer reference items on execution
      phase (after optimization) on demand (just before temporary table creation)
      by walking Item tree and finding outer references among Item_ident
      (Item_field/Item_ref) and Item_sum items.
      
      Removed depends_on list (because it is not neede any mnore for the cache, in the place where it was used it replaced with upper_refs).
      
      Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references (or other expression parameters in future).
      
      mysql-test/r/subselect_cache.result:
        A new test added.
      mysql-test/r/subselect_scache.result:
        Changes in creating the cache and its paremeters order or adding arguments of aggregate function (which is a parameter also, but this has no influence on the result).
      mysql-test/t/subselect_cache.test:
        Added a new test.
      sql/item.cc:
        depends_on removed.
        
        Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references.
        
        Item_cache_wrapper collect parameters befor initialization of its cache.
      sql/item.h:
        depends_on removed.
        
        Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references.
      sql/item_cmpfunc.cc:
        depends_on removed.
        
        Added processor (collect_outer_ref_processor) to collect outer references.
      sql/item_cmpfunc.h:
        Added processor (collect_outer_ref_processor) to collect outer references.
      sql/item_subselect.cc:
        depends_on removed.
        Added processor get_cache_parameters() method to collect outer references.
      sql/item_subselect.h:
        depends_on removed.
        Added processor get_cache_parameters() method to collect outer references.
      sql/item_sum.cc:
        Added processor (collect_outer_ref_processor) method to collect outer references.
      sql/item_sum.h:
        Added processor (collect_outer_ref_processor) and get_cache_parameters() methods to collect outer references.
      sql/opt_range.cc:
        depends_on removed.
      sql/sql_base.cc:
        depends_on removed.
      sql/sql_class.h:
        New iterator added.
      sql/sql_expression_cache.cc:
        Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done).
      sql/sql_expression_cache.h:
        Build of list of items resolved in outer query done just before creating expression cache on the first execution of the subquery which removes influence of optimizer removing items (all optimization already done).
      sql/sql_lex.cc:
        depends_on removed.
      sql/sql_lex.h:
        depends_on removed.
      sql/sql_list.h:
        Added add_unique method to add only unique elements to the list.
      sql/sql_select.cc:
        Support of new Item list added.
      sql/sql_select.h:
        Support of new Item list added.
      99cce189
    • Sergey Petrunya's avatar
    • Sergey Petrunya's avatar
      Buildbot fixes: add --sorted-result · 775ac38d
      Sergey Petrunya authored
      775ac38d
    • Sergey Petrunya's avatar
      Merge · 265b51df
      Sergey Petrunya authored
      265b51df
    • Igor Babaev's avatar
      Merge. · cfc78964
      Igor Babaev authored
      cfc78964
    • Igor Babaev's avatar
      Merge. · fdad4063
      Igor Babaev authored
      fdad4063
    • Igor Babaev's avatar
      f392edab
  4. 18 Jul, 2011 2 commits
    • unknown's avatar
      Fix bug lp:782305 · c9e23682
      unknown authored
      Analysis:
      Both the wrong result and the valgrind warning were a result
      of incomplete cleanup of the MIN/MAX subquery rewrite. At the
      first execution of the query, the non-aggregate subquery is
      transformed into an aggregate MIN/MAX subquery. During the
      fix_fields phase of the MIN/MAX function, it sets the property
      st_select_lex::with_sum_func to true.
      
      The second execution of the query finds this flag to be ON.
      When optimization reaches the same MIN/MAX subquery
      transformation, it tests if the subquery is an aggregate or not.
      Since select_lex->with_sum_func == true from the previous
      execution, the transformation executes the second branch that
      handles aggregate subqueries. This substitutes the subquery
      Item into a Item_maxmin_subselect. At the same time elsewhere
      it is assumed that the subquery Item is of type
      Item_allany_subselect. Ultimately this results in casting the
      actual object to the wrong class, and calling the wrong
      any_value() method from empty_underlying_subquery().
      
      Solution:
      Cleanup the st_select_lex::with_sum_func property in the case
      when the MIN/MAX transformation was performed for a non-aggregate
      subquery, so that the transformation can be repeated.
      c9e23682
    • Igor Babaev's avatar
      Fixed LP bug #793448. · a7287d9a
      Igor Babaev authored
      This bug could lead to wrong result sets for a query over a
      materialized derived table or view accessed by a multi-component
      key.
      It happened because the function get_next_field_for_derived_key
      was supposed to update its argument, and it did not do it.
      a7287d9a
  5. 17 Jul, 2011 2 commits
    • Igor Babaev's avatar
      Merge with the latest 5.3 code. · cc0195d6
      Igor Babaev authored
      cc0195d6
    • Igor Babaev's avatar
      Fixed LP bug #794901. · d37465a9
      Igor Babaev authored
      Also:
      1. simplified the code of the function mysql_derived_merge_for_insert.
      2. moved merge of views/dt for multi-update/delete to the prepare stage.
      3. the list of the references to the candidates for semi-join now is
         allocated in the statement memory.
      d37465a9
  6. 15 Jul, 2011 4 commits
  7. 14 Jul, 2011 9 commits
    • Sergey Petrunya's avatar
      Merge · 0a12fa29
      Sergey Petrunya authored
      0a12fa29
    • Sergey Petrunya's avatar
      0aaae1e3
    • Sergey Petrunya's avatar
      Valgrind fix for the previous cset: · 08fa757a
      Sergey Petrunya authored
      - {ha_myisam,ha_maria}::index_read_idx_map should also initialize end_range, because index condition 
        function will attempt to check it. We initialize it like index_init() does.
      08fa757a
    • Sergey Petrunya's avatar
      BUG#803457: Wrong result with semijoin + view + outer join in maria-5.3-subqueries-mwl90 · 56a23357
      Sergey Petrunya authored
      (This is not a real fix for this bug, even though it makes it to no longer repeat)
      - Semi-join subquery predicates, i.e. ... WHERE outer_expr IN (SELECT ...) may have null-rejecting properties,
        may allow to convert outer joins into inner.
      - When convert_subq_to_sj() injected IN-equality into parent's WHERE/ON clause, it didn't call 
        $new_cond->top_level_item(), which would cause null-rejecting properties to be lost.
      - Fixed, now the mentioned outer-to-inner conversion will really take place.
      56a23357
    • unknown's avatar
      MWL#68 efficient partial matching · 445fcaa8
      unknown authored
      - Added an initial set of feature-specific test cases
      - Handled the special case where the materialized subquery of an
        IN predicates consists of only NULL values.
      - Fixed a bug where making Item_in_subselect a constant,
        didn't respect its null_value value.
      445fcaa8
    • Sergey Petrunya's avatar
      Merge · 932d5166
      Sergey Petrunya authored
      932d5166
    • Sergey Petrunya's avatar
      BUG#778434 Wrong result with in_to_exists=on in maria-5.3-mwl89 · 2a9c86be
      Sergey Petrunya authored
      - Make {ha_myisam,ha_maria}::index_read_idx_map check pushed index condition.
      - Address review feedback (added comments)
      2a9c86be
    • unknown's avatar
      Fix bug lp:777691 · 53681ee5
      unknown authored
      Analysis:
      
      For some of the re-executions of the correlated subquery the
      where clause is false. In these cases the execution of the
      subquery detects that it must generate a NULL row because of
      implicit grouping. In this case the subquery execution reaches
      the following code in do_select():
      
              while ((table= li++))
                mark_as_null_row(table->table);
      
      This code marks all rows in the table as complete NULL rows.
      In the example, when evaluating the field t2.f10 for the second
      row, all bits of Field::null_ptr[0] are set by the previous call
      to mark_as_null_row(). Then the call to Field::is_null()
      returns true, resulting in a NULL for the MAX function.
      
      Thus the lines above are not suitable for subquery re-execution
      because mark_as_null_row() changes the NULL bits of each table
      field, and there is no logic to restore these fields.
      
      Solution:
      
      The call to mark_as_null_row() was added by the fix for bug
      lp:613029. Therefore removing the fix for lp:613029 corrects
      this wrong result. At the same time the test for lp:613029
      behaves correctly because the changes of MWL#89 result in a
      different execution path where:
      - the constant subquery is evaluated via JOIN::exec_const_cond
      - detecting that it has an empty result triggers the branch
        if (zero_result_cause)
          return_zero_rows()
      - return_zero_rows() calls mark_as_null_row().
      
      53681ee5
    • unknown's avatar
      Automatic merge. · c4097382
      unknown authored
      c4097382