[MDEV-24200] Syntax error in mysqldump (triggers with ; endings) Created: 2020-11-12 Updated: 2021-07-12 Resolved: 2021-07-12 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Backup, Triggers |
| Affects Version/s: | 10.3.25 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Kim Gert Nielsen | Assignee: | Sergei Golubchik |
| Resolution: | Duplicate | Votes: | 1 |
| Labels: | None | ||
| Environment: |
Ubuntu focal
|
||
| Issue Links: |
|
||||||||||||||||
| Description |
|
Hi, When dumping a database with triggers for a customer I got the current output:
When restoring or running it manually I get:
If I remove the last ; so the query looks like this:
then it works. |
| Comments |
| Comment by Alice Sherepa [ 2020-11-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I tried to repeat but got the correct output. Could you please provide steps on how to reproduce the issue?
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kim Gert Nielsen [ 2020-11-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sure .. I run
#/usr/bin/mysqldump --opt --single-transaction --disable-keys --routines --events --triggers --socket /var/run/mysqld/mysqld.sock -u root -p secret mydb {sql}– MySQL dump 10.17 Distrib 10.3.25-MariaDB, for debian-linux-gnu (x86_64) /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; DROP TABLE IF EXISTS `LabelsUsers`; – LOCK TABLES `LabelsUsers` WRITE; – /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; – Dump completed on 2020-11-12 5:13:38 Just noticed that I actually run mysqldump on bionic and restore on a focal but still version 10.3.25 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-11-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi Desdic,
What is problematic in your example is the executable comments /!50003 CREATE/ /!50017 DEFINER=`mydb`@`%` */. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2020-11-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
This is an old problem
Once you've created it, it does have an extra semicolon in the description, which ends up in the dump and causes the syntax error.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Elena Stepanova [ 2020-11-13 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
anel,
It's not a problem, it's a formatting issue. Since the comment doesn't have 'noformat' or alike, special symbols like stars are misinterpreted for bold markers. If you open the comment for editing, you'll see them there. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Kim Gert Nielsen [ 2020-11-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Ah oki so the Customer in my case actually did this themselves .. is there any option for the dump that I can add to change the behavior so I can get a consistent backup/restore ? | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2020-11-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Any option change is going to remove the trigger. The below sed should clean up all the output. Manually inspect the diff from the original to ensure it hasn't picked up addition pattens in your dump.
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-11-16 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Hi danblack, elenst thank you for clarification, I will take a closer look how comments are created in that manner. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2020-11-17 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
comments on patch. Same applies to | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-11-17 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks danblack for review. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-11-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I think it's a very strange idea to remove semicolons in sql_show.cc. Either they shoudn't get into the trigger definition in the first place, or the parser should be able to parse them just fine. On the related note I suspect that these /*!50003 comments have outlived their usefulness, 5.0.3 was looong time ago. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Daniel Black [ 2020-11-19 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
If we can get rid of the /*!500003 comments, then the problem can be solved purely in mysqldump like:
I've changed the delimiter here so that a trigger ending in ;, when it is getting restored in the dump isn't confused by a ;;; . The principle here of dump/restore being the same. I'm also hoping something here restores exactly the same trigger that was there previously so checksums, if any are applicable, match. A follow up task on the parser for 10.6 Second follow up task to remove any < 5.5 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-11-23 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
danblack, please, I want to review it | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-12-27 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
see my review for | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-02-24 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
The patch for this MDEV can be found in MDEV-6899 patch where the test case for this MDEV is added. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-07-12 ] | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Will be fixed in |