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

mysqldump --force doesn't ignore error as it should

Details

    Description

      Customer has few legacy functions.

      One of the function has some syntax error.
      But more importantly customer is unable to take a dump of the function even with --force.

      mysqldump --no-data --routines --events --triggers --force --databases xxxx> dump.sql
      mysqldump: Couldn't execute 'SHOW CREATE FUNCTION `FF1`': Undeclared variable: DBPAY_DRAWING_AMT (1327)
      

      Force option is supposed to ignore the error, add a comment in the dump file and move on to the next object.
      This doesnt happen for this particular function.
      But the behaviour can be observed for "Views with missing tables" errors.

      Attachments

        Activity

          danblack Daniel Black added a comment -

          reproduced with:

          MariaDB [mysql]> create function bob() returns int return 1;
           
          MariaDB [mysql]> update proc set body='return no_such_var' where name='bob';
          Query OK, 1 row affected (0.001 sec)
          Rows matched: 1  Changed: 1  Warnings: 0
           
          MariaDB [mysql]> show create function bob;
          ERROR 1327 (42000): Undeclared variable: no_such_var
          MariaDB [mysql]> select bob();
          ERROR 1457 (HY000): Failed to load routine mysql.bob (internal code -6). For more details, run SHOW WARNINGS
          MariaDB [mysql]> show warnings;
          +-------+------+------------------------------------------------------------------------------------------+
          | Level | Code | Message                                                                                  |
          +-------+------+------------------------------------------------------------------------------------------+
          | Error | 1327 | Undeclared variable: no_such_var                                                         |
          | Error | 1457 | Failed to load routine mysql.bob (internal code -6). For more details, run SHOW WARNINGS |
          +-------+------+------------------------------------------------------------------------------------------+
          2 rows in set (0.000 sec)
          

          I suppose it would be more consistent to treat events and triggers the same way during mariadb-dump too.

          danblack Daniel Black added a comment - reproduced with: MariaDB [mysql]> create function bob() returns int return 1;   MariaDB [mysql]> update proc set body= 'return no_such_var' where name = 'bob' ; Query OK, 1 row affected (0.001 sec) Rows matched: 1 Changed: 1 Warnings: 0   MariaDB [mysql]> show create function bob; ERROR 1327 (42000): Undeclared variable: no_such_var MariaDB [mysql]> select bob(); ERROR 1457 (HY000): Failed to load routine mysql.bob (internal code -6). For more details, run SHOW WARNINGS MariaDB [mysql]> show warnings; + -------+------+------------------------------------------------------------------------------------------+ | Level | Code | Message | + -------+------+------------------------------------------------------------------------------------------+ | Error | 1327 | Undeclared variable: no_such_var | | Error | 1457 | Failed to load routine mysql.bob (internal code -6). For more details, run SHOW WARNINGS | + -------+------+------------------------------------------------------------------------------------------+ 2 rows in set (0.000 sec) I suppose it would be more consistent to treat events and triggers the same way during mariadb-dump too.
          danblack Daniel Black added a comment -

          It occurs to me we could just removing the validation of the function in SHOW CREATE FUNCTION? This would make it equivalent to triggers and events who's SHOW SQL doesn't validate the function.

          Any recommendation serg?

          danblack Daniel Black added a comment - It occurs to me we could just removing the validation of the function in SHOW CREATE FUNCTION ? This would make it equivalent to triggers and events who's SHOW SQL doesn't validate the function. Any recommendation serg ?

          danblack, I think just making --force to continue over errors should be enough here. If someone would want to include invalid routines into the dump it could be easily achieved by dumping mysql.proc and not using --routines

          serg Sergei Golubchik added a comment - danblack , I think just making --force to continue over errors should be enough here. If someone would want to include invalid routines into the dump it could be easily achieved by dumping mysql.proc and not using --routines

          People

            serg Sergei Golubchik
            susmeet.khaire Susmeet Khaire
            Votes:
            1 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

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