Menu

#29 Subtle MYSQL Comment Parsing Error

open
nobody
None
5
2012-11-25
2012-11-25
Anonymous
No

Here is an example of a line which causes SQLFairy to crash :

`author` varchar(150) NOT NULL COMMENT 'book''s author',

The problem is the fact that the comment includes an apostrophe. The original comment is "book's author", but it seems that mysqldump adds an extra apostrophe to make "book''s author".

Thus, the SQLFairy parser must be interpreting this comment as two strings, "book" and "s author".

This causes SQLFairy to crash with the following error :

ERROR (line 22): Invalid statement: Was expecting comment, or use, or
set, or drop, or create, or alter, or insert, or
delimiter, or empty statement

I've seen this error posted a few times on the web. One thing that was a little confusing though was the line number where it said there was an error was the last line * before * the table statement which contained the offending line - in fact a line with no code on it at all. So it took me some time to solve this - I had to systematically delete lines till it worked.

Thanks for a really useful piece of software, and I *LOVE* the logo!!!

Peace,

Fred

Discussion


Log in to post a comment.

MongoDB Logo MongoDB