An error occurred fetching the project authors.
  1. 16 Jul, 2010 1 commit
    • unknown's avatar
      MWL#89: Cost-based choice between Materialization and IN->EXISTS transformation · 875bd20a
      unknown authored
      1. Changed the lazy optimization for subqueries that can be
         materialized into bottom-up optimization during the optimization of
         the main query.
      
         The main change is implemented by the method
         Item_in_subselect::setup_engine.
        
         All other changes were required to correct problems resulting from
         changing the order of optimization. Most of these problems followed
         the same pattern - there are some shared structures between a
         subquery and its parent query. Depending on which one is optimized
         first (parent or child query), these shared strucutres may get
         different values, thus resulting in an inconsistent query plan.
      
      2. Changed the code-generation for subquery materialization to be
         performed in runtime memory for each (re)execution, instead of in
         statement memory (once per prepared statement).
         - Item_in_subselect::setup_engine() no longer creates materialization
           related objects in statement memory.
         - Merged subselect_hash_sj_engine::init_permanent and
           subselect_hash_sj_engine::init_runtime into
           subselect_hash_sj_engine::init, which is called for each
           (re)execution.
         - Fixed deletion of the temp table accordingly.
      
      
      mysql-test/r/subselect_mat.result:
        Adjusted changed EXPLAIN because of earlier optimization of subqueries.
      875bd20a
  2. 10 Jul, 2010 1 commit
    • unknown's avatar
      Subquery cache (MWL#66) added. · ceb5468f
      unknown authored
      libmysqld/Makefile.am:
        The new file added.
      mysql-test/r/index_merge_myisam.result:
        subquery_cache optimization option added.
      mysql-test/r/myisam_mrr.result:
        subquery_cache optimization option added.
      mysql-test/r/subquery_cache.result:
        The subquery cache tests added.
      mysql-test/r/subselect3.result:
        Subquery cache switched off to avoid changing read statistics.
      mysql-test/r/subselect3_jcl6.result:
        Subquery cache switched off to avoid changing read statistics.
      mysql-test/r/subselect_no_mat.result:
        subquery_cache optimization option added.
      mysql-test/r/subselect_no_opts.result:
        subquery_cache optimization option added.
      mysql-test/r/subselect_no_semijoin.result:
        subquery_cache optimization option added.
      mysql-test/r/subselect_sj.result:
        subquery_cache optimization option added.
      mysql-test/r/subselect_sj_jcl6.result:
        subquery_cache optimization option added.
      mysql-test/t/subquery_cache.test:
        The subquery cache tests added.
      mysql-test/t/subselect3.test:
        Subquery cache switched off to avoid changing read statistics.
      sql/CMakeLists.txt:
        The new file added.
      sql/Makefile.am:
        The new files added.
      sql/item.cc:
        Expression cache item (Item_cache_wrapper) added.
        Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP.
      sql/item.h:
        Expression cache item (Item_cache_wrapper) added.
        Item_ref and Item_field fixed for correct usage of result field and fast resolwing in SP.
      sql/item_cmpfunc.cc:
        Subquery cache added.
      sql/item_cmpfunc.h:
        Subquery cache added.
      sql/item_subselect.cc:
        Subquery cache added.
      sql/item_subselect.h:
        Subquery cache added.
      sql/item_sum.cc:
        Registration of subquery parameters added.
      sql/mysql_priv.h:
        subquery_cache optimization option added.
      sql/mysqld.cc:
        subquery_cache optimization option added.
      sql/opt_range.cc:
        Fix due to subquery cache.
      sql/opt_subselect.cc:
        Parameters of the function cahnged.
      sql/procedure.h:
        .h file guard added.
      sql/sql_base.cc:
        Registration of subquery parameters added.
      sql/sql_class.cc:
        Option to allow add indeces to temporary table.
      sql/sql_class.h:
        Item iterators added.
        Option to allow add indeces to temporary table.
      sql/sql_expression_cache.cc:
        Expression cache for caching subqueries added.
      sql/sql_expression_cache.h:
        Expression cache for caching subqueries added.
      sql/sql_lex.cc:
        Registration of subquery parameters added.
      sql/sql_lex.h:
        Registration of subqueries and subquery parameters added.
      sql/sql_select.cc:
        Subquery cache added.
      sql/sql_select.h:
        Subquery cache added.
      sql/sql_union.cc:
        A new parameter to the function added.
      sql/sql_update.cc:
        A new parameter to the function added.
      sql/table.cc:
        Procedures to manage temporarty tables index added.
      sql/table.h:
        Procedures to manage temporarty tables index added.
      storage/maria/ha_maria.cc:
        Fix of handler to allow destoy a table in case of error during the table creation.
      storage/maria/ha_maria.h:
        .h file guard added.
      storage/myisam/ha_myisam.cc:
        Fix of handler to allow destoy a table in case of error during the table creation.
      ceb5468f
  3. 06 Jul, 2010 1 commit
    • Sergey Petrunya's avatar
      Fix buildbot valgrind failure · e5f238a0
      Sergey Petrunya authored
      - Item_in_subselect::init_left_expr_cache() should not try to 
        guess whether the left expression is accessed "over the grouping operation"
        (i.e. the subselect is evaluated after the grouping while the left_expr is
         an Item_ref that wraps an expression from before the grouping). Instead, 
        let new_Cached_item not to try accessing item->real_item() when creating 
        left expr cache.
      e5f238a0
  4. 26 Jun, 2010 1 commit
    • Sergey Petrunya's avatar
      Post-merge fixes: · 06399936
      Sergey Petrunya authored
      - fix a bug in LooseScan strategy execution code (exposed by changing costs/QEP)
      - Do set join_tab->sorted=TRUE for JOIN_TABs that use LooseScan (partitioning 
         handler cares about "sorted" parameter of h->index_init() call)
      06399936
  5. 05 Jun, 2010 1 commit
    • Sergei Golubchik's avatar
      few small MySQL bugs/issues that impact the engines, as discussed in the SE summit · ac6b3c44
      Sergei Golubchik authored
      * remove handler::index_read_last()
      * create handler::keyread_read_time() (was get_index_only_read_time() in opt_range.cc)
      * ha_show_status() allows engine's show_status() to fail
      * remove HTON_FLUSH_AFTER_RENAME
      * fix key_cmp_if_same() to work for floats and doubles
      * set table->status in the server, don't force engines to do it
      * increment status vars in the server, don't force engines to do it
      
      mysql-test/r/status_user.result:
        correct test results - innodb was wrongly counting internal
        index searches as handler_read_* calls.
      sql/ha_partition.cc:
        compensate for handler incrementing status counters -
        we want to count only calls to underlying engines
      sql/handler.h:
        inline methods moved to sql_class.h
      sql/key.cc:
        simplify the check
      sql/opt_range.cc:
        move get_index_only_read_time to the handler class
      sql/sp.cc:
        don't use a key that's stored in the record buffer -
        the engine can overwrite the buffer with anything, destroying the key
      sql/sql_class.h:
        inline handler methods that need to see THD and TABLE definitions
      sql/sql_select.cc:
        no ha_index_read_last_map anymore
      sql/sql_table.cc:
        remove HTON_FLUSH_AFTER_RENAME
      sql/table.cc:
        set HA_CAN_MEMCMP as appropriate
      sql/tztime.cc:
        don't use a key that's stored in the record buffer -
        the engine can overwrite the buffer with anything, destroying the key
      storage/myisam/ha_myisam.cc:
        engines don't need to update table->status or use ha_statistic_increment anymore
      storage/myisam/ha_myisam.h:
        index_read_last_map is no more
      ac6b3c44
  6. 26 May, 2010 1 commit
    • Igor Babaev's avatar
      Changed the fixes for the following bugs: · d120c5b5
      Igor Babaev authored
      Bug #39022: completed
      Bug #39653: reverted as invalid
      Bug #45640: ameliorated, simplified, optimized
      Bug #48483: completed
      Bug #49324: improved
      Bug #51242/52336: reverted, applied a real fix.
      d120c5b5
  7. 13 May, 2010 1 commit
    • Michael Widenius's avatar
      Fixes after last merge of MySQL 5.1 · 6659ad49
      Michael Widenius authored
      - INSERT with RAND() doesn't require row based logging again
      - Some bugs fixed in opt_range() where we table->key_read was wrongly used
      
      
      
      .bzrignore:
        Ignore new xtstat binary
      mysql-test/r/index_merge_myisam.result:
        Update results (old result was wrong)
      mysql-test/suite/binlog/r/binlog_stm_binlog.result:
        Added drop table first
      mysql-test/suite/binlog/r/binlog_stm_unsafe_warning.result:
        Added test for when RAND() requires row based logging
      mysql-test/suite/binlog/t/binlog_stm_binlog.test:
        Added drop table first
      mysql-test/suite/binlog/t/binlog_stm_unsafe_warning.test:
        Added test for when RAND() requires row based logging
      scripts/make_binary_distribution.sh:
        Removed type from last commit
      sql/item_create.cc:
        Don't require row based logging when using RAND() with INSERT
      sql/opt_range.cc:
        Revert wrong patch from Oracle:
        - As QUICK_RANGE_SELECT uses it's own 'file' handler to the tables, one can't use 'table->key_read' as a flag to detect if index only read (keyread) is used or not
        - Don't set keyread if keyread is already enabled
        - Don't disable key read, if we didn't enable it ourselves
        - Simplify code (and ensure that we do proper cleanup of index only read)
      sql/opt_range.h:
        Added flags to detect if the range optimizer enabled index only read (key read) or not
      sql/opt_sum.cc:
        Use our more optimized macros
      sql/sql_lex.h:
        Added 'readable' function to check if we are in a sub query function or not (not normal query or sub query in FROM clause)
      sql/sql_select.cc:
        Use our more optimized keyread macros
        Added ASSERTS early
        Simplify code on eliminate_item_equal()
        Fixed that substitute_for_best_equal_field() doesn't core dump in case of out of memory conditions.
        Removed not needed test for 'field->maybe_null()'
        Replaced master_unit()->item with is_subquery_function() (More readable)
      sql/sql_update.cc:
        Use our more optimized keyread macros
      sql/table.cc:
        Use our more optimized keyread macros
      sql/table.h:
        Use separate functions to enable/disable Index only reads
        - Safer, more readable, better logging and faster.
      6659ad49
  8. 10 May, 2010 2 commits
  9. 03 May, 2010 1 commit
    • unknown's avatar
      Fixed bug #53334. · 50ddf3c1
      unknown authored
      The fix actually reverts the change introduced by the patch
      for bug 51494
      The fact is that the patch for bug 52177 fixes bug 51194 as well.
      50ddf3c1
  10. 30 Apr, 2010 1 commit
    • Alexey Kopytov's avatar
      Bug #48419: another explain crash.. · 97374a11
      Alexey Kopytov authored
      WHERE predicates containing references to empty tables in a
      subquery were handled incorrectly by the optimizer when
      executing EXPLAIN. As a result, the optimizer could try to
      evaluate such predicates rather than just stop with
      "Impossible WHERE noticed after reading const tables" as 
      it would do in a non-subquery case. This led to valgrind 
      errors and crashes.
      
      Fixed the code checking the above condition so that subqueries
      are not excluded and hence are handled in the same way as top
      level SELECTs.
      
      mysql-test/r/explain.result:
        Added a test case for bug #48419.
      mysql-test/r/ps.result:
        Updated test results to take the new (and more correct)
        "Extra" comments in execution plans.
      mysql-test/t/explain.test:
        Added a test case for bug #48419.
      sql/sql_select.cc:
        There is no point in excluding subqueries from checking
        for identically false WHERE conditions.
      97374a11
  11. 26 Apr, 2010 1 commit
    • Alexey Kopytov's avatar
      Backport of the fix for bug #50335 to 5.0. · 6d43510a
      Alexey Kopytov authored
      The problem was in an incorrect debug assertion. The expression
      used in the failing assertion states that when finding
      references matching ORDER BY expressions, there can be only one
      reference to a single table. But that does not make any sense,
      all test cases for this bug are valid examples with multiple
      identical WHERE expressions referencing the same table which
      are also present in the ORDER BY list.
      
      Fixed by removing the failing assertion. We also have to take
      care of the 'found' counter so that we count multiple
      references only once. We rely on this fact later in
      eq_ref_table().
      
      mysql-test/r/join.result:
        Added a test case for bug #50335.
      mysql-test/t/join.test:
        Added a test case for bug #50335.
      sql/sql_select.cc:
        Removing the assertion in eq_ref_table() as it does not make
        any sense. We also have to take care of the 'found' counter so
        that we count multiple references only once. We rely on this
        fact later in eq_ref_table().
      6d43510a
  12. 08 Apr, 2010 1 commit
  13. 05 Apr, 2010 1 commit
    • Sergey Glukhov's avatar
      Bug#52336 Segfault / crash in 5.1 copy_fields (param=0x9872980) at sql_select.cc:15355 · c1ad5072
      Sergey Glukhov authored
      The problem is that we can not use make_cond_for_table().
      This function relies on used_tables() condition
      which is not set properly for subqueries.
      As result subquery is not filtered out.
      The fix is to use remove_eq_conds() function instead
      of make_cond_for_table() func. 'remove_eq_conds()'
      algorithm relies on const_item() value and it allows
      to handle subqueries in right way.
      
      
      mysql-test/r/having.result:
        test case
      mysql-test/t/having.test:
        test case
      sql/sql_select.cc:
        The fix is to use remove_eq_conds() function instead
        of make_cond_for_table() function.
      c1ad5072
  14. 29 Mar, 2010 2 commits
  15. 26 Mar, 2010 1 commit
    • Sergey Glukhov's avatar
      Bug#52177 crash with explain, row comparison, join, text field · f57839cd
      Sergey Glukhov authored
      The crash is the result of an attempt made by JOIN::optimize to evaluate
      the WHERE condition when no records have been actually read.
      The fix is to remove erroneous 'outer_join' variable check.
      
      
      mysql-test/r/join.result:
        test result
      mysql-test/t/join.test:
        test case
      sql/sql_select.cc:
        removed erroneous 'outer_join' variable check.
      f57839cd
  16. 24 Mar, 2010 6 commits
    • MySQL Build Team's avatar
      Backport into build-201003230706-5.1.43sp1 · f6f93eef
      MySQL Build Team authored
      > ------------------------------------------------------------
      > revno: 3333.1.31
      > revision-id: joro@sun.com-20091223104518-o29t0i3thgs7wgm1
      > parent: sergey.glukhov@sun.com-20100205093946-bx1hsljxlm12h7uf
      > committer: Georgi Kodinov <joro@sun.com>
      > branch nick: B39022-5.1-bugteam
      > timestamp: Wed 2009-12-23 12:45:18 +0200
      > message:
      >   Bug #39022: Mysql randomly crashing in lock_sec_rec_cons_read_sees
      >   
      >   flush_cached_records() was not correctly checking for errors after calling
      >   Item::val_xxx() methods. The expressions may contain subqueries
      >   or stored procedures that cause errors that should stop the statement.
      >   Fixed by correctly checking for errors and propagating them up the call stack.
      
      > ------------------------------------------------------------
      > revno: 3358
      > revision-id: sergey.glukhov@sun.com-20100226113925-mxwn1hfxe3l8khc4
      > parent: gshchepa@mysql.com-20100225191311-1x71dkk0h5e1alvx
      > committer: Sergey Glukhov <Sergey.Glukhov@sun.com>
      > branch nick: mysql-5.1-bugteam
      > timestamp: Fri 2010-02-26 15:39:25 +0400
      > message:
      >   Bug#50995 Having clause on subquery result produces incorrect results.
      >   The problem is that cond->fix_fields(thd, 0) breaks
      >   condition(cuts off 'having'). The reason of that is
      >   that NULL valued Item pointer is present in the
      >   middle of Item list and it breaks the Item processing
      >   loop.
      f6f93eef
    • MySQL Build Team's avatar
      Backporting of 5.1.43sp1 release, files mysql-test/r/bug39022.result,... · 5aa2394a
      MySQL Build Team authored
      Backporting of 5.1.43sp1 release, files mysql-test/r/bug39022.result, mysql-test/t/bug39022.test added
      
      5aa2394a
    • MySQL Build Team's avatar
      Backport into build-201003230706-5.1.43sp1 · b68a8cb2
      MySQL Build Team authored
      > ------------------------------------------------------------
      > revno: 3333.1.11 [merge]
      > revision-id: joro@sun.com-20100201115030-hgvq6489bt0w3rty
      > parent: li-bing.song@sun.com-20100130124925-o6sfex42b6noyc6x
      > parent: joro@sun.com-20100201114016-jylx4hivgqbs0vg2
      > committer: Georgi Kodinov <joro@sun.com>
      > branch nick: test-5.1-bugteam
      > timestamp: Mon 2010-02-01 13:50:30 +0200
      > message:
      >   merge
      > ------------------------------------------------------------
      > Use --include-merges or -n0 to see merged revisions.
      b68a8cb2
    • MySQL Build Team's avatar
      Backport into build-201003230706-5.1.43sp1 · e21c3537
      MySQL Build Team authored
      > ------------------------------------------------------------
      > revno: 3333.1.7 [merge]
      > revision-id: ramil@mysql.com-20100129110849-1nm85j95594epnme
      > parent: joro@sun.com-20100129093628-sze9cv0neu0xbabm
      > parent: ramil@mysql.com-20100129091757-81r640na2t5bzbiz
      > committer: Ramil Kalimullin <ramil@mysql.com>
      > branch nick: mysql-5.1-bugteam
      > timestamp: Fri 2010-01-29 15:08:49 +0400
      > message:
      >   Auto-merge.
      > ------------------------------------------------------------
      > Use --include-merges or -n0 to see merged revisions.
      e21c3537
    • MySQL Build Team's avatar
      Backport into build-201003230706-5.1.43sp1 · 6c026b7e
      MySQL Build Team authored
      > ------------------------------------------------------------
      > revno: 3324
      > revision-id: joro@sun.com-20091223151122-ada73up1yydh0emt
      > parent: joro@sun.com-20100119124841-38vva51cuq3if7dc
      > committer: Georgi Kodinov <joro@sun.com>
      > branch nick: B49512-5.1-bugteam
      > timestamp: Wed 2009-12-23 17:11:22 +0200
      > message:
      >   Bug #49512 : subquery with aggregate function crash
      >     subselect_single_select_engine::exec()
      >   
      >   When a subquery doesn't need to be evaluated because
      >   it returns only aggregate functions and these aggregates
      >   can be calculated from the metadata about the table it
      >   was not updating all the relevant members of the JOIN 
      >   structure to reflect that this is a constant query.
      >   This caused problems to the enclosing subquery 
      >   ('<> SOME' in the test case above) trying to read some
      >   data about the tables.
      >   
      >   Fixed by setting const_tables to the number of tables 
      >   when the SELECT is optimized away.
      6c026b7e
    • Sergey Glukhov's avatar
      Bug#48483 crash in get_best_combination() · bccf219b
      Sergey Glukhov authored
      The crash happens because greedy_serach
      can not determine best plan due to
      wrong inner table dependences. These
      dependences affects join table sorting
      which performs before greedy_search starting.
      In our case table which has real 'no dependences'
      should be put on top of the list but it does not
      happen as inner tables have no dependences as well.
      The fix is to exclude RAND_TABLE_BIT mask from
      condition which checks if table dependences
      should be updated.
      
      
      mysql-test/r/join.result:
        test result
      mysql-test/t/join.test:
        test case
      sql/sql_select.cc:
        RAND_TABLE_BIT mask should not be counted as it
        prevents update of inner table dependences.
        For example it might happen if RAND() function
        is used in JOIN ON clause.
      bccf219b
  17. 20 Mar, 2010 1 commit
  18. 19 Mar, 2010 2 commits
    • Sergey Glukhov's avatar
      Bug#51242 HAVING clause on table join produce incorrect results · ad6e00e3
      Sergey Glukhov authored
      The problem is that when we make conditon for
      grouped result const part of condition is cut off.
      It happens because some parts of 'having' condition
      which refer to outer join become const after
      make_join_statistics. These parts may be lost
      during further having condition transformation
      in JOIN::exec. The fix is adding 'having'
      condition check for const tables after
      make_join_statistics is performed.
      
      
      mysql-test/r/having.result:
        test case
      mysql-test/t/having.test:
        test result
      sql/sql_select.cc:
        added 'having' condition check for const tables
        after make_join_statistics is performed.
      ad6e00e3
    • Sergey Glukhov's avatar
      Bug#51494 crash with join, explain and 'sounds like' operator · caa1ccb0
      Sergey Glukhov authored
      The crash happens because of discrepancy between values of
      conts_tables and join->const_table_map(make_join_statisctics).
      Calculation of conts_tables used condition with
      HA_STATS_RECORDS_IS_EXACT flag check. Calculation of
      join->const_table_map does not use this flag check.
      In case of MERGE table without union with index
      the table does not become const table and
      thus join_read_const_table() is not called
      for the table. join->const_table_map supposes
      this table is const and later in make_join_select
      this table is used for making&calculation const
      condition. As table record buffer is not populated
      it leads to crash.
      The fix is adding a check if an engine supports
      HA_STATS_RECORDS_IS_EXACT flag before updating
      join->const_table_map.
      
      
      mysql-test/r/merge.result:
        test result
      mysql-test/t/merge.test:
        test case
      sql/sql_select.cc:
        adding a check if an engine supports
        HA_STATS_RECORDS_IS_EXACT flag before updating
        join->const_table_map.
      caa1ccb0
  19. 14 Mar, 2010 2 commits
    • Sergey Petrunya's avatar
      BUG#43768: Prepared query with nested subqueries core dumps on second execution · 77e66c69
      Sergey Petrunya authored
      Fix two problems:
      1. Let optimize_semijoin_nests() reset sj_nest->sjmat_info irrespectively  
         of value of optimizer_flag. We need this in case somebody has turned optimization
         off between reexecutions of the same statement.
      
      2. Do not pull out constant tables out of semi-join nests. The problem is that pullout 
         operation is not undoable, and if a table is constant because it is 1/0-row table it 
         may cease to be constant on the next execution. Note that tables that are constant
         because of possible eq_ref(const) access will still be pulled out as they are
         considered functionally-dependent.
      77e66c69
    • Staale Smedseng's avatar
      Bug #49829 Many "hides virtual function" warnings with · c7fad393
      Staale Smedseng authored
      SunStudio
            
      SunStudio compilers of late warn about methods that might hide
      methods in base classes due to the use of overloading combined
      with overriding. SunStudio also warns about variables defined
      in local socpe or method arguments that have the same name as
      a member attribute of the class.
            
      This patch renames methods that might hide base class methods,
      to make it easier both for humans and compilers to see what is
      actually called. It also renames variables in local scope.
      
      
      sql/field.cc:
        Local scope variable or method argument same as class 
        attribute.
      sql/item_cmpfunc.cc:
        Local scope variable or method argument same as class 
        attribute.
      sql/item_create.cc:
        Renaming base class create() to create_func().
      sql/item_create.h:
        Renaming base class create() to create_func().
      sql/protocol.cc:
        Local scope variable or method argument same as class 
        attribute.
      sql/sql_profile.cc:
        Local scope variable or method argument same as class 
        attribute.
      sql/sql_select.cc:
        Local scope variable or method argument same as class 
        attribute.
      sql/sql_yacc.yy:
        Renaming base class create() to create_func().
      storage/federated/ha_federated.cc:
        Local scope variable or method argument same as class 
        attribute.
      storage/myisammrg/ha_myisammrg.cc:
        Local scope variable or method argument same as class 
        attribute.
      c7fad393
  20. 13 Mar, 2010 1 commit
  21. 09 Mar, 2010 2 commits
    • Michael Widenius's avatar
      Added count of my_sync calls (to SHOW STATUS) · 292f6568
      Michael Widenius authored
      tmp_table_size can now be set to 0 (to disable in memory internal temp tables)
      Improved speed for internal Maria temp tables:
      - Don't use packed keys, except with long text fields.
      - Don't copy key all accessed pages during key search.
      Some new benchmark tests to sql-bench (for group by)
      
      BUILD/compile-pentium64-gcov:
        Update script to use same pentium_config flags as other tests
      BUILD/compile-pentium64-gprof:
        Update script to use same pentium_config flags as other tests
      include/my_sys.h:
        Added count of my_sync calls
      mysql-test/r/variables.result:
        tmp_table_size can now be set to 0
      sql-bench/test-select.sh:
        Added some new test for GROUP BY on a not key field and group by with different order by
      sql/mysqld.cc:
        Added count of my_sync calls
        tmp_table_size can now be set to 0 (to disable in memory internal temp tables)
      sql/sql_select.cc:
        If tmp_table_size is 0, don't use in memory temp tables (good for benchmarking MyISAM/Maria temp tables)
        Don't pack keys for Maria tables;  The 8K page size makes packed keys too slow for temp tables.
      storage/maria/ma_key_recover.h:
        Moved definition to maria_def.h
      storage/maria/ma_page.c:
        Moved code used to simplify comparing of identical Maria tables to own function (page_cleanup())
        Fixed that one can read a page with a read lock.
      storage/maria/ma_rkey.c:
        For not exact key reads, cache the page where we found key (to speed up future read-next/read-prev calls)
      storage/maria/ma_search.c:
        Moved code to cache last key page to separate function.
        Instead of copying pages, only get a link to the page. This notable speeds up key searches on bigger tables.
      storage/maria/ma_write.c:
        Added comment
      storage/maria/maria_def.h:
        Moved page_cleanup() to separate function.
      292f6568
    • Davi Arnaut's avatar
      Bug#40277: SHOW CREATE VIEW returns invalid SQL · f502deac
      Davi Arnaut authored
      The problem is that not all column names retrieved from a SELECT
      statement can be used as view column names due to length and format
      restrictions. The server failed to properly check the conformity
      of those automatically generated column names before storing the
      final view definition on disk.
      
      Since columns retrieved from a SELECT statement can be anything
      ranging from functions to constants values of any format and length,
      the solution is to rewrite to a pre-defined format any names that
      are not acceptable as a view column name.
      
      The name is rewritten to "Name_exp_%u" where %u translates to the
      position of the column. To avoid this conversion scheme, define
      explict names for the view columns via the column_list clause.
      Also, aliases are now only generated for top level statements.
      
      mysql-test/include/view_alias.inc:
        Add test case for Bug#40277
      mysql-test/r/compare.result:
        Bug#40277: SHOW CREATE VIEW returns invalid SQL
      mysql-test/r/group_by.result:
        Bug#40277: SHOW CREATE VIEW returns invalid SQL
      mysql-test/r/ps.result:
        Bug#40277: SHOW CREATE VIEW returns invalid SQL
      mysql-test/r/subselect.result:
        Bug#40277: SHOW CREATE VIEW returns invalid SQL
      mysql-test/r/subselect3.result:
        Bug#40277: SHOW CREATE VIEW returns invalid SQL
      mysql-test/r/type_datetime.result:
        Bug#40277: SHOW CREATE VIEW returns invalid SQL
      mysql-test/r/union.result:
        Bug#40277: SHOW CREATE VIEW returns invalid SQL
      mysql-test/r/view.result:
        Add test case result for Bug#40277
      mysql-test/r/view_alias.result:
        Add test case result for Bug#40277
      mysql-test/t/view_alias.test:
        Add test case for Bug#40277
      sql/sql_view.cc:
        Check if auto generated column names are conforming. Also, the
        make_unique_view_field_name function is not used as it uses the
        original name to construct a new one, which does not work if the
        name is invalid.
      f502deac
  22. 08 Mar, 2010 1 commit
  23. 07 Mar, 2010 1 commit
    • Sergey Petrunya's avatar
      BUG#49129: Wrong result with IN-subquery with join_cache_level=6 and firstmatch=off · c2924e15
      Sergey Petrunya authored
      - The problem was that DuplicateWeedout strategy setup code wasn't aware of the 
        fact that join buffering will be used and applied optimization that doesn't work
        together with join buffering. Fixed by making DuplicateWeedout setup code to have 
        a pessimistic check about whether there is a chance that join buffering will be 
        used.
      - Make JOIN_CACHE_BKA::init() correctly process Copy_field elements that denote saving
        current rowids in the join buffer.
      
      mysql-test/r/subselect_sj2.result:
        Update test results
      mysql-test/r/subselect_sj2_jcl6.result:
        Update test results
      mysql-test/r/subselect_sj_jcl6.result:
        Testcase
      mysql-test/t/subselect_sj2.test:
        Update test results
      mysql-test/t/subselect_sj_jcl6.test:
        Testcase
      sql/opt_subselect.cc:
        - The problem was that DuplicateWeedout strategy setup code wasn't aware of the 
          fact that join buffering will be used and applied optimization that doesn't work
          together with join buffering. Fixed by making DuplicateWeedout setup code to have 
          a pessimistic check about whether there is a chance that join buffering will be 
          used.
      sql/sql_join_cache.cc:
        Make JOIN_CACHE_BKA::init() correctly process Copy_field elements that denote saving current rowids in the join buffer.
      sql/sql_select.cc:
        Added a question note
      c2924e15
  24. 06 Mar, 2010 1 commit
    • Sergey Petrunya's avatar
      LPBUG#524025 Running RQG outer_join test leads to crash · 81424b5b
      Sergey Petrunya authored
      Save no-records constant tables in JOIN::const_table_map before we invoke
      eliminate_tables(). Failure to do so caused crash when the same table was
      marked as constant two times
      
      mysql-test/r/table_elim.result:
        LPBUG#524025 Running RQG outer_join test leads to crash
        - Testcase
      mysql-test/t/table_elim.test:
        LPBUG#524025 Running RQG outer_join test leads to crash
        - Testcase
      sql/sql_select.cc:
        LPBUG#524025 Running RQG outer_join test leads to crash
        Save no-records constant tables in JOIN::const_table_map before we invoke eliminate_tables(). Failure to do so caused crash when the same table was marked as constant two times.
      81424b5b
  25. 05 Mar, 2010 2 commits
    • Igor Babaev's avatar
      Corrected Evgen's fix for bug #45191. · 3ccc1d6b
      Igor Babaev authored
      Made sure that join buffers could be used for inner tables of
      any semi-join when the first match strategy is employed.
      3ccc1d6b
    • Gleb Shchepa's avatar
      Bug #39653: find_shortest_key in sql_select.cc does not · 63a88e13
      Gleb Shchepa authored
                  consider clustered primary keys
      
      Choosing a shortest index for the covering index scan,
      the optimizer ignored the fact, that the clustered primary
      key read involves whole table data.
      
      The find_shortest_key function has been modified to
      take into account that fact that a clustered PK has a
      longest key of possible covering indices.
      
      
      mysql-test/r/innodb_mysql.result:
        Test case for bug #39653.
      mysql-test/t/innodb_mysql.test:
        Test case for bug #39653.
      sql/sql_select.cc:
        Bug #39653: find_shortest_key in sql_select.cc does not
                    consider clustered primary keys
        
        The find_shortest_key function has been modified to
        take into account that fact that a clustered PK has a
        longest key of possible covering indices.
      63a88e13
  26. 26 Feb, 2010 2 commits
    • Sergey Glukhov's avatar
      Bug#50995 Having clause on subquery result produces incorrect results. · 9245ed4a
      Sergey Glukhov authored
      The problem is that cond->fix_fields(thd, 0) breaks
      condition(cuts off 'having'). The reason of that is
      that NULL valued Item pointer is present in the
      middle of Item list and it breaks the Item processing
      loop.
      
      
      mysql-test/r/having.result:
        test case
      mysql-test/t/having.test:
        test case
      sql/item_cmpfunc.h:
        added ASSERT to make sure that we do not add NULL valued Item pointer
      sql/sql_select.cc:
        skip adding an item to condition if Item pointer is NULL.
        skip adding a list to condition if this list is empty.
      9245ed4a
    • Evgeny Potemkin's avatar
      Bug#50843: Filesort used instead of clustered index led to · 2d4db52e
      Evgeny Potemkin authored
      performance degradation.
      
      Filesort + join cache combination is preferred to full index scan because it
      is usually faster. But it's not the case when the index is clustered one.
      
      Now test_if_skip_sort_order function prefers filesort only if index isn't
      clustered.
      
      mysql-test/r/innodb_mysql.result:
        Added a test case for the bug#50843.
      mysql-test/t/innodb_mysql.test:
        Added a test case for the bug#50843.
      sql/sql_select.cc:
        Bug#50843: Filesort used instead of clustered index led to
        performance degradation.
        Now test_if_skip_sort_order function prefers filesort only if index isn't
        clustered.
      2d4db52e
  27. 25 Feb, 2010 1 commit
    • Alexey Kopytov's avatar
      Bug #50335: Assertion `!(order->used & map)' in eq_ref_table · 9201bff1
      Alexey Kopytov authored
       
      The problem was in an incorrect debug assertion. The expression 
      used in the failing assertion states that when finding 
      references matching ORDER BY expressions, there can be only one 
      reference to a single table. But that does not make any sense, 
      all test cases for this bug are valid examples with multiple 
      identical WHERE expressions referencing the same table which
      are also present in the ORDER BY list. 
       
      Fixed by removing the failing assertion. We also have to take 
      care of the 'found' counter so that we count multiple 
      references only once. We rely on this fact later in 
      eq_ref_table(). 
      
      mysql-test/r/join.result:
        Added a test case for bug #50335.
      mysql-test/t/join.test:
        Added a test case for bug #50335.
      sql/sql_select.cc:
        Removing the assertion in eq_ref_table() as it does not make
        any sense. We also have to take care of the 'found' counter so 
        that we count multiple references only once. We rely on this 
        fact later in eq_ref_table().
      9201bff1
  28. 19 Feb, 2010 1 commit
    • unknown's avatar
      MWL#68 Subquery optimization: Efficient NOT IN execution with NULLs · 5515bcba
      unknown authored
      This patch implements correct NULL semantics for materialized subquery execution.
      The implementation has the following properties and main limitations:
      - It passes all query result tests, but fails a number of EXPLAIN tests because of
        changed plans.
      - The EXPLAIN output for partial matching is not decided yet.
      - It works only when all necessary indexes fit into main memory. Notice that these
        are not the general B-tree/Hash indexes, but instead much more compact ones,
        therefore this limitation may not be a problem in many practical cases.
      - It doesn't contain specialized tests.
      - In several places the implementation uses methods that are modified copies of
        other similar methods. These cases need to be refactored to avoid code duplication.
      - Add a test if the predicate is top-level just before deciding on partial matching.
        If it is top-level, use a more efficient exec method (index lookup).
      - Add sorting of indexes according to their selectivity. The code is almost there.
      - Needs more comments, and to sync existing ones with the implementation.
      
      sql/item_cmpfunc.h:
        Expose the Arg_comparator of a comparison predicate. This makes it possible to
        directly get the comparison result {-1,0,1}, which is not possible through the
        val_XXX() methods which "fold" such results into a boolean.
      sql/item_subselect.cc:
        The core of the implementation of MWL#68.
      sql/item_subselect.h:
        The core of the implementation of MWL#68.
      sql/opt_subselect.cc:
        Removed the limitation for materialized subquery execution that it is applicable only
        for top-level predicates.
      sql/sql_class.cc:
        New class select_materialize_with_stats that collects data statistics about
        the data being inserted into the target table.
      sql/sql_class.h:
        New class select_materialize_with_stats that collects data statistics about
        the data being inserted into the target table.
      sql/sql_select.cc:
        - more complete initialization of the TABLE object of a temp table.
        - call setup_subquery_materialization at one more exit point.
      5515bcba