Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-39476

mariadb-dump outputs ALTER TABLE statements with former charset/collation if a trigger was created with said former charset/collation

    XMLWordPrintable

Details

    • Bug
    • Status: Open (View Workflow)
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • Scripts & Clients
    • None

    Description

      This issue is related to the dump utility `mariadb-dump`. That being said, I could not find an issue category related to clients specifically and I know it's not related to specific connectors.

      I haven't fully grasped the circumstances that cause the issue, but they are something along the lines of:
      1. I have a MariaDB instance that was for the most part using default settings for charset/collation.
      2. Over time I had created many schemas/tables/triggers and the instance was being actively used.
      3. Eventually I discovered that the default charset/collation were being applied to schemas and tables.
      4. I went through a comprehensive process of configuring [server], [mysqld], [mysql]'s, [mysqldump]'s to use utf8mb4 and utf8mb4_unicode_ci.
      5. Alter/converted all tables to utf8mb4_unicode_ci. Altered all schemas to utf8mb4_unicode_ci.

      No action was attempted on the triggers, which seem to have some memory of the old charsets/collations, which is visible through:
      ```
      mariadb --skip-ssl --host=mariadb -u root -p -e "
      SELECT routine_type, routine_name, character_set_client, collation_connection, database_collation
      FROM information_schema.ROUTINES
      WHERE routine_schema = 'adex_sales_nomad'
      LIMIT 10;
      SELECT trigger_name, character_set_client, collation_connection, database_collation
      FROM information_schema.TRIGGERS
      WHERE trigger_schema = 'adex_sales_nomad'
      LIMIT 5;"
      ```
      which in my case produces
      ```
      -----------------------------------------------------------------------------------------------+

      trigger_name character_set_client collation_connection database_collation

      -----------------------------------------------------------------------------------------------+

      trg_auth_user_full_name_insert utf8mb4 utf8mb4_unicode_ci latin1_swedish_ci
      trg_auth_user_email_username_insert utf8mb4 utf8mb4_unicode_ci latin1_swedish_ci
      trg_auth_user_email_domain_insert utf8mb4 utf8mb4_unicode_ci latin1_swedish_ci
      trg_auth_user_full_name_update utf8mb4 utf8mb4_unicode_ci latin1_swedish_ci
      trg_auth_user_email_username_update utf8mb4 utf8mb4_unicode_ci latin1_swedish_ci

      -----------------------------------------------------------------------------------------------+
      ```

      This results in dump files created by mariadb-dump to have the create tables correctly ending with
      ```
      ...
      ) ENGINE=InnoDB AUTO_INCREMENT=10 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
      ```

      but after the data insert queries I'm getting
      ```
      UNLOCK TABLES;
      ALTER DATABASE `db_name` CHARACTER SET latin1 COLLATE latin1_swedish_ci ;
      ```

      which does seem like a bug or poor design with the bigger problem here being that a portable dump that does not specify --databases should NOT contain the original name of the target schema (at least from my understanding, since I don't see USE DATABASE statements).

      Attachments

        Activity

          People

            Unassigned Unassigned
            savemetenminutes Milen
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.