An error occurred fetching the project authors.
  1. 09 Apr, 2013 2 commits
    • Igor Babaev's avatar
      Fixed mdev-4380. · 1db675b6
      Igor Babaev authored
      Uninitialized field next_equal_field of the Field objects created
      for the fields of a temporary table could hang the server.
      
      
      1db675b6
    • Igor Babaev's avatar
      Fixed mdev-4378. · ddb84f90
      Igor Babaev authored
      Uninitialized field cond_selectivity of the Field objects created
      for the fields of a temporary table could cause an assertion abort.
      ddb84f90
  2. 05 Apr, 2013 1 commit
  3. 04 Apr, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-4367. · 50d4d1ca
      Igor Babaev authored
      When calculating selectivity of conditions one should take into account
      the cases when some tables to be joined are empty.
      50d4d1ca
  4. 03 Apr, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-4349. · 915a8ae4
      Igor Babaev authored
      Range analysis of the condition for a non-indexed column may
      return an impossible range. This must be taken into account.
      915a8ae4
  5. 02 Apr, 2013 1 commit
  6. 30 Mar, 2013 1 commit
    • Igor Babaev's avatar
      Fixed several bugs for mwl #253. · 90554986
      Igor Babaev authored
      One of them is quite serious: the function table_cond_selectivity used
      the TABLE_REF structure for ref/eq_ref access methods as if they had been
      filled. In  fact these structure are filled after the best execution plan
      has been chosen.
      
      The other bugs happened due to:
      - an erroneous attempt at get statistics on the result of materialization
        of a view
      - incorrect handling of ranges with no left/right limits when calculating
        selectivity of range conditions on non-indexed columns
      - lack of cleanup for some newly introduced fields
       
      90554986
  7. 26 Mar, 2013 1 commit
  8. 23 Mar, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-4318. · 21dad7ec
      Igor Babaev authored
      In some cases, when using views the optimizer incorrectly determined
      possible join orders for queries with nested outer and inner joins.
      This could lead to invalid execution plans for such queries.
      21dad7ec
  9. 20 Mar, 2013 2 commits
  10. 18 Mar, 2013 1 commit
    • unknown's avatar
      MDEV-4269 fix. · 2cd7cf8f
      unknown authored
      Item_default_value inherited form Item_field so should create temporary table field similary.
      2cd7cf8f
  11. 17 Mar, 2013 1 commit
  12. 11 Mar, 2013 1 commit
  13. 08 Mar, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-4250. · 926b0f54
      Igor Babaev authored
      This is a bug in the legacy code. It did not manifest itself because
      it was masked by other bugs that were fixed by the patches for
      mdev-4172 and mdev-4177.
      926b0f54
  14. 02 Mar, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-4220. · bd305d6b
      Igor Babaev authored
      This bug is a regression bug. The regression was introduced by
      the patch for mdev-3851, that tried to weaken the condition when
      a ref access with an extended key can be converted to an eq_ref
      access. The patch incorrectly formed this condition. As a result,
      while improving performance for some queries, the patch caused 
      worse performance for another queries.
      bd305d6b
  15. 28 Feb, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-4209 · 90c0f3d3
      Igor Babaev authored
      Do not include BLOB fields into the key to access the temporary
      table created for a materialized view/derived table.
      BLOB components are not allowed in keys. 
      90c0f3d3
  16. 25 Feb, 2013 2 commits
    • unknown's avatar
      [NOT] EXISTS to IN transformation. · e3ac3061
      unknown authored
      e3ac3061
    • Igor Babaev's avatar
      Fixed bug mdev-4177 · d434d79a
      Igor Babaev authored
      The function remove_eq_cond removes the parts of a disjunction
      for which it has been proved that they are always true. In the
      result of this removal the disjunction may be converted into a 
      formula without OR that must be merged into the the AND formula
      that contains the disjunction.
      The merging of two AND conditions must take into account the
      multiple equalities that may be part of each of them.
      These multiple equality must be merged and become part of the
      and object built as the result of the merge of the AND conditions.
      Erroneously the function remove_eq_cond lacked the code that 
      would merge multiple equalities of the merged AND conditions.
      This could lead to confusing situations when at the same AND 
      level there were two multiple equalities with common members
      and the list of equal items contained only some of these 
      multiple equalities.
      This, in its turn, could lead to an incorrect work of the
      function substitute_for_best_equal_field when it tried to optimize
      ref accesses. This resulted in forming invalid TABLE_REF objects
      that were used to build look-up keys when materialized subqueries
      were exploited.
         
      d434d79a
  17. 22 Feb, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-4172. · ed7671d5
      Igor Babaev authored
      This bug in the legacy code could manifest itself in queries with
      semi-join materialized subqueries.
      When a subquery is materialized all conditions that are imposed
      only on the columns belonging to the tables from the subquery 
      are taken into account.The code responsible for subquery optimizations
      that employes subquery materialization  makes sure to remove these
      conditions from the WHERE conditions of the query obtained after
      it has transformed the original query into a query with a semi-join.
      If the condition to be removed is an equality condition it could
      be added to ON expressions and/or conditions from disjunctive branches
      (parts of OR conditions) in an attempt to generate better access keys
      to the tables of the query. Such equalities are supposed to be removed
      later from all the formulas where they have been added to.
      However, erroneously, this was not done in some cases when an ON
      expression and/or a disjunctive part of the OR condition could
      be converted into one multiple equality. As a result some equality
      predicates over columns belonging to the tables of the materialized
      subquery remained in the ON condition and/or the a disjunctive 
      part of the OR condition, and the excuter later, when trying to
      evaluate them, returned wrong answers as the values of the fields
      from these equalities were not valid.  
      This happened because any standalone multiple equality (a multiple
      equality that are not ANDed with any other predicates) lacked
      the information about equality predicates inherited from upper
      levels (in particular, inherited from the WHERE condition).
      The fix adds a reference to such information to any standalone
      multiple equality. 
      ed7671d5
  18. 21 Feb, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-3913. · c9b63e6a
      Igor Babaev authored
      The wrong result set returned by the left join query  from
      the bug test case happened due to several inconsistencies 
      and bugs of the legacy mysql code.
      
      The bug test case uses an execution plan that employs a scan
      of a materialized IN subquery from the WHERE condition.
      When materializing such an IN- subquery the optimizer injects
      additional equalities  into the WHERE clause. These equalities
      express the constraints imposed by the subquery predicate.
      The injected equality of the query in the  test case happens
      to belong to the same equality class, and a new equality 
      imposing a condition on the rows of the materialized subquery
      is inferred from this class. Simultaneously the multiple
      equality is added to the ON expression of the LEFT JOIN
      used in the main query.
        
      The inferred equality of the form f1=f2 is taken into account
      when optimizing the scan of  the rows the temporary table 
      that is the result of the subquery materialization: only the 
      values of the field f1 are read from the table into the record 
      buffer. Meanwhile the inferred equality is removed from the
      WHERE conditions altogether as a constraint on the fields
      of the temporary table that has been used when filling this table. 
      This equality is supposed to be removed from the ON expression
      when the multiple equalities of the ON expression are converted
      into an optimal set of equality predicates. It supposed to be
      removed from the ON expression as an equality inferred from only
      equalities of the WHERE condition. Yet, it did not happened
      due to the following bug in the code.
      
      Erroneously the code tried to build multiple equality for ON
      expression twice: the first time, when it called optimize_cond()
      for the WHERE condition, the second time, when it called
      this function for the HAVING condition. When executing
      optimize_con() for the WHERE condition  a reference
      to the multiple equality of the WHERE condition is set
      in the multiple equality of the  ON expression. This reference
      would allow later to convert multiple equalities of the
      ON expression into equality predicates. However the 
      the second call of build_equal_items() for the ON expression
      that happened when optimize_cond() was called for the
      HAVING condition reset this reference to NULL.
      
      This bug fix blocks calling build_equal_items() for ON
      expressions for the second time. In general, it will be
      beneficial for many queries as it removes from ON 
      expressions any equalities that are to be checked for the
      WHERE condition.
      The patch also fixes two bugs in the list manipulation
      operations and a bug in the function  
      substitute_for_best_equal_field() that resulted
      in passing wrong reference to the multiple equalities
      of where conditions when processing multiple
      equalities  of ON expressions.
      
      The code of substitute_for_best_equal_field() and
      the code the helper function eliminate_item_equal()
      were also streamlined and cleaned up.
      Now the conversion of the multiple equalities into
      an optimal set of equality predicates first produces
      the sequence of the all equalities processing multiple
      equalities one by one, and, only after this, it inserts
      the equalities at the beginning of the other conditions.
      
      The multiple changes in the output of EXPLAIN
      EXTENDED are mainly the result of this streamlining,
      but in some cases is the result of the removal of
      unneeded equalities from ON expressions. In
      some test cases this removal were reflected in the
      output of EXPLAIN resulted in disappearance of 
      “Using where” in some rows of the execution plans.
      c9b63e6a
  19. 08 Feb, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-3995. · 48aee459
      Igor Babaev authored
      This bug happened because the executor tried to use a wrong
      TABLE REF object when building access keys. It constructed
      keys from fields of a materialized table from a ref object
      created to construct keys from the fields of the underlying
      base table. This could happen only when materialized table
      was created for a non-correlated IN subquery and only
      when the materialized table used for lookups.
      In this case we are guaranteed to be able to construct the
      keys from the fields of tables that would be outer tables
      for the tables of the IN subquery.
      The patch makes sure that no ref objects constructed from
      fields of materialized lookup tables are to be used.
      48aee459
  20. 26 Jan, 2013 1 commit
  21. 23 Jan, 2013 1 commit
    • Michael Widenius's avatar
      MDEV-4011 Added per thread memory counting and usage · a260b155
      Michael Widenius authored
      Base code and idea from a patch from by plinux at Taobao.
      
      The idea is that we mark all memory that are thread specific with MY_THREAD_SPECIFIC.
      Memory counting is done per thread in the my_malloc_size_cb_func callback function from my_malloc().
      There are plenty of new asserts to ensure that for a debug server the counting is correct.
      
      Information_schema.processlist gets two new columns: MEMORY_USED and EXAMINED_ROWS.
      - The later is there mainly to show how query is progressing.
      
      The following changes in interfaces was needed to get this to work:
      - init_alloc_root() amd init_sql_alloc() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
      - One now have to use alloc_root_set_min_malloc() to set min memory to be allocated by alloc_root()
      - my_init_dynamic_array()  has extra option so that one can mark memory with MY_THREAD_SPECIFIC
      - my_net_init() has extra option so that one can mark memory with MY_THREAD_SPECIFIC
      - Added flag for hash_init() so that one can mark hash table to be thread specific.
      - Added flags to init_tree() so that one can mark tree to be thread specific.
      - Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
      - Added flag to Warning_info::Warning_info() if the structure should be fully initialized.
      - String elements can now be marked as thread specific.
      - Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
      - Changed type of myf from int to ulong, as this is always a set of bit flags.
      
      Other things:
      - Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
      - We now also show EXAMINED_ROWS in SHOW PROCESSLIST
      - Added new variable 'memory_used'
      - Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
      - Removed calls to the obsoleted function init_dynamic_array()
      - Use set_current_thd() instead of my_pthread_setspecific_ptr(THR_THD,...)
      
      
      client/completion_hash.cc:
        Updated call to init_alloc_root()
      client/mysql.cc:
        Updated call to init_alloc_root()
      client/mysqlbinlog.cc:
        init_dynamic_array() -> my_init_dynamic_array()
        Updated call to init_alloc_root()
      client/mysqlcheck.c:
        Updated call to my_init_dynamic_array()
      client/mysqldump.c:
        Updated call to init_alloc_root()
      client/mysqltest.cc:
        Updated call to init_alloc_root()
        Updated call to my_init_dynamic_array()
        Fixed compiler warnings
      extra/comp_err.c:
        Updated call to my_init_dynamic_array()
      extra/resolve_stack_dump.c:
        Updated call to my_init_dynamic_array()
      include/hash.h:
        Added HASH_THREAD_SPECIFIC
      include/heap.h:
        Added flag is internal temporary table.
      include/my_dir.h:
        Safety fix: Ensure that MY_DONT_SORT and MY_WANT_STAT don't interfer with other mysys flags
      include/my_global.h:
        Changed type of myf from int to ulong, as this is always a set of bit flags.
      include/my_sys.h:
        Added MY_THREAD_SPECIFIC and MY_THREAD_MOVE
        Added malloc_flags to DYNAMIC_ARRAY
        Added extra mysys flag argument to my_init_dynamic_array()
        Removed deprecated functions init_dynamic_array() and my_init_dynamic_array.._ci
        Updated paramaters for init_alloc_root()
      include/my_tree.h:
        Added my_flags to allow one to use MY_THREAD_SPECIFIC with hash tables.
        Removed with_delete. One should now instead use MY_TREE_WITH_DELETE_FLAG
        Updated parameters to init_tree()
      include/myisamchk.h:
        Added malloc_flags to allow one to use MY_THREAD_SPECIFIC for checks.
      include/mysql.h:
        Added MYSQL_THREAD_SPECIFIC_MALLOC
        Used 'unused1' to mark memory as thread specific.
      include/mysql.h.pp:
        Updated file
      include/mysql_com.h:
        Used 'unused1' to mark memory as thread specific.
        Updated parameters for my_net_init()
      libmysql/libmysql.c:
        Updated call to init_alloc_root() to mark memory thread specific.
      libmysqld/emb_qcache.cc:
        Updated call to init_alloc_root()
      libmysqld/lib_sql.cc:
        Updated call to init_alloc_root()
      mysql-test/r/create.result:
        Updated results
      mysql-test/r/user_var.result:
        Updated results
      mysql-test/suite/funcs_1/datadict/processlist_priv.inc:
        Update to handle new format of SHOW PROCESSLIST
      mysql-test/suite/funcs_1/datadict/processlist_val.inc:
        Update to handle new format of SHOW PROCESSLIST
      mysql-test/suite/funcs_1/r/is_columns_is.result:
        Update to handle new format of SHOW PROCESSLIST
      mysql-test/suite/funcs_1/r/processlist_priv_no_prot.result:
        Updated results
      mysql-test/suite/funcs_1/r/processlist_val_no_prot.result:
        Updated results
      mysql-test/t/show_explain.test:
        Fixed usage of debug variable so that one can run test with --debug
      mysql-test/t/user_var.test:
        Added test of memory_usage variable.
      mysys/array.c:
        Added extra my_flags option to init_dynamic_array() and init_dynamic_array2() so that one can mark memory with MY_THREAD_SPECIFIC
        All allocated memory is marked with the given my_flags.
        Removed obsolete function init_dynamic_array()
      mysys/default.c:
        Updated call to init_alloc_root()
        Updated call to my_init_dynamic_array()
      mysys/hash.c:
        Updated call to my_init_dynamic_array_ci().
        Allocated memory is marked with MY_THREAD_SPECIFIC if HASH_THREAD_SPECIFIC is used.
      mysys/ma_dyncol.c:
        init_dynamic_array() -> my_init_dynamic_array()
        Added #if to get rid of compiler warnings
      mysys/mf_tempdir.c:
        Updated call to my_init_dynamic_array()
      mysys/my_alloc.c:
        Added extra parameter to init_alloc_root() so that one can mark memory with MY_THREAD_SPECIFIC
        Extend MEM_ROOT with a flag if memory is thread specific.
        This is stored in block_size, to keep the size of the MEM_ROOT object identical as before.
        Allocated memory is marked with MY_THREAD_SPECIFIC if used with init_alloc_root()
      mysys/my_chmod.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_chsize.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_copy.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_create.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_delete.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_error.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_fopen.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_fstream.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_getwd.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_lib.c:
        Updated call to init_alloc_root()
        Updated call to my_init_dynamic_array()
        Updated DBUG_PRINT because of change of myf type
      mysys/my_lock.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_malloc.c:
        Store at start of each allocated memory block the size of the block and if the block is thread specific.
        Call malloc_size_cb_func, if set, with the memory allocated/freed.
        Updated DBUG_PRINT because of change of myf type
      mysys/my_open.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_pread.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_read.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_redel.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_rename.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_seek.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_sync.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/my_thr_init.c:
        Ensure that one can call my_thread_dbug_id() even if thread is not properly initialized.
      mysys/my_write.c:
        Updated DBUG_PRINT because of change of myf type
      mysys/mysys_priv.h:
        Updated parameters to sf_malloc and sf_realloc()
      mysys/safemalloc.c:
        Added checking that for memory marked with MY_THREAD_SPECIFIC that it's the same thread that is allocation and freeing the memory.
        Added sf_malloc_dbug_id() to allow MariaDB to specify which THD is handling the memory.
        Added my_flags arguments to sf_malloc() and sf_realloc() to be able to mark memory with MY_THREAD_SPECIFIC.
        Added sf_report_leaked_memory() to get list of memory not freed by a thread.
      mysys/tree.c:
        Added flags to init_tree() so that one can mark tree to be thread specific.
        Removed with_delete option to init_tree(). Now one should instead use MY_TREE_WITH_DELETE_FLAG.
        Updated call to init_alloc_root()
        All allocated memory is marked with the given malloc flags
      mysys/waiting_threads.c:
        Updated call to my_init_dynamic_array()
      sql-common/client.c:
        Updated call to init_alloc_root() and my_net_init() to mark memory thread specific.
        Updated call to my_init_dynamic_array().
        Added MYSQL_THREAD_SPECIFIC_MALLOC so that client can mark memory as MY_THREAD_SPECIFIC.
      sql-common/client_plugin.c:
        Updated call to init_alloc_root()
      sql/debug_sync.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/event_scheduler.cc:
        Removed calls to net_end() as this is now done in ~THD()
        Call set_current_thd() to ensure that memory is assigned to right thread.
      sql/events.cc:
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/filesort.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/filesort_utils.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/ha_ndbcluster.cc:
        Updated call to init_alloc_root()
        Updated call to my_net_init()
        Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
      sql/ha_ndbcluster_binlog.cc:
        Updated call to my_net_init()
        Updated call to init_sql_alloc()
        Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
      sql/ha_partition.cc:
        Updated call to init_alloc_root()
      sql/handler.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
        Added missing call to my_dir_end()
      sql/item_func.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/item_subselect.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/item_sum.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/log.cc:
        More DBUG
        Updated call to init_alloc_root()
      sql/mdl.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/mysqld.cc:
        Added total_memory_used
        Updated call to init_alloc_root()
        Move mysql_cond_broadcast() before my_thread_end()
        Added mariadb_dbug_id() to count memory per THD instead of per thread.
        Added my_malloc_size_cb_func() callback function for my_malloc() to count memory.
        Move initialization of mysqld_server_started and mysqld_server_initialized earlier.
        Updated call to my_init_dynamic_array().
        Updated call to my_net_init().
        Call my_pthread_setspecific_ptr(THR_THD,...) to ensure that memory is assigned to right thread.
        Added status variable 'memory_used'.
        Updated call to init_alloc_root()
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/mysqld.h:
        Added set_current_thd()
      sql/net_serv.cc:
        Added new parameter to my_net_init() so that one can mark memory with MY_THREAD_SPECIFIC.
        Store in net->thread_specific_malloc if memory is thread specific.
        Mark memory to be thread specific if requested.
      sql/opt_range.cc:
        Updated call to my_init_dynamic_array()
        Updated call to init_sql_alloc()
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/opt_subselect.cc:
        Updated call to init_sql_alloc() to mark memory thread specific.
      sql/protocol.cc:
        Fixed compiler warning
      sql/records.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/rpl_filter.cc:
        Updated call to my_init_dynamic_array()
      sql/rpl_handler.cc:
        Updated call to my_init_dynamic_array2()
      sql/rpl_handler.h:
        Updated call to init_sql_alloc()
      sql/rpl_mi.cc:
        Updated call to my_init_dynamic_array()
      sql/rpl_tblmap.cc:
        Updated call to init_alloc_root()
      sql/rpl_utility.cc:
        Updated call to my_init_dynamic_array()
      sql/slave.cc:
        Initialize things properly before calling functions that allocate memory.
        Removed calls to net_end() as this is now done in ~THD()
      sql/sp_head.cc:
        Updated call to init_sql_alloc()
        Updated call to my_init_dynamic_array()
        Added parameter to warning_info() that it should be fully initialized.
      sql/sp_pcontext.cc:
        Updated call to my_init_dynamic_array()
      sql/sql_acl.cc:
        Updated call to init_sql_alloc()
        Updated call to my_init_dynamic_array()
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/sql_admin.cc:
        Added parameter to warning_info() that it should be fully initialized.
      sql/sql_analyse.h:
        Updated call to init_tree() to mark memory thread specific.
      sql/sql_array.h:
        Updated call to my_init_dynamic_array() to mark memory thread specific.
      sql/sql_audit.cc:
        Updated call to my_init_dynamic_array()
      sql/sql_base.cc:
        Updated call to init_sql_alloc()
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/sql_cache.cc:
        Updated comment
      sql/sql_class.cc:
        Added parameter to warning_info() that not initialize it until THD is fully created.
        Updated call to init_sql_alloc()
        Mark THD::user_vars has to be thread specific.
        Updated call to my_init_dynamic_array()
        Ensure that memory allocated by THD is assigned to the THD.
        More DBUG
        Always acll net_end() in ~THD()
        Assert that all memory signed to this THD is really deleted at ~THD.
        Fixed set_status_var_init() to not reset memory_used.
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/sql_class.h:
        Added MY_THREAD_SPECIFIC to allocated memory.
        Added malloc_size to THD to record allocated memory per THD.
      sql/sql_delete.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/sql_error.cc:
        Added 'initialize' parameter to Warning_info() to say if should allocate memory for it's structures.
        This is used by THD::THD() to not allocate memory until THD is ready.
        Added Warning_info::free_memory()
      sql/sql_error.h:
        Updated Warning_info() class.
      sql/sql_handler.cc:
        Updated call to init_alloc_root() to mark memory thread specific.
      sql/sql_insert.cc:
        More DBUG
      sql/sql_join_cache.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/sql_lex.cc:
        Updated call to my_init_dynamic_array()
      sql/sql_lex.h:
        Updated call to my_init_dynamic_array()
      sql/sql_load.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/sql_parse.cc:
        Removed calls to net_end() and thd->cleanup() as these are now done in ~THD()
        Ensure that examined_row_count() is reset before query.
        Fixed bug where kill_threads_for_user() was using the wrong mem_root to allocate memory.
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
        Don't restore thd->status_var.memory_used when restoring thd->status_var
      sql/sql_plugin.cc:
        Updated call to init_alloc_root()
        Updated call to my_init_dynamic_array()
        Don't allocate THD on the stack, as this causes problems with valgrind when doing thd memory counting.
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/sql_prepare.cc:
        Added parameter to warning_info() that it should be fully initialized.
        Updated call to init_sql_alloc() to mark memory thread specific.
      sql/sql_reload.cc:
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/sql_select.cc:
        Updated call to my_init_dynamic_array() and init_sql_alloc() to mark memory thread specific.
        Added MY_THREAD_SPECIFIC to allocated memory.
        More DBUG
      sql/sql_servers.cc:
        Updated call to init_sql_alloc() to mark memory some memory thread specific.
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/sql_show.cc:
        Updated call to my_init_dynamic_array()
        Mark my_dir() memory thread specific.
        Use my_pthread_setspecific_ptr(THR_THD,...) to mark that allocated memory should be allocated to calling thread.
        More DBUG.
        Added malloc_size and examined_row_count to SHOW PROCESSLIST.
        Added MY_THREAD_SPECIFIC to allocated memory.
        Updated call to init_sql_alloc()
        Added parameter to warning_info() that it should be fully initialized.
      sql/sql_statistics.cc:
        Fixed compiler warning
      sql/sql_string.cc:
        String elements can now be marked as thread specific.
      sql/sql_string.h:
        String elements can now be marked as thread specific.
      sql/sql_table.cc:
        Updated call to init_sql_alloc() and my_malloc() to mark memory thread specific
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
        Fixed compiler warning
      sql/sql_test.cc:
        Updated call to my_init_dynamic_array() to mark memory thread specific.
      sql/sql_trigger.cc:
        Updated call to init_sql_alloc()
      sql/sql_udf.cc:
        Updated call to init_sql_alloc()
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/sql_update.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      sql/table.cc:
        Updated call to init_sql_alloc().
        Mark memory used by temporary tables, that are not for slave threads, as MY_THREAD_SPECIFIC
        Updated call to init_sql_alloc()
      sql/thr_malloc.cc:
        Added my_flags argument to init_sql_alloc() to be able to mark memory as MY_THREAD_SPECIFIC.
      sql/thr_malloc.h:
        Updated prototype for init_sql_alloc()
      sql/tztime.cc:
        Updated call to init_sql_alloc()
        Updated call to init_alloc_root() to mark memory thread specific.
        my_pthread_setspecific_ptr(THR_THD,...) -> set_current_thd()
      sql/uniques.cc:
        Updated calls to init_tree(), my_init_dynamic_array() and my_malloc() to mark memory thread specific.
      sql/unireg.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      storage/csv/ha_tina.cc:
        Updated call to init_alloc_root()
      storage/federated/ha_federated.cc:
        Updated call to init_alloc_root()
        Updated call to my_init_dynamic_array()
        Ensure that memory allocated by fedarated is registered for the system, not for the thread.
      storage/federatedx/federatedx_io_mysql.cc:
        Updated call to my_init_dynamic_array()
      storage/federatedx/ha_federatedx.cc:
        Updated call to init_alloc_root()
        Updated call to my_init_dynamic_array()
      storage/heap/ha_heap.cc:
        Added MY_THREAD_SPECIFIC to allocated memory.
      storage/heap/heapdef.h:
        Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
      storage/heap/hp_block.c:
        Added parameter to hp_get_new_block() to be able to do thread specific memory tagging.
      storage/heap/hp_create.c:
        - Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
        - Use MY_TREE_WITH_DELETE instead of removed option 'with_delete'.
      storage/heap/hp_open.c:
        Internal HEAP tables are now marking it's memory as MY_THREAD_SPECIFIC.
      storage/heap/hp_write.c:
        Added new parameter to hp_get_new_block()
      storage/maria/ma_bitmap.c:
        Updated call to my_init_dynamic_array()
      storage/maria/ma_blockrec.c:
        Updated call to my_init_dynamic_array()
      storage/maria/ma_check.c:
        Updated call to init_alloc_root()
      storage/maria/ma_ft_boolean_search.c:
        Updated calls to init_tree() and init_alloc_root()
      storage/maria/ma_ft_nlq_search.c:
        Updated call to init_tree()
      storage/maria/ma_ft_parser.c:
        Updated call to init_tree()
        Updated call to init_alloc_root()
      storage/maria/ma_loghandler.c:
        Updated call to my_init_dynamic_array()
      storage/maria/ma_open.c:
        Updated call to my_init_dynamic_array()
      storage/maria/ma_sort.c:
        Updated call to my_init_dynamic_array()
      storage/maria/ma_write.c:
        Updated calls to my_init_dynamic_array() and init_tree()
      storage/maria/maria_pack.c:
        Updated call to init_tree()
      storage/maria/unittest/sequence_storage.c:
        Updated call to my_init_dynamic_array()
      storage/myisam/ft_boolean_search.c:
        Updated call to init_tree()
        Updated call to init_alloc_root()
      storage/myisam/ft_nlq_search.c:
        Updated call to init_tree()
      storage/myisam/ft_parser.c:
        Updated call to init_tree()
        Updated call to init_alloc_root()
      storage/myisam/ft_stopwords.c:
        Updated call to init_tree()
      storage/myisam/mi_check.c:
        Updated call to init_alloc_root()
      storage/myisam/mi_write.c:
        Updated call to my_init_dynamic_array()
        Updated call to init_tree()
      storage/myisam/myisamlog.c:
        Updated call to init_tree()
      storage/myisam/myisampack.c:
        Updated call to init_tree()
      storage/myisam/sort.c:
        Updated call to my_init_dynamic_array()
      storage/myisammrg/ha_myisammrg.cc:
        Updated call to init_sql_alloc()
      storage/perfschema/pfs_check.cc:
        Rest current_thd
      storage/perfschema/pfs_instr.cc:
        Removed DBUG_ENTER/DBUG_VOID_RETURN as at this point my_thread_var is not allocated anymore, which can cause problems.
      support-files/compiler_warnings.supp:
        Disable compiler warning from offsetof macro.
      a260b155
  22. 16 Jan, 2013 1 commit
    • unknown's avatar
      MDEV-3988 fix. · a716b061
      unknown authored
      Subquery turned into constant too late to be excluded from grouping list so test for constant added to the create_temp_table().
      a716b061
  23. 15 Jan, 2013 2 commits
    • unknown's avatar
      Fix for bug MDEV-3992, second attempt · a87eab60
      unknown authored
      The previous fix for MDEV-3992 was incomplete, because it still computed
      incorrectly the number of keyparts of the extended secondary key in the
      case when columns of the PK participate in the secondary key.
      
      This patch by Monty corrects the above problem.
      a87eab60
    • Olav Sandstaa's avatar
      Fix for Bug#14636211 WRONG RESULT (EXTRA ROW) ON A FROM SUBQUERY · e7ad5e36
      Olav Sandstaa authored
                           WITH A VARIABLE AND ORDER BY
              Bug#16035412 MYSQL SERVER 5.5.29 WRONG SORTING USING COMPLEX INDEX
                  
      This is a fix for a regression introduced by Bug#12667154:
      Bug#12667154 attempted to fix a performance problem with subqueries
      that did filesort. For doing filesort, the optimizer creates a quick
      select object to use when building the sort index. This quick select
      object was deleted after the first call to create_sort_index(). Thus,
      for queries where the subquery was executed multiple times, the quick
      object was only used for the first execution. For all later executions
      of the subquery, filesort used a complete table scan for building the
      sort index. The fix for Bug#12667154 tried to fix this by not deleting
      the quick object after the first execution of create_sort_index() so
      that it would be re-used for building the sort index by the following
      executions of the subquery.
      
      This regression introduced in Bug#12667154 is that due to not deleting
      the quick select object after building the sort index, the quick
      object could in some cases be used also during the second phase of the
      execution of the subquery instead of using the created sort
      index. This caused wrong results to be returned.
      
      The fix for this issue is to delete the reference to the select object
      after it has been used in create_sort_index(). In this way the select 
      and quick objects will not be available when doing the second phase
      of the execution of the select operation. To ensure that the select
      object can be re-used for the following executions of the subquery
      we make a copy of the select pointer. This is used for restoring the
      select object after the select operation is completed.
      
      
      mysql-test/suite/innodb/r/innodb_mysql.result:
        Changed explain output: The explain now contains "Using where" since we
        have restored the select pointer after doing the filesort operation.
      sql/sql_select.cc:
        Change create_sort_index() so that it always sets the pointer to
        the select object to NULL. This is done in order to avoid that the
        select->quick object can be used when execution the main part of
        the select operation.
      sql/sql_select.h:
        New member in JOIN_TAB: saved_select. Used by create_sort_index to
        make a backup copy of the select pointer.
      e7ad5e36
  24. 14 Jan, 2013 1 commit
    • unknown's avatar
      Fix for bug MDEV-3992 · cf79c01c
      unknown authored
      Analysis:
        The crash is a result of incorrect analysis of whether a secondary key
        can be extended with a primary in order to compute ORDER BY. The analysis
        is done in test_if_order_by_key(). This function doesn't take into account
        that the primary key may in fact index the same columns as the secondary
        key. For the test query test_if_order_by_key says that there is an extended
        key with total 2 keyparts.
        At the same time, the condition
          if (pkinfo->key_part[i].field->key_start.is_set(nr))
        in test_if_cheaper_oredring() becomes true for (i == 0), which results in
        an invalid access to rec_per_key[-1].
        
      Solution:
        The best solution would be to reuse KEY::ext_key_parts that is already computed
        by open_binary_frm(), however after detailed analysis the conclusion is that
        the change would be too intrusive for a GA release.
        The solution for 5.5 is to add a guard for the case when the 0-th key part is
        considered, and to assume that all keys will be scanned in this case.
      cf79c01c
  25. 12 Jan, 2013 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-4025. · 12bf6fe8
      Igor Babaev authored
      The bug could lead to a wrong estimate of the number of expected rows
      in the output of the EXPLAIN commands for queries with GROUP BY.
      This could be observed in the test case for LP bug 934348.
      12bf6fe8
  26. 10 Jan, 2013 1 commit
    • Michael Widenius's avatar
      Fixed some race conditons and bugs related to killed queries · 6e9a48b6
      Michael Widenius authored
      KILL now breaks locks inside InnoDB
      Fixed possible deadlock when running INNODB STATUS
      Added ha_kill_query() and kill_query() to send kill signal to all storage engines
      Added reset_killed() to ensure we don't reset killed state while awake() is getting called
      
      
      include/mysql/plugin.h:
        Added thd_mark_as_hard_kill()
      include/mysql/plugin_audit.h.pp:
        Added thd_mark_as_hard_kill()
      include/mysql/plugin_auth.h.pp:
        Added thd_mark_as_hard_kill()
      include/mysql/plugin_ftparser.h.pp:
        Added thd_mark_as_hard_kill()
      sql/handler.cc:
        Added ha_kill_query() to send kill signal to all storage engines
      sql/handler.h:
        Added ha_kill_query() and kill_query() to send kill signal to all storage engines
      sql/log_event.cc:
        Use reset_killed()
      sql/mdl.cc:
        use thd->killed instead of thd_killed() to abort on soft kill
      sql/sp_rcontext.cc:
        Use reset_killed()
      sql/sql_class.cc:
        Fixed possible deadlock in INNODB STATUS by not getting thd->LOCK_thd_data if it's locked.
        Use reset_killed()
        Tell storge engines that KILL has been sent
      sql/sql_class.h:
        Added reset_killed() to ensure we don't reset killed state while awake() is getting called.
        Added mark_as_hard_kill()
      sql/sql_insert.cc:
        Use reset_killed()
      sql/sql_parse.cc:
        Simplify detection of killed queries.
        Use reset_killed()
      sql/sql_select.cc:
        Use reset_killed()
      sql/sql_union.cc:
        Use reset_killed()
      storage/innobase/handler/ha_innodb.cc:
        Added innobase_kill_query()
        Fixed error reporting for interrupted queries.
      storage/xtradb/handler/ha_innodb.cc:
        Added innobase_kill_query()
        Fixed error reporting for interrupted queries.
      6e9a48b6
  27. 07 Jan, 2013 1 commit
  28. 21 Dec, 2012 1 commit
    • Roy Lyseng's avatar
      Bug#15972635: Incorrect results returned in 32 table join with HAVING · 96c373c5
      Roy Lyseng authored
      The problem is a shift operation that is not 64-bit safe.
      The consequence is that used tables information for a join with 32 tables
      or more will be incorrect.
      
      Fixed by adding a type cast in Item_sum::update_used_tables().
      
      Also used the opportunity to fix some other potential bugs by adding an
      explicit type-cast to an integer in a left-shift operation.
      Some of them were quite harmless, but was fixed in order to get the same
      signed-ness as the other operand of the operation it was used in.
      
      sql/item_cmpfunc.cc
        Adjusted signed-ness for some integers in left-shift.
      
      sql/item_subselect.cc
        Added type-cast to nesting_map (which is a 32/64 bit type, so
        potential bug for deeply nested queries).
      
      sql/item_sum.cc
        Added type-cast to nesting_map (32/64-bit type) and table_map
        (64-bit type).
      
      sql/opt_range.cc
        Added type-cast to ulonglong (which is a 64-bit type).
      
      sql/sql_base.cc
        Added type-cast to nesting_map (which is a 32/64-bit type).
      
      sql/sql_select.cc
        Added type-cast to nesting_map (32/64-bit type) and key_part_map
        (64-bit type).
      
      sql/strfunc.cc
        Changed type-cast from longlong to ulonglong, to preserve signed-ness.
      96c373c5
  29. 17 Dec, 2012 1 commit
  30. 14 Dec, 2012 1 commit
    • Igor Babaev's avatar
      Addressed all remaining issues from the review of the patch · a06224bd
      Igor Babaev authored
      that introduced engine independent persistent statistics.
      In particular:
      - added an enumeration type for possible values of the system
        variable use_stat_tables
      - renamed KEY::real_rec_per_key to KEY::actual_rec_per_key
      - optimized the collection of statistical data for any primary
        key defined only on one column.
        
      a06224bd
  31. 20 Dec, 2012 1 commit
    • unknown's avatar
      MDEV-3899 Valgrind warnings (blocks are definitely lost) in filesort on IN... · 1b2692d0
      unknown authored
      MDEV-3899  Valgrind warnings (blocks are definitely lost) in filesort on IN subquery with SUM and DISTINCT
        
      Analysys:
      In the beginning of JOIN::cleanup there is code that is supposed to
      free all filesort buffers. The code assumes that the table being sorted
      is the first non-constant table. To get this table it calls:
      first_top_level_tab(this, WITHOUT_CONST_TABLES)
        
      However, first_top_level_tab() instead returned the wrong table - the first
      one in the plan, instead of the first non-constant table. There is no other
      place outside filesort() where sort buffers may be freed. As a result, the
      sort buffer was not freed, and there was a memory leak.
        
      Solution:
      Change first_top_level_tab(), to test for WITH_CONST_TABLES instead of
      WITHOUT_CONST_TABLES.
      1b2692d0
  32. 26 Nov, 2012 1 commit
    • unknown's avatar
      Fix of MDEV-3874: Server crashes in Item_field::print on a SELECT from a MERGE... · b8b875cb
      unknown authored
      Fix of MDEV-3874: Server crashes in Item_field::print on a SELECT from a MERGE view with materialization+semijoin, subquery, ORDER BY.
      
      The problem was that in debugging binaries it try to print item to assign human readable name to the item.
      But subquery item was already freed (join_free/cleanup with full cleanup) so Item_field refers to temporary
      table which memory had been already freed.
      b8b875cb
  33. 22 Nov, 2012 1 commit
    • Igor Babaev's avatar
      Fixed LP bug #1002146 (bug mdev-645). · db1db8fa
      Igor Babaev authored
      If the setting of system variables does not allow to use join buffer
      for a join query with GROUP BY <f1,...> / ORDER BY <f1,...> then
      filesort is not needed if the first joined table is scanned in
      the order compatible with order specified by the list <f1,...>.
      db1db8fa
  34. 19 Nov, 2012 1 commit
  35. 20 Nov, 2012 1 commit
  36. 11 Nov, 2012 1 commit
    • Igor Babaev's avatar
      Fixed bug mdev-3851. · e08f4f16
      Igor Babaev authored
      Any ref access to a table by a key fully extended by the components
      of the primary key should be actually an eq_ref access.
      e08f4f16