[MDEV-31092] mysqldump --force doesn't ignore error as it should Created: 2023-04-20  Updated: 2023-07-31  Resolved: 2023-07-31

Status: Closed
Project: MariaDB Server
Component/s: Scripts & Clients
Affects Version/s: 10.6.12, 10.5
Fix Version/s: 10.4.31, 10.5.22, 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.0.3, 11.1.2, 11.2.1

Type: Bug Priority: Critical
Reporter: Susmeet Khaire Assignee: Sergei Golubchik
Resolution: Fixed Votes: 1
Labels: mysqldump


 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.



 Comments   
Comment by Daniel Black [ 2023-04-21 ]

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.

Comment by Daniel Black [ 2023-04-21 ]

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?

Comment by Sergei Golubchik [ 2023-04-24 ]

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

Generated at Thu Feb 08 10:21:13 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.