• anozdrin/alik@ibm.'s avatar
    Fix for BUG#30027: mysqldump does not dump views properly. · e73f004f
    anozdrin/alik@ibm. authored
    mysqldump generates view defitions in two stages:
    
      - dump CREATE TABLE statements for the temporary tables.  For each view a
        temporary table, that has the same structure as the view is created.
    
      - dump DROP TABLE statements for the temporary tables and CREATE VIEW
        statements for the view.
    
    This approach is required because views can have dependencies on each other
    (a view can use other views). So, they should be created in the particular
    order. mysqldump however is not smart enough, so in order to resolve
    dependencies it creates temporary tables first of all.
    
    The problem was that mysqldump might have generated incorrect dump for the
    temporary table when a view has non-ASCII column name. That happened when
    default-character-set is not utf8.
    
    The fix is to:
    
      1. Switch character_set_client for the mysqldump's connection to binary
         before issuing SHOW FIELDS statement in order to avoid conversion.
        
      2. Dump switch character_set_client statements to UTF8 and back for
         CREATE TABLE statement that is issued to create temporary table.
    e73f004f
mysqldump.c 145 KB