Index: includes/bootstrap.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/bootstrap.inc,v
retrieving revision 1.206.2.29
diff -u -p -r1.206.2.29 bootstrap.inc
--- includes/bootstrap.inc	6 Aug 2010 11:50:24 -0000	1.206.2.29
+++ includes/bootstrap.inc	14 Aug 2010 14:02:50 -0000
@@ -376,7 +376,7 @@ function conf_init() {
   global $base_url, $base_path, $base_root;
 
   // Export the following settings.php variables to the global namespace
-  global $db_url, $db_prefix, $cookie_domain, $conf, $installed_profile, $update_free_access;
+  global $db_url, $db_prefix, $db_collation, $cookie_domain, $conf, $installed_profile, $update_free_access;
   $conf = array();
 
   if (isset($_SERVER['HTTP_HOST'])) {
Index: includes/database.mysql-common.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.mysql-common.inc,v
retrieving revision 1.17.2.4
diff -u -p -r1.17.2.4 database.mysql-common.inc
--- includes/database.mysql-common.inc	1 Mar 2010 10:37:30 -0000	1.17.2.4
+++ includes/database.mysql-common.inc	14 Aug 2010 13:24:29 -0000
@@ -60,7 +60,16 @@ function db_query($query) {
 function db_create_table_sql($name, $table) {
 
   if (empty($table['mysql_suffix'])) {
-    $table['mysql_suffix'] = "/*!40100 DEFAULT CHARACTER SET UTF8 */";
+    $table['mysql_suffix'] = '/*!40100 DEFAULT CHARACTER SET utf8';
+    // By default, MySQL uses the default collation for new tables, which is
+    // 'utf8_general_ci' for utf8. If an alternate collation has been set, it
+    // needs to be explicitly specified.
+    // @see db_connect()
+    $collation = (!empty($table['collation']) ? $table['collation'] : (!empty($GLOBALS['db_collation']) ? $GLOBALS['db_collation'] : ''));
+    if ($collation) {
+      $table['mysql_suffix'] .= ' COLLATE ' . $collation;
+    }
+    $table['mysql_suffix'] .= ' */';
   }
 
   $sql = "CREATE TABLE {". $name ."} (\n";
Index: includes/database.mysql.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.mysql.inc,v
retrieving revision 1.89.2.2
diff -u -p -r1.89.2.2 database.mysql.inc
--- includes/database.mysql.inc	1 Feb 2010 16:32:10 -0000	1.89.2.2
+++ includes/database.mysql.inc	14 Aug 2010 13:35:09 -0000
@@ -80,8 +80,16 @@ function db_connect($url) {
     _db_error_page(mysql_error());
   }
 
-  // Force UTF-8.
-  mysql_query('SET NAMES "utf8"', $connection);
+  // Force MySQL to use the UTF-8 character set. Also set the collation, if a
+  // certain one has been set; otherwise, MySQL defaults to 'utf8_general_ci'
+  // for UTF-8.
+  if (!empty($GLOBALS['db_collation'])) {
+    mysql_query('SET NAMES utf8 COLLATE '. $GLOBALS['db_collation'], $connection);
+  }
+  else {
+    mysql_query('SET NAMES utf8', $connection);
+  }
+
   return $connection;
 }
 
Index: includes/database.mysqli.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/Attic/database.mysqli.inc,v
retrieving revision 1.54.2.2
diff -u -p -r1.54.2.2 database.mysqli.inc
--- includes/database.mysqli.inc	1 Feb 2010 16:32:10 -0000	1.54.2.2
+++ includes/database.mysqli.inc	14 Aug 2010 13:35:17 -0000
@@ -79,8 +79,15 @@ function db_connect($url) {
     _db_error_page(mysqli_connect_error());
   }
 
-  // Force UTF-8.
-  mysqli_query($connection, 'SET NAMES "utf8"');
+  // Force MySQL to use the UTF-8 character set. Also set the collation, if a
+  // certain one has been set; otherwise, MySQL defaults to 'utf8_general_ci'
+  // for UTF-8.
+  if (!empty($GLOBALS['db_collation'])) {
+    mysqli_query($connection, 'SET NAMES utf8 COLLATE ' . $GLOBALS['db_collation']);
+  }
+  else {
+    mysqli_query($connection, 'SET NAMES utf8');
+  }
 
   return $connection;
 }
Index: sites/default/default.settings.php
===================================================================
RCS file: /cvs/drupal/drupal/sites/default/default.settings.php,v
retrieving revision 1.8.2.4
diff -u -p -r1.8.2.4 default.settings.php
--- sites/default/default.settings.php	14 Sep 2009 12:59:18 -0000	1.8.2.4
+++ sites/default/default.settings.php	14 Aug 2010 13:36:20 -0000
@@ -93,6 +93,26 @@ $db_url = 'mysql://username:password@loc
 $db_prefix = '';
 
 /**
+ * Database default collation.
+ *
+ * All data stored in Drupal is in UTF-8. Certain databases, such as MySQL,
+ * support different algorithms for comparing, indexing, and sorting characters;
+ * a so called "collation". The default collation of a database normally works
+ * for many use-cases, but depending on the language(s) of the stored data, it
+ * may be necessary to use a different collation.
+ * Important:
+ * - Only set or change this value BEFORE installing Drupal, unless you know
+ *   what you are doing.
+ * - All database tables and columns should be in the same collation. Otherwise,
+ *   string comparisons performed for table JOINs will be significantly slower.
+ * - Especially when storing data in German or Russian on MySQL 5.1+, you want
+ *   to use the 'utf8_unicode_ci' collation instead.
+ *
+ * @see http://drupal.org/node/772678
+ */
+# $db_collation = 'utf8_general_ci';
+
+/**
  * Access control for update.php script
  *
  * If you are updating your Drupal installation using the update.php script
