1. 09 Sep, 2010 1 commit
    • Dmitry Lenev's avatar
      Fix for bug #55273 "FLUSH TABLE tm WITH READ LOCK for Merge · 3326614d
      Dmitry Lenev authored
      table causes assert failure".
      
      Attempting to use FLUSH TABLE table_list WITH READ LOCK
      statement for a MERGE table led to an assertion failure if
      one of its children was not present in the list of tables
      to be flushed. The problem was not visible in non-debug builds.
      
      The assertion failure was caused by the fact that in such
      situations FLUSH TABLES table_list WITH READ LOCK implementation
      tried to use (e.g. lock) such child tables without acquiring
      metadata lock on them. This happened because when opening tables
      we assumed metadata locks on all tables were already acquired
      earlier during statement execution and a such assumption was
      false for MERGE children.
      
      This patch fixes the problem by ensuring at open_tables() time
      that we try to acquire metadata locks on all tables to be opened. 
      For normal tables such requests are satisfied instantly since
      locks are already acquired for them. For MERGE children metadata
      locks are acquired in normal fashion.
      
      Note that FLUSH TABLES merge_table WITH READ LOCK will lock for
      read both the MERGE table and its children but will flush only 
      the MERGE table. To flush children one has to mention them in table
      list explicitly. This is expected behavior and it is consistent with
      usage patterns for this statement (e.g. in mysqlhotcopy script).
      3326614d
  2. 08 Sep, 2010 1 commit
    • Jon Olav Hauglid's avatar
      Bug #56292 Deadlock with ALTER TABLE and MERGE tables · 51a3375c
      Jon Olav Hauglid authored
      ALTER TABLE on a MERGE table could cause a deadlock with two
      other connections if we reached a situation where:
      
      1) A connection doing ALTER TABLE can't upgrade to MDL_EXCLUSIVE on the
      parent table, but holds TL_READ_NO_INSERT on the child tables.
      2) A connection doing DELETE on a child table can't get TL_WRITE on it
      since ALTER TABLE holds TL_READ_NO_INSERT.
      3) A connection doing SELECT on the parent table can't get TL_READ on 
      the child tables since TL_WRITE is ahead in the lock queue, but holds
      MDL_SHARED_READ on the parent table preventing ALTER TABLE from upgrading.
      
      For regular tables, this deadlock is avoided by having ALTER TABLE
      take a MDL_SHARED_NO_WRITE metadata lock on the table. This prevents
      DELETE from acquiring MDL_SHARED_WRITE on the table before ALTER TABLE
      tries to upgrade to MDL_EXCLUSIVE. In the example above, SELECT would
      therefore not be blocked by the pending DELETE as DELETE would not be
      able to enter TL_WRITE in the table lock queue.
      
      This patch fixes the problem for merge tables by using the same metadata
      lock type for child tables as for the parent table. The child tables will
      in this case therefore be locked with MDL_SHARED_NO_WRITE, preventing
      DELETE from acquiring a metadata lock and enter into the table lock queue.
      
      Change in behavior: By taking the same metadata lock for child tables
      as for the parent table, LOCK TABLE on the parent table will now also
      implicitly lock the child tables. Since LOCK TABLE on the parent table
      now takes more than one metadata lock, it is possible for LOCK TABLE
      ... WRITE on the parent table or child tables to give ER_LOCK_DEADLOCK
      error.
      
      Test case added to mdl_sync.test.
      Merge.test/.result has been updated to reflect the change to LOCK TABLE.
      51a3375c
  3. 03 Sep, 2010 1 commit
  4. 02 Sep, 2010 2 commits
  5. 01 Sep, 2010 5 commits
  6. 31 Aug, 2010 10 commits
    • Alexander Nozdrin's avatar
      b75958e6
    • Alexander Nozdrin's avatar
      Bug#55980 Character sets: supplementary character _bin ordering is wrong · 8da22a75
      Alexander Nozdrin authored
      Problem:
      - ORDER BY for utf8mb4_bin, utf16_bin and utf32_bin returned
        results in a wrong order, because old functions
        (supporting only BMP range) were used to handle these collations.
      - Additionally, utf16_bin did not sort supplementary characters
        between U+D700 and U+E000, as WL#1213 specification specified.
      8da22a75
    • Alexander Nozdrin's avatar
      Bug#27480 (Extend CREATE TEMPORARY TABLES privilege · d2159e37
      Alexander Nozdrin authored
      to allow temp table operations) -- prerequisite patch #3.
      
      Rename open_temporary_table() to open_table_uncached().
      open_temporary_table() will be introduced in following patches
      to open temporary tables for a statement.
      d2159e37
    • Alexander Nozdrin's avatar
      Remove check_merge_table_access(). · 53e566a4
      Alexander Nozdrin authored
      check_merge_table_access() used to do two things:
        - set proper database for every merge table child;
        - check SELECT | UPDATE | DELETE for merge table children.
      
      Setting database is not needed anymore, since it's done
      on the parsing stage.
      
      Thus, check_merge_table_access() can be removed;
      needed privileges can be checked using check_table_access().
      53e566a4
    • Alexander Nozdrin's avatar
      Polish check_grant(): name TABLE_LIST instance "tl", not "table". · 6b9371bd
      Alexander Nozdrin authored
      This allows to avoid mixing it up with pointer to TABLE object
      which will be introduced to this function in one of upcoming
      patches.
      6b9371bd
    • Alexander Nozdrin's avatar
      Remove unused enum (enum open_table_mode). · 1f1eba3c
      Alexander Nozdrin authored
      It was added by mistake during backport from 6.0.
      1f1eba3c
    • Alexander Nozdrin's avatar
      Bug#27480 (Extend CREATE TEMPORARY TABLES privilege · 2e462c8f
      Alexander Nozdrin authored
      to allow temp table operations) -- prerequisite patch #2.
      
      Introduce a new form of find_temporary_table() function:
      find_temporary_table() by a table key. It will be used
      in further patches.
      
      Replace find_temporary_table(table_list->db, table_list->name)
      by more appropiate find_temporary_table(table_list) across
      the codebase.
      2e462c8f
    • Alexander Nozdrin's avatar
      Fix TABLE::init() comment. · a92ca267
      Alexander Nozdrin authored
      a92ca267
    • Dmitry Lenev's avatar
      Bug #56137 "Assertion `thd->lock == 0' failed on upgrading · 26bc3b34
      Dmitry Lenev authored
      from 5.1.50 to 5.5.6".
      
      Debug builds of the server aborted due to an assertion
      failure when DROP DATABASE statement was run on an
      installation which had outdated or corrupt mysql.proc table.
      Particularly this affected the mysql_upgrade tool which is
      run as part of 5.1 to 5.5 upgrade.
      
      The problem was that sp_drop_db_routines(), which was invoked
      during dropping of the database, could have returned without
      closing and unlocking mysql.proc table in cases when this
      table was not up-to-date with the current server. As a result
      further attempt to open and lock the mysql.event table, which
      was necessary to complete dropping of the database, ended up
      with an assert.
      
      This patch solves this problem by ensuring that
      sp_drop_db_routines() always closes mysql.proc table and
      releases metadata locks on it. This is achieved by changing
      open_proc_table_for_update() function to close tables and
      release metadata locks acquired by it in case of failure.
      This step also makes behavior of the latter function
      consistent with behavior of open_proc_table_for_read()/
      open_and_lock_tables().
      
      
      Test case for this bug was added to sp-destruct.test.
      26bc3b34
    • Alexander Nozdrin's avatar
      Auto-merge from mysql-5.5-merge. · e4a7db6c
      Alexander Nozdrin authored
      e4a7db6c
  7. 30 Aug, 2010 10 commits
  8. 28 Aug, 2010 1 commit
  9. 27 Aug, 2010 7 commits
    • Marc Alff's avatar
      local merge · 73570819
      Marc Alff authored
      73570819
    • Sergey Vojtovich's avatar
      Merge 5.1-bugteam to 5.5-merge. · ab241457
      Sergey Vojtovich authored
      ab241457
    • Alexey Kopytov's avatar
      Bug #54465: assert: field_types == 0 || field_types[field_pos] · b409a221
      Alexey Kopytov authored
                  == MYSQL_TYPE_LONGLONG
      
      A MIN/MAX() function with a subquery as its argument could lead
      to a debug assertion on debug builds or wrong data on release
      ones.
      
      The problem was a combination of the following factors:
      
      - Item_sum_hybrid::fix_fields() might use the argument
      (args[0]) to calculate 'hybrid_field_type' which was later used
      to decide how the data should be sent to the client.
      
      - Item_sum::make_field() might use the argument again to
      calculate the field's type when sending result set metadata to
      the client.
      
      - The argument could be changed in between these two calls via
        Item::set_arg() leading to inconsistent metadata being
        reported.
      
      Here is what was happening for the bug's test case:
      
      1. Item_sum_hybrid::fix_fields() calculates hybrid_field_type
      as MYSQL_TYPE_LONGLONG based on args[0] which is an
      Item::SUBSELECT_ITEM at that time.
      
      2. A temporary table is created to execute the
      query. create_tmp_field_from_item() creates a Field_long object
      according to the subselect's max_length.
      
      3. The subselect item in Item_sum_hybrid is replaced by the
      Item_field object referencing the newly created Field_long.
      
      4. Item_sum::make_field() rightfully returns the
      MYSQL_TYPE_LONG type when calculating the result set metadata.
      
      5. When sending the actual data, Item::send() relies on the
      virtual field_type() function which in our case returns
      previously calculated hybrid_field_type == MYSQL_TYPE_LONGLONG.
      
      It looks like the only solution is to never refer to the
      argument's metadata after the result metadata has been
      calculated in fix_fields(), since the argument itself may be
      different by then. In this sense, Item_sum::make_field() should
      never be used, because it may rely on the argument's metadata
      and is only called after fix_fields(). The "default"
      implementation in Item::make_field() should be used instead as
      it relies only on field_type(), but not on the argument's type.
      
      Fixed by removing Item_sum::make_field() so that the superclass
      implementation Item::make_field() is always used.
      b409a221
    • Alexander Nozdrin's avatar
      Bug#27480 (Extend CREATE TEMPORARY TABLES privilege · 0142c14a
      Alexander Nozdrin authored
      to allow temp table operations) -- prerequisite patch #1.
        
      Move a piece of code that initialiazes TABLE instance
      after it was successfully opened into a separate function.
      This function will be reused in the following patches.
      0142c14a
    • Ramil Kalimullin's avatar
      Fix for bug #54253: memory leak when using I_S plugins w/o deinit method · 1087cfc4
      Ramil Kalimullin authored
      Free memory allocated by the server for all plugins,
      with or without deinit() method.
      1087cfc4
    • Sergey Vojtovich's avatar
      c2c833e4
    • Sergey Vojtovich's avatar
      BUG#52821 - plugin_ftparser.h and plugin_audit.h are · 7ceb92ff
      Sergey Vojtovich authored
                  not tested by ABI check
      
      plugin_audit.h and plugin_ftparser.h are now subject
      for ABI check. plugin.h is now tested implicitly.
      
      Also fixed broken ABI check cmake rules.
      7ceb92ff
  10. 26 Aug, 2010 2 commits