PDA

View Full Version : MySQL validation?


u9x
8-29-06, 07:34 PM
For some reason I was thinking there was a way to validate MySQL code/syntax within MySQL but I haven't found anything on it (I might have been confused with PHP's php_check_syntax() function which only checks PHP code).

Prior to migration, I'd been using a script on my local development box to download my database backups, determine the most recent one, and import it into my local MySQL server. However, with the still unresolved file corruption issues (http://forum.powweb.com/showthread.php?t=66725) on PW's side, I don't trust that the backups are surviving the transfer intact and want to validate the code before importing it. I could compare the filesize of a backup file on the remote to that on the local side but I don't particularly trust that method either (I've always seen minor variances in those as it is).

Can anyone tell me if there is an MySQL function or command-line option to test the code?

cc1030
8-29-06, 09:06 PM
I don't know about MySQL, but you couldn't you use a CGI script to calculate the MD5 or SHA1 hash of the file? That would tell you with a high degree of certainty whether or not the file had survived the transfer.

jmucchiello
8-31-06, 04:45 AM
Actually, it might not tell you anything. If your home platform is Windows, the end of line markers will be translated from CRLF to LF and the MD5 or SHA1 hash of the two files will not match without jumping through a few hoops.

u9x
8-31-06, 07:22 PM
Hashing didn't work, nor did pulling the files into a string and comparing them. I figured there might be issues between platforms due to line endings, turned out to be the very reason. Thanks for the idea anyways, cc1030 :)

cc1030
8-31-06, 07:59 PM
This may sound dumb, but why not just zip the file (using WinZip)? That would make it smaller, so it would be sent faster, and it provides built-in error detection. Then you can just create a script to allow you to unzip the file (the command to unzip the file and convert the endlines on text files would be "unzip -ua zipfile.zip"). If you need help writing the script, I could help with that. Alternatively, you could code a script to receive a zipfile as a file input, then extract your .SQL file from that zipfile. That would eliminate the need to upload your .SQL file via FTP and then run the script to extract it; just cuts down on the number of steps.