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

mariadb-dump / mysqldump backup corrupt if stored procedure ends with comment

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Major
    • Resolution: Unresolved
    • 10.5, 10.6, 10.11, 11.4, 11.8
    • 10.11, 11.4, 11.8
    • Scripts & Clients
    • None
    • MariaDB dump 10.19 Distrib 10.6.21-MariaDB, for debian-linux-gnu (x86_64)

    Description

      When you create a stored procedure, where the last line ends with a comment, mariadb-dump will just add ";;" after this comment.

      When you execute the following statement in a JDBC-query

      CREATE PROCEDURE usp_ebean_drop_column(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
      -- play-ebean-start
      BEGIN
      CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);
      SET @sql = CONCAT('ALTER TABLE `', p_table_name, '` DROP COLUMN `', p_column_name, '`');
      PREPARE stmt FROM @sql;
      EXECUTE stmt;
      END
      -- play-ebean-end
      

      a backup will get corrupt, because mariadb-dump will create the following output in the dump file:

      DELIMITER ;;
      CREATE DEFINER=`root`@`%` PROCEDURE `usp_ebean_drop_column`(IN p_table_name VARCHAR(255), IN p_column_name VARCHAR(255))
      BEGIN
      CALL usp_ebean_drop_foreign_keys(p_table_name, p_column_name);
      SET @sql = CONCAT('ALTER TABLE `', p_table_name, '` DROP COLUMN `', p_column_name, '`');
      PREPARE stmt FROM @sql;
      EXECUTE stmt;
      END
      -- play-ebean-end ;;
      DELIMITER ;
      

      Note the --play-ebean-end ;; line. mariadb-dump just adds the ;;

      The following command/options were used: mysqldump --hex-blob --routines --single-transaction --skip-extended-insert --complete-insert --no-autocommit -p testdb

      We could repoduce this in our java application or just by pasting this query in Dbeeaver. Adding a newline after the comment seems not to help (seems that jdbc-driver trims the query)

      We could not reproduce it with the mariadb CLI client

      You may also take a look at this issue https://github.com/ebean-orm/ebean/issues/3577 where we discovered the bug and the workaround.

      Workaround: don't let your procedures end with a comment.

      Attachments

        Activity

          pram Roland Praml created issue -
          elenst Elena Stepanova made changes -
          Field Original Value New Value
          Component/s Scripts & Clients [ 11002 ]
          Component/s Backup [ 13902 ]
          Component/s mariabackup [ 14500 ]
          Fix Version/s 10.11 [ 27614 ]
          Fix Version/s 11.4 [ 29301 ]
          Fix Version/s 11.8 [ 29921 ]
          Affects Version/s 10.5 [ 23123 ]
          Affects Version/s 10.11 [ 27614 ]
          Affects Version/s 11.4 [ 29301 ]
          Affects Version/s 11.8 [ 29921 ]
          Assignee Oleksandr Byelkin [ sanja ]
          elenst Elena Stepanova made changes -
          Status Open [ 1 ] Confirmed [ 10101 ]

          People

            sanja Oleksandr Byelkin
            pram Roland Praml
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.