PDA

View Full Version : Trouble inserting literal semicolons in mySQL


omatic
3-12-03, 02:10 AM
Hello all,

I have been experimenting with making backups of my mySQL data from Powweb's mySQL servers, and then restoring that data to my copy of mySQL running locally, here in my 'lab'.

What I'm having a problem with, is that many of the INSERT statements contain semicolons within their string data. Unfortunately, the INSERT statement seems to ignore the fact that the ; character is in single quotes (part of a quoted literal string) and mySQL treats that semicolon as the end of the INSERT statement.

This kinda SUCKS, because it turns a single valid INSERT statement into two completely broken SQL statements by breaking it in half! Here's an example:INSERT INTO mysql_tablename (stringcolumn1, column2) VALUES ('a string literal; with a semicolon in it!', 'someothervalue');This gets interpreted, rather ungracefully, as two separate (and completely invalid) statements:INSERT INTO mysql_tablename (stringcolumn1, column2) VALUES ('a string literal;

--- and ---

with a semicolon in it!', 'someothervalue');Of course, that's completely wrong.

I have tried escaping these semicolons with a backslash character, as one would with normal special characters that need escaping (like "\n" for a newline character). Unfortunately, it appears that "\;" is not a valid escape sequence, and it still fails.

Anybody have an idea how I can get it to recognize the semicolons as part of a literal string?

Good Gawd!! Frustrating.
omatic

HalfaBee
3-12-03, 02:45 AM
I tried it on mysql-front and it works OK
What version of mysql are you using?

HalfaBee

Xinil
3-12-03, 02:47 AM
I tried it out too, works for me.

omatic
3-12-03, 03:04 AM
MySQL version is same as here at Pow, 4.0.11-gamma.

I'm using MySQL-CC, the front end tool now being offered at mysql's website.

I will obtain mySql-Front tomorrow and try using that; perhaps it's a problem with mySQL-CC's handling of literals.

Thanks guys.
omatic

omatic
3-12-03, 10:51 AM
Well I thought I posted this last night (about 20 minutes after my previous message) but apparently my brain was already sleeping and I didn't hit "submit..." ... lol.... so here goes again.

I found a copy of MySQL-Front v2.5 online (has development of it really ceased? bummer!) and tried it out. The semicolons did no harm when submitted from MySQL-Front. So it appears to be a bug in MySQL-CC. Guess I will switch tools! They're very similar anyway, though -Front seems to have more features.

Say, if you happen to be bored and feel like downloading/trying MySQL-CC under these circumstances (to see if you can break it) I'd sure like to hear about it... please post back here. Otherwise I consider it a done deal.

Couldn't have figured it out without y'all. Thanks again!!
omatic