diff --git includes/database/mysql/schema.inc includes/database/mysql/schema.inc index 01933da..2071d6d 100644 --- includes/database/mysql/schema.inc +++ includes/database/mysql/schema.inc @@ -134,6 +134,9 @@ class DatabaseSchema_mysql extends DatabaseSchema { if (in_array($spec['mysql_type'], array('VARCHAR', 'CHAR', 'TINYTEXT', 'MEDIUMTEXT', 'LONGTEXT', 'TEXT')) && isset($spec['length'])) { $sql .= '(' . $spec['length'] . ')'; + if (!empty($spec['binary'])) { + $sql .= ' BINARY'; + } } elseif (isset($spec['precision']) && isset($spec['scale'])) { $sql .= '(' . $spec['precision'] . ', ' . $spec['scale'] . ')'; diff --git includes/database/schema.inc includes/database/schema.inc index e57c94b..09c3a6f 100644 --- includes/database/schema.inc +++ includes/database/schema.inc @@ -77,6 +77,9 @@ require_once dirname(__FILE__) . '/query.inc'; * the precision (total number of significant digits) and scale * (decimal digits right of the decimal point). Both values are * mandatory. Ignored for other field types. + * - 'binary': For type 'char', 'varchar' or 'text' fields on MySQL, forces + * a case-sensitive binary collation. This has no effect on other database + * types for which case sensitivity is already the default behavior. * All parameters apart from 'type' are optional except that type * 'numeric' columns must specify 'precision' and 'scale'. * - 'primary key': An array of one or more key column specifiers (see below) diff --git modules/simpletest/tests/upgrade/drupal-6.upload.database.php modules/simpletest/tests/upgrade/drupal-6.upload.database.php index 94733ed..e87c089 100644 --- modules/simpletest/tests/upgrade/drupal-6.upload.database.php +++ modules/simpletest/tests/upgrade/drupal-6.upload.database.php @@ -115,6 +115,17 @@ db_insert('files')->fields(array( 'status' => '1', 'timestamp' => '1285708957', )) +// Test upgrading files with the same name but different case. +->values(array( + 'fid' => '11', + 'uid' => '1', + 'filename' => 'FORUM-STICKY.PNG', + 'filepath' => 'sites/default/files/FORUM-STICKY.PNG', + 'filemime' => 'image/png', + 'filesize' => '329', + 'status' => '1', + 'timestamp' => '1285708957', +)) ->execute(); db_insert('node')->fields(array( @@ -236,8 +247,8 @@ db_insert('node_revisions')->fields(array( 'vid' => '53', 'uid' => '1', 'title' => 'node title 40 revision 53', - 'body' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png", - 'teaser' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png", + 'body' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\nFORUM-STICKY.PNG", + 'teaser' => "Attachments:\r\nforum-hot-new.png\r\nforum-hot.png\r\nforum-sticky.png\r\nforum-new.png\r\nFORUM-STICKY.PNG", 'log' => '', 'timestamp' => '1285709012', 'format' => '1', @@ -395,4 +406,13 @@ db_insert('upload')->fields(array( 'list' => '1', 'weight' => '-1', )) +// Test upgrading files with the same name but different case. +->values(array( + 'fid' => '11', + 'nid' => '40', + 'vid' => '53', + 'description' => 'FORUM-STICKY.PNG', + 'list' => '1', + 'weight' => '0', +)) ->execute(); diff --git modules/system/system.install modules/system/system.install index eb6d017..c51b17a 100644 --- modules/system/system.install +++ modules/system/system.install @@ -818,6 +818,7 @@ function system_schema() { 'length' => 255, 'not null' => TRUE, 'default' => '', + 'binary' => TRUE, ), 'filemime' => array( 'description' => "The file's MIME type.", @@ -2203,6 +2204,7 @@ function system_update_7034() { 'length' => 255, 'not null' => TRUE, 'default' => '', + 'binary' => TRUE, ), 'filemime' => array( 'description' => "The file's MIME type.", @@ -2973,6 +2975,23 @@ function system_update_7069() { } /** + * Apply binary collation to the file_managed.uri column. + */ +function system_update_7070() { + $spec = array( + 'description' => 'The URI to access the file (either local or remote).', + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + 'default' => '', + 'binary' => TRUE, + ); + db_drop_unique_key('file_managed', 'uri'); + db_change_field('file_managed', 'uri', 'uri', $spec, + array('unique keys' => array('uri' => array('uri')))); +} + +/** * @} End of "defgroup updates-6.x-to-7.x" * The next series of updates should start at 8000. */