in reply to Re: Regexp in mysqldump
in thread Regexp in mysqldump

You may get into trouble if the default values for fields contain spaces, or if the dump includes database population (insert) statements with values containing spaces.

Bottom line is that the substitution needs to be SQL syntax aware. I feel too lazy to write a SQL parser - there is probably one already on CPAN.

     Syntactic sugar causes cancer of the semicolon.        --Alan Perlis

Replies are listed 'Best First'.
Re^3: Regexp in mysqldump
by brozzis (Sexton) on Apr 16, 2010 at 14:57 UTC

    I was creating a parser, and I already created one for another project, but then I discovered that mysqldump uses backticks (`) for table name and field names, and standard ticks (') for values in insert and update statements.

    For this reason a standard regexp does the job.

    I've tried the first solution, and works perfectly at a first glance... I'll try hopefully tonight the second one...
      For this reason a standard regexp does the job.
      Nope. That reason is not enough on its own. It breaks on things like:
      `fieldname` varchar(255) default 'Got you `haha haha`!',
      Just because MySQL uses different quotes doesn't mean quotes cannot be contained inside other quotes.