Fix blob escaping when creating backups

dww - June 23, 2007 - 19:08
Project:Database Administration
Version:5.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:smk-ka
Status:patch (to be ported)
Description

Polluting patches in both http://drupal.org/node/106576 and http://drupal.org/node/132630 was an important change to fix how we escape blobs when creating backup tables. I ripped the code out of #106576, so it could be fixed separately, since it needs to go into both DRUPAL-4-7 and HEAD.

And so begins the long list of bugs that require totally separate patches due to lame differences between HEAD and DRUPAL-4-7... :(

Here's the patch for DRUPAL-4-7

AttachmentSize
dba_escape_blobs.47x.patch.txt1.62 KB

#1

dww - June 23, 2007 - 19:09

And for HEAD...

AttachmentSize
dba_escape_blobs.HEAD_.patch.txt 1.54 KB

#2

dww - June 23, 2007 - 19:20
Assigned to:dww» Anonymous

not having thought about this much or investigated, it's not clear why we're manually trying to escape everything instead of just using db_escape_string()... these patches might need re-doing.

#3

smk-ka - July 29, 2007 - 11:23
Version:4.7.x-1.x-dev» 5.x-1.x-dev
Assigned to:Anonymous» smk-ka

[...] it's not clear why we're manually trying to escape everything instead of just using db_escape_string()...

Because creating a textual dump is different from actually executing a query. mysql_real_escape_string() escapes both types of quotes with a backslash, where we only need to double single quotes and leave double quotes unchanged.

Updated patch contains:
- support for NULL values, to be able to 100% recreate a database
- the missing read-in of the table schema.

Tests I've run so far:
1. created a phpMyAdmin reference dump
2. created a site snapshot using Demo module
3. reset site using Demo module
4. created another dump using phpMyAdmin and visually diffed against the first one. Result is 100% the same (except for changed timestamps, of course).
--
Stefan Kudwien
unleashed mind

AttachmentSize
backup_table.patch 2 KB

#4

dww - July 29, 2007 - 16:34
Status:needs review» patch (to be ported)

great, thanks! don't have time to review/test now, but i certainly appreciate the patch. however, since this is a bug, please provide a version for the DRUPAL-4-7 branch, too...

thanks,
-derek

 
 

Drupal is a registered trademark of Dries Buytaert.