[MDEV-6899] extra semicolon in show create event syntax Created: 2014-10-20 Updated: 2022-05-17 Resolved: 2022-04-25 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Parser |
| Affects Version/s: | 5.5.40 |
| Fix Version/s: | 10.2.44, 10.3.35, 10.4.25, 10.5.16, 10.6.8, 10.7.4 |
| Type: | Bug | Priority: | Major |
| Reporter: | Kai Song | Assignee: | Sergei Golubchik |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | upstream | ||
| Environment: |
Scientific Linux release 6.5 |
||
| Attachments: |
|
||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||
| Description |
|
Dear MariaDB developers, I encountered a problem when importing from a database dump of itself. I used this command for the dump:
After I got the dump file, and was trying to import the database dump, the MariaDB complains about syntax error on a single line. This line is about the EVENT from the dump. The offending line looks like this:
Notice, there are a lot of "/* */" in this line. If I remove them as the following, the import can finish without any issue, and the database seems to be set up properly after importing:
Do you know what could be the issues here? Is this a bug in MariaDB "mysqldump" command? Thanks, Kai |
| Comments |
| Comment by Elena Stepanova [ 2014-10-20 ] | ||||||||||||||||||||||
|
The syntax error in the quoted statement is obvious: There should be no semicolon after CURRENT_DATE. You mentioned in the 'Affects Version' field that it's 5.5.40. Which MariaDB package are you using? | ||||||||||||||||||||||
| Comment by Kai Song [ 2014-10-20 ] | ||||||||||||||||||||||
|
Hi Elena, Thanks for looking into this. My MariaDB installation is from RHEL 6 build RPM:
I defined the event as follow:
So, could it be the semicolon causing the issue? I tried to remove the semicolon, but I am not able to to import this code anymore after I did that:
Do you know what I might have been missing? Thanks, Kai | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-10-20 ] | ||||||||||||||||||||||
|
Your syntax for CREATE EVENT seems fine to me. | ||||||||||||||||||||||
| Comment by Kai Song [ 2014-10-20 ] | ||||||||||||||||||||||
|
Hi Elena, Sure. It's always a good idea to go back and check the most basic things. I did try to dump from fresh every time I tested it. Here, I did it again as follow:
Then I dropped and created the my_db in MariaDB.
Thanks, Kai | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-10-20 ] | ||||||||||||||||||||||
|
Hi Kai, Does the dump you created (and re-created) also say in the header something like below?
What's your default character sets and locale? (I have no idea yet if it can be related, just covering the basics) As I understand, you only have one event in your dump, so we can't be sure if it's specific to the event, to mysqldump, or to the server. Could you please make an experiment – create an event in a separate empty schema on the same server, dump this schema and check if the problem is persistent, regardless the schema and the contents of the event? | ||||||||||||||||||||||
| Comment by Kai Song [ 2014-10-21 ] | ||||||||||||||||||||||
|
Hi Elena, Yes, the dump head looks exactly like that:
How to check the default character sets and locale? I tried to dump the database with --default-character-set=utf8", but still getting the same result. I will try to see if I can recreate this on a test database. Thanks so much for your help! Kai | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-10-21 ] | ||||||||||||||||||||||
|
Hi Kai, Could you please also run show create event expireToken \G on the server from which you are taking the dump, and see whether it shows the trailing semicolon in the 'Create Event' field? | ||||||||||||||||||||||
| Comment by Kai Song [ 2014-10-21 ] | ||||||||||||||||||||||
|
Hi Elena, Yes, it does have the semicolon in the 'Create Event' field:
By the way, I tested with just a table and a event, and the database dump file works just fine. Thanks, Kai | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-10-21 ] | ||||||||||||||||||||||
|
Okay, thanks, so now we know it's not mysqldump's fault, it just takes whatever it finds in show create event. You mentioned that you create objects, including the event in question, from STORED_PROCEDURES.sql file. Also, please attach your my.cnf file(s) or output of SHOW VARIABLES from the server. Thanks. | ||||||||||||||||||||||
| Comment by Kai Song [ 2014-10-21 ] | ||||||||||||||||||||||
|
Hi Elena, I found the problem while trying to prepare the sql script for you! The DELIMITER is set to be "//", but I didn't use it for the EVENT. Thanks so much for your help, and please feel free to remove this bug report! Kai | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-10-21 ] | ||||||||||||||||||||||
|
Okay, as long as the fix made the problem go away. I'm still mildly curious about how exactly it looked at the file, because even with the missing delimiter it's not so easy to achieve. But I suppose it's possible. | ||||||||||||||||||||||
| Comment by Kai Song [ 2014-10-21 ] | ||||||||||||||||||||||
|
Hi Elena, I managed to extract the problematic code in a schema.sql file and attached it to this issue. Take any database server without a database name "test_db", you can import the schema.sql file and generate a dump file, db_dump.sql:
Then, we can see the extra semicolon in the dump file:
Notice, in the schema.sql file line 22, if I replace the semicolon with "//" delimiter, the problem should be fixed. Hope this helps with debugging the issue. Thanks, Kai | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-10-21 ] | ||||||||||||||||||||||
|
Thanks, it's interesting.
It's the same in MySQL, too, probably has always been. Not sure that upstream will want to fix it, but at least next time we'll know. Still, if you want, you can try to file a bug at bugs.mysql.com and see what they say. | ||||||||||||||||||||||
| Comment by Elena Stepanova [ 2014-10-21 ] | ||||||||||||||||||||||
|
After some contemplation, re-opening because it still feels like a bug, albeit minor – a problem with parsing multi-statement queries? | ||||||||||||||||||||||
| Comment by Hartmut Holzgraefe [ 2017-07-30 ] | ||||||||||||||||||||||
|
Similar to https://bugs.mysql.com/bug.php?id=77856 ? | ||||||||||||||||||||||
| Comment by Anel Husakovic [ 2020-11-16 ] | ||||||||||||||||||||||
| Comment by Daniel Black [ 2020-11-20 ] | ||||||||||||||||||||||
|
Same approach as | ||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2020-11-23 ] | ||||||||||||||||||||||
|
danblack, please, I want to review it | ||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-02-24 ] | ||||||||||||||||||||||
|
Hi serg can you please review bb-10.2-anel-MDEV-6899-show-event-mysqldump-v2? | ||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2021-07-12 ] | ||||||||||||||||||||||
|
This still looks like a hack. Why the parser even puts a semicolon into the sp_proc_stmt ? | ||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-07-13 ] | ||||||||||||||||||||||
|
Hi,
sp_proc_stmts is used in
sp_proc_stmts1 is used in
None of above rules are used in trigger_tail (used in test case). | ||||||||||||||||||||||
| Comment by Anel Husakovic [ 2021-09-08 ] | ||||||||||||||||||||||
|
Hi serg, holyfoot, | ||||||||||||||||||||||
| Comment by Sergei Golubchik [ 2022-04-21 ] | ||||||||||||||||||||||
|
I've fixed the parser to not include the semicolon into the event definition | ||||||||||||||||||||||
| Comment by Alexander Barkov [ 2022-04-22 ] | ||||||||||||||||||||||
|
The patch |