From 810602ec9837edb28845316ea99293f22a1b4460 Mon Sep 17 00:00:00 2001
From: sun <sun@unleashedmind.com>
Date: Sat, 26 May 2012 02:51:56 +0200
Subject: [PATCH] - #1224316 by sun: Fixed Custom collations in column
 definitions break the database dump entirely (files table
 uses utf8_bin since Drupal 7.14).

---
 database_mysql_dump.inc |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/database_mysql_dump.inc b/database_mysql_dump.inc
index 60b4a0e..369f00c 100644
--- a/database_mysql_dump.inc
+++ b/database_mysql_dump.inc
@@ -165,9 +165,9 @@ function _demo_dump_table_schema($fp, $table) {
       $collate = 'COLLATE=' . $status['collation'];
     }
     // If there is a character set defined already, just append the collation.
-    if (strpos($output, 'CHARSET') || strpos($output, 'CHARACTER SET')) {
-      // @todo This may also hit column definitions instead of the table
-      //   definition only. Should technically also be case-insensitive.
+    // Only look for the table definition (on the last line); column definitions
+    // may use a special collation, which must not be changed.
+    if (preg_match('@^\).+(?:CHARSET|CHARACTER SET)@m', $output)) {
       $output = preg_replace('@((?:DEFAULT )?(?:CHARSET|CHARACTER SET) \w+)@', '$1 ' . $collate, $output);
     }
     else {
-- 
1.7.6.msysgit.0

