1. 01 Aug, 2012 1 commit
    • Elena Stepanova's avatar
      MDEV-369 (Mismatches in MySQL engines test suite) · 4f3674c8
      Elena Stepanova authored
      Following reasons caused mismatches:
        - different handling of invalid values;
        - different CAST results with fractional seconds;
        - microseconds support in MariaDB;
        - different algorithm of comparing temporal values;
        - differences in error and warning texts and codes;
        - different approach to truncating datetime values to time;
        - additional collations;
        - different record order for queries without ORDER BY;
        - MySQL bug#66034.
      More details in MDEV-369 comments.
      4f3674c8
  2. 30 Jul, 2012 1 commit
    • Elena Stepanova's avatar
      MDEV-369 (Mismatches in MySQL engines test suite) · d1a90e85
      Elena Stepanova authored
      Following reasons caused mismatches:
        - different handling of invalid values;
        - different CAST results with fractional seconds;
        - microseconds support in MariaDB;
        - different algorithm of comparing temporal values;
        - differences in error and warning texts and codes;
        - different approach to truncating datetime values to time;
        - additional collations;
        - different record order for queries without ORDER BY;
        - MySQL bug#66034.
      More details in MDEV-369 comments.
      d1a90e85
  3. 26 Jul, 2012 1 commit
  4. 18 Jul, 2012 1 commit
    • Sergey Petrunya's avatar
      MDEV-398: Sergv related to spacial queries · 7e6bec87
      Sergey Petrunya authored
      - index_merge/intersection is unable to work on GIS indexes, because:
        1. index scans have no Rowid-Ordered-Retrieval property
        2. When one does an index-only read over a GIS index, they do not 
           get the index tuple, because index only contains bounding box of the geometry.
           This is why key_copy() call crashed.
      This patch fixes #1, which makes the problem go away. Theoretically, it would 
      be nice to check #2, too, but SE API semantics is not sufficiently precise to do it.
      7e6bec87
  5. 26 Jun, 2012 1 commit
    • unknown's avatar
      Fix for LP bug#1007622 · 1b84c0cf
      unknown authored
      TABLE_LIST::check_single_table made aware about fact that now if table attached to a merged view it can be (unopened) temporary table
      (in 5.2 it was always leaf table or non (in case of several tables)).
      1b84c0cf
  6. 23 Jun, 2012 2 commits
  7. 22 Jun, 2012 1 commit
  8. 21 Jun, 2012 1 commit
  9. 20 Jun, 2012 2 commits
  10. 19 Jun, 2012 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-354. · 0c69f220
      Igor Babaev authored
      Virtual columns of ENUM and SET data types were not supported properly
      in the original patch that introduced virtual columns into MariaDB 5.2.
      The problem was that for any  virtual column the patch used the 
      interval_id field of the definition of the column in the frm file as
      a reference to the virtual column expression.
      The fix stores the optional interval_id of the virtual column in the
      extended header of the virtual column expression. 
      0c69f220
  11. 18 Jun, 2012 1 commit
  12. 15 Jun, 2012 1 commit
    • unknown's avatar
      Fix bug lp:1008686 · db6dbadb
      unknown authored
      Analysis:
      The fix for bug lp:985667 implements the method Item_subselect::no_rows_in_result()
      for all main kinds of subqueries. The purpose of this method is to be called from
      return_zero_rows() and set Items to some default value in the case when a query
      returns no rows. Aggregates and subqueries require special treatment in this case.
      
      Every implementation of Item_subselect::no_rows_in_result() called
      Item_subselect::make_const() to set the subquery predicate to its default value
      irrespective of where the predicate was located in the query. Once the predicate
      was set to a constant it was never executed.
      
      At the same time, the JOIN object of the fake select for UNIONs (the one used for
      the final result of the UNION), was set after all subqueries in the union were
      executed. Since we set the subquery as constant, it was never executed, and the
      corresponding JOIN was never created.
      
      In order to decide whether the result of NOT IN is NULL or FALSE, Item_in_optimizer
      needs to check if the subquery result was empty or not. This is where we got the
      crash, because subselect_union_engine::no_rows() checks for
      unit->fake_select_lex->join->send_records, and the join object was NULL.
      
      Solution:
      If a subquery is in the HAVING clause it must be evaluated in order to know its
      result, so that we can properly filter the result records. Once subqueries in the
      HAVING clause are executed even in the case of no result rows, this specific
      crash will be solved, because the UNION will be executed, and its JOIN will be
      constructed. Therefore the fix for this crash is to narrow the fix for lp:985667,
      and to apply Item_subselect::no_rows_in_result() only when the subquery predicate
      is in the SELECT clause.
      db6dbadb
  13. 14 Jun, 2012 1 commit
    • unknown's avatar
      Fix bug lp:1008773 · 88d3d853
      unknown authored
      Analysis:
      Queries with implicit grouping (there is aggregate, but no group by)
      follow some non-obvious semantics in the case of empty result set.
      Aggregate functions produce some special "natural" value depending on
      the function. For instance MIN/MAX return NULL, COUNT returns 0.
      
      The complexity comes from non-aggregate expressions in the select list.
      If the non-aggregate expression is a constant, it can be computed, so
      we should return its value, however if the expression is non-constant,
      and depends on columns from the empty result set, then the only meaningful
      value is NULL.
      
      The cause of the wrong result was that for subqueries the optimizer didn't
      make a difference between constant and non-constant ones in the case of
      empty result for implicit grouping.
      
      Solution:
      In all implementations of Item_subselect::no_rows_in_result() check if the
      subquery predicate is constant. If it is constant, do not set it to the
      default value for implicit grouping, instead let it be evaluated.
      88d3d853
  14. 12 Jun, 2012 3 commits
    • Igor Babaev's avatar
    • Igor Babaev's avatar
      Merge. · 01cd1235
      Igor Babaev authored
      01cd1235
    • Igor Babaev's avatar
      Fixed LP bug #1008293. · 7b32d88c
      Igor Babaev authored
      One of the reported problems manifested itself in the scenario when one
      thread tried to to get statistics on a key cache while the second thread
      had not finished initialization of the key cache structure yet. 
      The problem was resolved by forcing serialization of such operations
      on key caches.
      
      To serialize function calls to perform certain operations over a key cache
      a new mutex associated with the key cache now is used. It is stored in the
      field op_lock of the KEY_CACHE structure. It is locked when the operation
      is performed. Some of the serialized key cache operations utilize calls 
      for other key cache operations. To avoid recursive locking of op_lock
      the new functions that perform the operations of key cache initialization,
      destruction and re-partitioning with an additional parameter were introduced.
      The parameter says whether the operation over op_lock are to be performed or
      are to be omitted. The old functions for the operations of key cache 
      initialization, destruction,and  re-partitioning  now just call the
      corresponding new functions with the additional parameter set to true
      requesting to use op_lock while all other calls of these new function
      have this parameter set to false. 
      
      Another problem reported in the bug entry concerned the operation of
      assigning an index to a key cache. This operation can be called
      while the key cache structures are not initialized yet. In this
      case any call of flush_key_blocks() should return without any actions.
      
      No test case is provided with this patch.
      7b32d88c
  15. 10 Jun, 2012 4 commits
  16. 08 Jun, 2012 1 commit
    • Vladislav Vaintroub's avatar
      LP1008334 : Speedup specific datetime queries that got slower with... · afe1ef5e
      Vladislav Vaintroub authored
      LP1008334 : Speedup specific datetime queries that got slower with introduction of microseconds in 5.3
      
      - Item::get_seconds() now skips decimal arithmetic, if decimals is 0. This significantly speeds up from_unixtime() if no fractional part is passed.
      - replace sprintfs used to format temporal values  by hand-coded formatting 
        
      Query1 (original query in the bug report)
      BENCHMARK(10000000,DATE_SUB(FROM_UNIXTIME(RAND() * 2147483648), INTERVAL (FLOOR(1 + RAND() * 365)) DAY)) 
        
      Query2 (Variation of query1 that does not use fractional part in FROM_UNIXTIME parameter)
      BENCHMARK(10000000,DATE_SUB(FROM_UNIXTIME(FLOOR(RAND() * 2147483648)), INTERVAL (FLOOR(1 + RAND() * 365)) DAY)) 
        
      Prior to the patch, the runtimes were (32 bit compilation/AMD machine)
      Query1: 41.53 sec 
      Query2: 23.90 sec
        
      With the patch, the runtimes are
      Query1: 32.32 sec (speed up due to removing sprintf)
      Query2: 12.06 sec (speed up due to skipping decimal arithmetic)
      afe1ef5e
  17. 06 Jun, 2012 1 commit
  18. 05 Jun, 2012 1 commit
    • unknown's avatar
      Fixed bug lp:1000649 · f1ab0089
      unknown authored
      Analysis:
      
      When the method JOIN::choose_subquery_plan() decided to apply
      the IN-TO-EXISTS strategy, it set the unit and select_lex
      uncacheable flag to UNCACHEABLE_DEPENDENT_INJECTED unconditionally.
      As result, even if IN-TO-EXISTS injected non-correlated predicates,
      the subquery was still treated as correlated.
      
      Solution:
      Set the subquery as correlated only if the injected predicate(s) depend
      on the outer query.
      f1ab0089
  19. 04 Jun, 2012 1 commit
  20. 02 Jun, 2012 1 commit
  21. 01 Jun, 2012 4 commits
  22. 30 May, 2012 1 commit
    • unknown's avatar
      Fix for bug lp:1006231 · 66dfceb1
      unknown authored
      Analysis:
      
      When a subquery that needs a temp table is executed during
      the prepare or optimize phase of the outer query, at the end
      of the subquery execution all the JOIN_TABs of the subquery
      are replaced by a new JOIN_TAB that selects from the temp table.
      However that temp table has no corresponding TABLE_LIST.
      Once EXPLAIN execution reaches its last phase, it tries to print
      the names of the subquery tables through its TABLE_LISTs, but in
      the case of this bug there is no such TABLE_LIST (it is NULL),
      hence a crash.
      
      Solution:
      The fix is to block subquery evaluation inside
      Item_func_like::fix_fields and Item_func_like::select_optimize()
      using the Item::is_expensive() test.
      66dfceb1
  23. 29 May, 2012 1 commit
    • Alexey Botchkov's avatar
      MDEV-294 SELECT WHERE ST_CONTAINS doesn't return all the records where ST_CONTAINS() is 1. · 662c51ba
      Alexey Botchkov authored
              Optimizator fails using index with ST_Within(g, constant_poly).
      
      per-file comments:
        mysql-test/r/gis-rt-precise.result
              test result fixed.
        mysql-test/r/gis-rtree.result
              test result fixed.
        mysql-test/suite/maria/r/maria-gis-rtree-dynamic.result
              test result fixed.
        mysql-test/suite/maria/r/maria-gis-rtree-trans.result
              test result fixed.
        mysql-test/suite/maria/r/maria-gis-rtree.result
              test result fixed.
        storage/maria/ma_rt_index.c
              Use MBR_INTERSECT mode when optimizing the select WITH ST_Within.
        storage/myisam/rt_index.c
              Use MBR_INTERSECT mode when optimizing the select WITH ST_Within.
      662c51ba
  24. 25 May, 2012 3 commits
  25. 24 May, 2012 1 commit
  26. 23 May, 2012 3 commits
    • Sergey Petrunya's avatar
      a834af8c
    • unknown's avatar
      Fix bug lp:1001506 · d56f5dae
      unknown authored
      This is a backport of the (unchaged) fix for MySQL bug #11764372, 57197.
      
      Analysis:
      
      When the outer query finishes its main execution and computes GROUP BY,
      it needs to construct a new temporary table (and a corresponding JOIN) to
      execute the last DISTINCT operation. At this point JOIN::exec calls
      JOIN::join_free, which calls JOIN::cleanup -> TMP_TABLE_PARAM::cleanup
      for both the outer and the inner JOINs. The call to the inner
      TMP_TABLE_PARAM::cleanup sets copy_field = NULL, but not copy_field_end.
      
      The final execution phase that computes the DISTINCT invokes:
      evaluate_join_record -> end_write -> copy_funcs
      The last function copies the results of all functions into the temp table.
      copy_funcs walks over all functions in join->tmp_table_param.items_to_copy.
      In this case items_to_copy contains both assignments to user variables.
      The process of copying user variables invokes Item_func_set_user_var::check
      which in turn re-evaluates the arguments of the user variable assignment.
      This in turn triggers re-evaluation of the subquery, and ultimately
      copy_field.
      
      However, the previous call to TMP_TABLE_PARAM::cleanup for the subquery
      already set copy_field to NULL but not its copy_field_end. This results
      in a null pointer access, and a crash.
      
      Fix:
      Set copy_field_end and save_copy_field_end to null when deleting
      copy fields in TMP_TABLE_PARAM::cleanup().
      d56f5dae
    • Sergey Petrunya's avatar