1. 27 Apr, 2011 1 commit
    • Igor Babaev's avatar
      Fixed LP bugs #717577, #724942. · 8d9dd21d
      Igor Babaev authored
      Both these two bugs happened due to the following problem.
      When a view column is referenced in the query an Item_direct_view_ref
      object is created that is refers to the Item_field for the column.
      All references to the same view column refer to the same Item_field.
      Different references can belong to different AND/OR levels and,
      as a result, can be included in different Item_equal object.
      These Item_equal objects may include different constant objects.
      If these constant objects are substituted for the Item_field created
      for a view column we have a conflict situation when the second
      substitution annuls the first substitution. This leads to
      wrong result sets returned by the query. Bug #724942 demonstrates
      such an erroneous behaviour.
      Test case of the bug #717577 produces wrong result sets because best
      equal fields of the multiple equalities built for different OR levels
      of the WHERE condition differs. The subsitution for the best equal field
      in the second OR branch overwrites the the substitution made for the
      first branch.
      
      To avoid such conflicts we have to substitute for the references
      to the view columns rather than for the underlying field items.
      To make such substitutions possible we have to include into
      multiple equalities references to view columns rather than 
      field items created for such columns.
      
      This patch modifies the Item_equal class to include references
      to view columns into multiple equality objects. It also performs
      a clean up of the class methods and adds more comments. The methods
      of the Item_direct_view_ref class that assist substitutions for
      references to view columns has been also added by this patch.
      8d9dd21d
  2. 12 Feb, 2011 4 commits
  3. 11 Feb, 2011 1 commit
  4. 10 Feb, 2011 1 commit
  5. 09 Feb, 2011 2 commits
  6. 07 Feb, 2011 1 commit
  7. 06 Feb, 2011 1 commit
    • Igor Babaev's avatar
      Fixed LP bug #702403 that caused a crash on the tree for mwl#128 · cbeab250
      Igor Babaev authored
      with the test case added by this patch.
      The bug cannot be reproduced with the same test case for the main
      5.3 tree because the backported fix for bug 59696 masks the 
      problem that causes the crash in the mentioned test case. It's not
      clear weather this fix masks this problem in all possible cases. 
      
      Anyway the patch for bug 698882 introduced some inconsistent data
      structures that could contain indirect references to deleted object.
      It happened when two Item_equal objects were merged and the Item_field
      list of the second object was joined to such list of the first object.
      This operation required adjustment of the backward pointers in 
      Item fields from the joined list. However the adjustment was missing 
      and this caused crashes in the tree for mwl#128.
      
      Now the backward pointers are set only when Item_equal items are
      completely built and are not changed anymore.
       
      cbeab250
  8. 05 Feb, 2011 1 commit
    • Igor Babaev's avatar
      Introduced optimizer switch flag 'optimize_join_buffer_size'. · 4b24105d
      Igor Babaev authored
      When this flag is 'off' the size of the used join buffer 
      is taken directly from the system variable 'join_buffer_size'.
      When this flag is 'on' then the size of the buffer depends
      on the estimated number of rows in the partial join whose
      records are to be stored in the buffer.
      By default this flag is set 'on'.
      4b24105d
  9. 01 Feb, 2011 2 commits
    • Vladislav Vaintroub's avatar
      Fix compile errors: · 7e206872
      Vladislav Vaintroub authored
      * declaration in the middle of the block in C file.
      * round() is only available in C99.
      7e206872
    • Igor Babaev's avatar
      Back-ported the patch for bug #59696 from mysql-5.6 code line. · 8041013f
      Igor Babaev authored
      The patch fixed the following optimizer defect: when performing
      substitution for best equal fields into where conditions to be
      able to do their evaluations as soon as possible the optimizer 
      skipped conditions over views. That could lead to suboptimal 
      execution of queries that used views.  
      Slightly changed the test case to demonstrate the performance
      improvements if this fix.
      8041013f
  10. 29 Jan, 2011 1 commit
  11. 28 Jan, 2011 1 commit
    • Igor Babaev's avatar
      Fixed LP bug #707827. · d4929035
      Igor Babaev authored
      This bug could manifest itself when hash join over a varchar column
      with NULL values in some rows was used. It happened because the
      function key_buf_cmp erroneously returned FALSE when one of the joined
      key fields was null while the second was not.
      Also fixed two other bugs in the functions key_hashnr and key_buf_cmp 
      that could possibly lead to wrong results for some queries that
      used hash join over several columns with nulls.
      Also reverted the latest addition of the test case for bug #45092. It
      had been already backported earlier.
      d4929035
  12. 27 Jan, 2011 1 commit
    • Igor Babaev's avatar
      Fixed LP bug #707848. · 3e868cd3
      Igor Babaev authored
      This was another bug in the patch for bug 698882. The new
      code from this patch did not ensured that substitutions
      of fields for best equal fields were performed on all
      AND-OR levels. As a result substitutions for best fields
      in some predicates that had been used by the range optimizer
      were not actually performed while range plans could employ
      these substitutions. This could lead to inconsistent data
      structures and ultimately to a crash.
      3e868cd3
  13. 26 Jan, 2011 1 commit
    • Igor Babaev's avatar
      Fixed LP bug #707555. · a624f99e
      Igor Babaev authored
      The bug was in the code of the patch fixing bug 698882.
      With improper casting the method store_key_field::change_source_field
      was called for the elements of the array TABLE_REF::key_copy that
      were either of a different type or not allocated at all. This caused
      crashes in some queries. 
      a624f99e
  14. 24 Jan, 2011 1 commit
  15. 23 Jan, 2011 2 commits
  16. 22 Jan, 2011 3 commits
  17. 21 Jan, 2011 1 commit
  18. 14 Jan, 2011 10 commits
    • Sergei Golubchik's avatar
      6c907625
    • Sergei Golubchik's avatar
    • Sergei Golubchik's avatar
      Optimize use of SEARCH_SAVE_BUFF in Aria · eec32a33
      Sergei Golubchik authored
      (less not-needed copies of key pages)
      
      storage/maria/ma_rkey.c:
        Fixed wrong test if SEARCH_SAVE_BUFF should be set.
        Now we assume that if we are doing HA_READ_KEY_EXACT,
        we don't have to copy the last key buffer
        (in other words, it's not likely this will be followed
        by a read-next call)
      eec32a33
    • Sergei Golubchik's avatar
      use bulk insert and repair by sort for unique keys in · 418df96d
      Sergei Golubchik authored
      Aria and MyISAM in create_internal_tmp_table_from_heap()
      (safe, as duplicates are impossible).
      This gives a HUGE speed boost!
      
      sql/opt_subselect.cc:
        Fixed problem with wrong recinfo in create_duplicate_weedout_tmp_tabl()
        Tagged the table with 'no_rows' so that when we create the table on disk,
        we only store the index data. This gave us a major speedup!
      sql/sql_select.cc:
        create_tmp_table_from_heap() now uses bulk_insert + repair_by_sort
        when creating Aria/MyISAM tables from HEAP tables.
        This gives a HUGE speed boost!
      storage/maria/ha_maria.cc:
        Extended bulk_insert() to recreate UNIQUE keys for
        internal temporary tables
      storage/maria/ma_open.c:
        Initialize m_info->lock.type properly for temporarly tables
        (needed for start_bulk_insert())
      storage/maria/ma_write.c:
        Don't check uniques that are disabled
      storage/myisam/ha_myisam.cc:
        Extended bulk_insert() to recreate UNIQUE keys for
        internal temporary tables.
      418df96d
    • Sergei Golubchik's avatar
      Added ha_write_tmp_row() for slightly faster write_row for internal temp tables. · 6554977f
      Sergei Golubchik authored
      This will also enable us in the future to collect statistics for
      writes to internal tmp tables.
      
      sql/handler.h:
        Added ha_write_tmp_row()
      sql/opt_subselect.cc:
        ha_write_row -> ha_write_tmp_row
      sql/sql_class.h:
        Added ha_write_tmp_row()
      sql/sql_select.cc:
        ha_write_row -> ha_write_tmp_row
      6554977f
    • Sergei Golubchik's avatar
      Added support for NO_RECORD record format (don't store any row data) for Aria. · f5ea301a
      Sergei Golubchik authored
      This makes the keys smaller (no row pointer) and gives us proper errors if we
      use the table wrongly.
      
      sql/sql_select.cc:
        Use NO_RECORD for tables that doesn't need row data.
      storage/maria/Makefile.am:
        Added ma_norec.c
      storage/maria/ma_check.c:
        Added support for NO_RECORD record format (don't store any row data)
      storage/maria/ma_norec.c:
        Added support for NO_RECORD record format
      storage/maria/ma_open.c:
        Added support for NO_RECORD record format
      storage/maria/ma_search.c:
        Added support for 0 size row pointers (used with NO_RECORD)
      storage/maria/ma_test1.c:
        Added testing of NO_RECORD record format.
      storage/maria/maria_chk.c:
        Added support for NO_RECORD
      storage/maria/maria_def.h:
        Added support for NO_RECORD
      storage/maria/unittest/ma_test_all-t:
        Added testing of NO_RECORD record format
      f5ea301a
    • Sergei Golubchik's avatar
      use normal unique (HA_NOSAME) keys for expression cache · 17c18877
      Sergei Golubchik authored
      temptables, not "uniques", that are hash-based keys.
      
      sql/sql_expression_cache.cc:
        Don't set uniques (we don't want or need an unique
        constraint on this table)
      17c18877
    • Sergei Golubchik's avatar
      Added to Aria better hash for packed numeric data for unique handling. · fba96f7c
      Sergei Golubchik authored
      This was needed as the old code caused us to have LOTS of duplicate
      hash values when used by optimizer.
      
      include/m_ctype.h:
        Made my_hash_sort_bin() exernal
      storage/maria/ma_unique.c:
        Better hash for packed numeric data for unique handling.
        This was needed as the old code caused us to have LOTS
        of duplicate hash values when used by optimizer.
      fba96f7c
    • Sergei Golubchik's avatar
    • Sergei Golubchik's avatar
      Removed some old comments. · 563da78d
      Sergei Golubchik authored
      mysys/my_handler.c:
        Fixed typo
      563da78d
  19. 17 Jan, 2011 2 commits
  20. 16 Jan, 2011 1 commit
  21. 15 Jan, 2011 2 commits
    • Igor Babaev's avatar
      Merge · e32efc01
      Igor Babaev authored
      e32efc01
    • Igor Babaev's avatar
      Fixed LP bug #698882. · 84a0c9b2
      Igor Babaev authored
      Made sure that the optimal fields are used by TABLE_REF objects
      when building index access keys to joined tables.
      Fixed a bug in the template function that sorts the elements of
      a list using the bubble sort algorithm. The bug caused poor
      performance of the function. Also added an optimization that
      skips comparison with the most heavy elements that has been 
      already properly placed in the list.
      Made the comparison of the fields belonging to the same Item_equal
      more granular: fields belonging to the same table are also ordered
      according to some rules.
      84a0c9b2