Index: update.php
===================================================================
RCS file: /cvs/drupal/drupal/update.php,v
retrieving revision 1.169
diff -u -F^f -r1.169 update.php
--- update.php	4 Jan 2006 09:27:51 -0000	1.169
+++ update.php	6 Jan 2006 06:01:55 -0000
@@ -276,7 +276,7 @@ function update_fix_watchdog() {
 function update_data($module, $number) {
   $ret = module_invoke($module, 'update_'. $number);
   // Assume the update finished unless the update results indicate otherwise.
-  $finished = TRUE;
+  $finished = 1;
   if (isset($ret['#finished'])) {
     $finished = $ret['#finished'];
     unset($ret['#finished']);
@@ -294,7 +294,7 @@ function update_data($module, $number) {
   }
   $_SESSION['update_results'][$module][$number] = array_merge($_SESSION['update_results'][$module][$number], $ret);
 
-  if ($finished) {
+  if ($finished == 1) {
     // Update the installed version
     drupal_set_installed_schema_version($module, $number);
   }
@@ -312,7 +312,7 @@ function update_selection_page() {
     '#type' => 'fieldset',
     '#title' => 'Select versions',
     '#collapsible' => TRUE,
-    '#collapsed' => TRUE,
+    '#collapsed' => TRUE
   );
   foreach (module_list() as $module) {
     $updates = drupal_get_schema_versions($module);
@@ -324,7 +324,7 @@ function update_selection_page() {
         '#type' => 'select',
         '#title' => $module . ' module',
         '#default_value' => array_search(drupal_get_installed_schema_version($module), $updates) + 1,
-        '#options' => $updates,
+        '#options' => $updates
       );
     }
   }
@@ -389,9 +389,10 @@ function update_progress_page() {
 function update_do_updates() {
   while (($update = reset($_SESSION['update_remaining']))) {
     $update_finished = update_data($update['module'], $update['version']);
-    if ($update_finished) {
+    if ($update_finished == 1) {
       // Dequeue the completed update.
       unset($_SESSION['update_remaining'][key($_SESSION['update_remaining'])]);
+      $update_finished = 0; // Make sure this step isn't counted double
     }
     if (timer_read('page') > 1000) {
       break;
@@ -399,7 +400,7 @@ function update_do_updates() {
   }
 
   if ($_SESSION['update_total']) {
-    $percent = floor(($_SESSION['update_total'] - count($_SESSION['update_remaining'])) / $_SESSION['update_total'] * 100);
+    $percent = floor(($_SESSION['update_total'] - count($_SESSION['update_remaining']) + $update_finished) / $_SESSION['update_total'] * 100);
   }
   else {
     $percent = 100;
Index: database/database.mysql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.mysql,v
retrieving revision 1.214
diff -u -F^f -r1.214 database.mysql
--- database/database.mysql	4 Jan 2006 09:17:02 -0000	1.214
+++ database/database.mysql	6 Jan 2006 06:01:56 -0000
@@ -1,19 +1,14 @@
--- MySQL dump 8.22
---
--- Host: localhost    Database: drupal_devel
--- Server version  3.23.52-nt
-
 --
 -- Table structure for table 'access'
 --
-
 CREATE TABLE access (
   aid tinyint(10) NOT NULL auto_increment,
   mask varchar(255) NOT NULL default '',
   type varchar(255) NOT NULL default '',
   status tinyint(2) NOT NULL default '0',
   PRIMARY KEY (aid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'accesslog'
@@ -31,7 +26,8 @@
   timestamp int(11) unsigned NOT NULL default '0',
   KEY accesslog_timestamp (timestamp),
   PRIMARY KEY (aid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'aggregator_category'
@@ -44,7 +40,8 @@
   block tinyint(2) NOT NULL default '0',
   PRIMARY KEY (cid),
   UNIQUE KEY title (title)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'aggregator_category_feed'
@@ -54,7 +51,8 @@
   fid int(10) NOT NULL default '0',
   cid int(10) NOT NULL default '0',
   PRIMARY KEY (fid,cid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'aggregator_category_item'
@@ -64,7 +62,8 @@
   iid int(10) NOT NULL default '0',
   cid int(10) NOT NULL default '0',
   PRIMARY KEY (iid,cid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'aggregator_feed'
@@ -85,7 +84,8 @@
   PRIMARY KEY (fid),
   UNIQUE KEY link (url),
   UNIQUE KEY title (title)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'aggregator_item'
@@ -100,7 +100,8 @@
   description longtext NOT NULL,
   timestamp int(11) default NULL,
   PRIMARY KEY (iid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'authmap'
@@ -113,7 +114,8 @@
   module varchar(128) NOT NULL default '',
   PRIMARY KEY (aid),
   UNIQUE KEY authname (authname)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'blocks'
@@ -130,7 +132,8 @@
   throttle tinyint(1) DEFAULT '0' NOT NULL,
   visibility tinyint(1) DEFAULT '0' NOT NULL,
   pages text DEFAULT '' NOT NULL
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'book'
@@ -144,7 +147,8 @@
   PRIMARY KEY (vid),
   KEY nid (nid),
   KEY parent (parent)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'boxes'
@@ -158,7 +162,8 @@
   format int(4) NOT NULL default '0',
   PRIMARY KEY (bid),
   UNIQUE KEY info (info)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'cache'
@@ -172,7 +177,8 @@
   headers text,
   PRIMARY KEY (cid),
   INDEX expire (expire)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'comments'
@@ -197,7 +203,8 @@
   homepage varchar(255) default NULL,
   PRIMARY KEY (cid),
   KEY lid (nid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structre for table 'contact'
@@ -212,7 +219,8 @@
   selected tinyint(1) NOT NULL default '0',
   PRIMARY KEY (cid),
   UNIQUE KEY category (category)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structre for table 'node_comment_statistics'
@@ -226,7 +234,8 @@
   comment_count int(10) unsigned NOT NULL default '0',
   PRIMARY KEY (nid),
   KEY node_comment_timestamp (last_comment_timestamp)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'client'
@@ -245,7 +254,8 @@
   created int(11) NOT NULL default '0',
   changed int(11) NOT NULL default '0',
   PRIMARY KEY (cid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'client_system'
@@ -256,7 +266,8 @@
   name varchar(255) NOT NULL default '',
   type varchar(255) NOT NULL default '',
   PRIMARY KEY (cid,name)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'files'
@@ -274,7 +285,8 @@
   list tinyint(1) unsigned NOT NULL default '0',
   KEY vid (vid),
   KEY fid (fid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'filter_formats'
@@ -286,7 +298,8 @@
   roles varchar(255) NOT NULL default '',
   cache tinyint(2) NOT NULL default '0',
   PRIMARY KEY (format)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'filters'
@@ -298,7 +311,8 @@
   delta tinyint(2) DEFAULT '0' NOT NULL,
   weight tinyint(2) DEFAULT '0' NOT NULL,
   INDEX (weight)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'flood'
@@ -308,7 +322,8 @@
   event varchar(64) NOT NULL default '',
   hostname varchar(128) NOT NULL default '',
   timestamp int(11) NOT NULL default '0'
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'forum'
@@ -321,7 +336,8 @@
   PRIMARY KEY (nid),
   KEY vid (vid),
   KEY tid (tid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'history'
@@ -332,7 +348,8 @@
   nid int(10) NOT NULL default '0',
   timestamp int(11) NOT NULL default '0',
   PRIMARY KEY (uid,nid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'locales_meta'
@@ -346,7 +363,8 @@
   plurals int(1) NOT NULL default '0',
   formula varchar(128) NOT NULL default '',
   PRIMARY KEY (locale)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'locales_source'
@@ -357,7 +375,8 @@
   location varchar(255) NOT NULL default '',
   source blob NOT NULL,
   PRIMARY KEY (lid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'locales_target'
@@ -373,7 +392,8 @@
   KEY lang (locale),
   KEY plid (plid),
   KEY plural (plural)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'menu'
@@ -388,7 +408,8 @@
   weight tinyint(4) NOT NULL default '0',
   type int(2) unsigned NOT NULL default '0',
   PRIMARY KEY (mid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'moderation_filters'
@@ -399,7 +420,8 @@
   filter varchar(255) NOT NULL default '',
   minimum smallint(6) NOT NULL default '0',
   PRIMARY KEY (fid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'moderation_roles'
@@ -411,7 +433,8 @@
   value tinyint(4) NOT NULL default '0',
   KEY idx_rid (rid),
   KEY idx_mid (mid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'moderation_votes'
@@ -422,7 +445,8 @@
   vote varchar(255) default NULL,
   weight tinyint(4) NOT NULL default '0',
   PRIMARY KEY (mid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'node'
@@ -452,7 +476,8 @@
   KEY node_created (created),
   KEY node_changed (changed),
   KEY node_status_type (status, type, nid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table `node_access`
@@ -466,7 +491,8 @@
   grant_update tinyint(1) unsigned NOT NULL default '0',
   grant_delete tinyint(1) unsigned NOT NULL default '0',
   PRIMARY KEY (nid,gid,realm)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'node_revisions'
@@ -484,7 +510,8 @@
   format int(4) NOT NULL default '0',
   PRIMARY KEY  (nid,vid),
   KEY uid (uid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'profile_fields'
@@ -506,7 +533,8 @@
   KEY category (category),
   UNIQUE KEY name (name),
   PRIMARY KEY (fid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'profile_values'
@@ -518,7 +546,8 @@
   value text,
   KEY uid (uid),
   KEY fid (fid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 
 --
@@ -532,7 +561,8 @@
   PRIMARY KEY (pid),
   UNIQUE KEY dst (dst),
   KEY src (src)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'permission'
@@ -543,7 +573,8 @@
   perm longtext,
   tid int(10) unsigned NOT NULL default '0',
   KEY rid (rid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'poll'
@@ -554,7 +585,8 @@
   runtime int(10) NOT NULL default '0',
   active int(2) unsigned NOT NULL default '0',
   PRIMARY KEY (nid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'poll_votes'
@@ -567,7 +599,8 @@
   INDEX (nid),
   INDEX (uid),
   INDEX (hostname)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'poll_choices'
@@ -581,7 +614,8 @@
   chorder int(2) NOT NULL default '0',
   PRIMARY KEY (chid),
   KEY nid (nid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'role'
@@ -592,7 +626,8 @@
   name varchar(32) NOT NULL default '',
   PRIMARY KEY (rid),
   UNIQUE KEY name (name)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'search_dataset'
@@ -602,7 +637,8 @@
   type varchar(16) default NULL,
   data longtext NOT NULL,
   KEY sid_type (sid, type)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'search_index'
@@ -618,7 +654,8 @@
   KEY sid_type (sid, type),
   KEY from_sid_type (fromsid, fromtype),
   KEY word (word)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'search_total'
@@ -628,7 +665,8 @@
   word varchar(50) NOT NULL default '',
   count float default NULL,
   PRIMARY KEY (word)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'sessions'
@@ -645,7 +683,8 @@
   KEY uid (uid),
   PRIMARY KEY (sid),
   KEY timestamp (timestamp)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'sequences'
@@ -655,7 +694,8 @@
   name varchar(255) NOT NULL default '',
   id int(10) unsigned NOT NULL default '0',
   PRIMARY KEY (name)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'node_counter'
@@ -670,7 +710,8 @@
   KEY totalcount (totalcount),
   KEY daycount (daycount),
   KEY timestamp (timestamp)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'system'
@@ -686,7 +727,8 @@
   bootstrap int(2) NOT NULL default '0',
   schema_version smallint(2) unsigned NOT NULL default 0,
   PRIMARY KEY (filename)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'term_data'
@@ -700,7 +742,8 @@
   weight tinyint(4) NOT NULL default '0',
   PRIMARY KEY (tid),
   KEY vid (vid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'term_hierarchy'
@@ -711,7 +754,8 @@
   parent int(10) unsigned NOT NULL default '0',
   KEY tid (tid),
   KEY parent (parent)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'term_node'
@@ -723,7 +767,8 @@
   KEY nid (nid),
   KEY tid (tid),
   PRIMARY KEY (tid,nid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'term_relation'
@@ -734,7 +779,8 @@
   tid2 int(10) unsigned NOT NULL default '0',
   KEY tid1 (tid1),
   KEY tid2 (tid2)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'term_synonym'
@@ -745,7 +791,8 @@
   name varchar(255) NOT NULL default '',
   KEY tid (tid),
   KEY name (name(3))
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'users'
@@ -773,7 +820,8 @@
   PRIMARY KEY (uid),
   UNIQUE KEY name (name),
   KEY access (access)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'users_roles'
@@ -783,7 +831,8 @@
   uid int(10) unsigned NOT NULL default '0',
   rid int(10) unsigned NOT NULL default '0',
   PRIMARY KEY (uid, rid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'variable'
@@ -793,7 +842,8 @@
   name varchar(48) NOT NULL default '',
   value longtext NOT NULL,
   PRIMARY KEY (name)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'vocabulary'
@@ -812,7 +862,8 @@
   module varchar(255) NOT NULL default '',
   weight tinyint(4) NOT NULL default '0',
   PRIMARY KEY (vid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'vocabulary_node_types'
@@ -822,7 +873,8 @@
   vid int(10) unsigned NOT NULL DEFAULT '0',
   type varchar(16) NOT NULL DEFAULT '',
   PRIMARY KEY (vid, type)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Table structure for table 'watchdog'
@@ -840,7 +892,8 @@
   hostname varchar(128) NOT NULL default '',
   timestamp int(11) NOT NULL default '0',
   PRIMARY KEY (wid)
-) TYPE=MyISAM;
+) TYPE=MyISAM
+/*!40100 DEFAULT CHARACTER SET utf8 */ ;
 
 --
 -- Insert some default values
@@ -894,3 +947,4 @@
 INSERT INTO menu VALUES (2, 0, '', 'Primary links', '', 0, 115);
 INSERT INTO variable VALUES ('menu_primary_menu', 'i:2;');
 INSERT INTO variable VALUES ('menu_secondary_menu', 'i:2;');
+
Index: database/updates.inc
===================================================================
RCS file: /cvs/drupal/drupal/database/updates.inc,v
retrieving revision 1.175
diff -u -F^f -r1.175 updates.inc
--- database/updates.inc	6 Jan 2006 03:08:52 -0000	1.175
+++ database/updates.inc	6 Jan 2006 06:02:00 -0000
@@ -1397,3 +1397,106 @@ function system_update_166() {
 
   return $ret;
 }
+
+
+function system_update_167() {
+  // Are we starting this update for the first time?
+  if (!isset($_SESSION['update_167'])) {
+    // Only for MySQL 4.1+
+    switch ($GLOBALS['db_type']) {
+      case 'mysqli':
+        break;
+      case 'mysql':
+        if (version_compare(mysql_get_server_info($GLOBALS['active_db']), '4.1.0', '<')) {
+          return array();
+        }
+        break;
+      case 'pgsql':
+        return array();
+    }
+
+    // See if database uses UTF-8 already
+    $url = parse_url($GLOBALS['db_url']);
+    $db_name = substr($url['path'], 1);
+    $create = array_pop(db_fetch_array(db_query('SHOW CREATE DATABASE `%s`', $db_name)));
+    if (preg_match('/utf8/i', $create)) {
+      return array();
+    }
+
+    // Make list of tables to convert
+    $_SESSION['update_167'] = array('access', 'accesslog', 'aggregator_category',
+                  'aggregator_category_feed', 'aggregator_category_item',
+                  'aggregator_feed', 'aggregator_item', 'authmap', 'blocks',
+                  'book', 'boxes', 'cache', 'comments', 'contact',
+                  'node_comment_statistics', 'client', 'client_system', 'files',
+                  'filter_formats', 'filters', 'flood', 'forum', 'history',
+                  'locales_meta', 'locales_source', 'locales_target', 'menu',
+                  'moderation_filters', 'moderation_roles', 'moderation_votes',
+                  'node', 'node_access', 'node_revisions', 'profile_fields',
+                  'profile_values', 'url_alias', 'permission', 'poll', 'poll_votes',
+                  'poll_choices', 'role', 'search_dataset', 'search_index',
+                  'search_total', 'sessions', 'sequences', 'node_counter',
+                  'system', 'term_data', 'term_hierarchy', 'term_node',
+                  'term_relation', 'term_synonym', 'users', 'users_roles', 'variable',
+                  'vocabulary', 'vocabulary_node_types', 'watchdog');
+    // Keep track of total for progress bar
+    $_SESSION['update_167_total'] = count($_SESSION['update_167']);
+  }
+  $list = &$_SESSION['update_167'];
+  $ret = array();
+
+  // Convert tables to UTF-8
+  // See: http://dev.mysql.com/doc/refman/4.1/en/charset-conversion.html
+  $types = array('char' => 'binary',
+                 'varchar' => 'varbinary',
+                 'tinytext' => 'tinyblob',
+                 'text' => 'blob',
+                 'mediumtext' => 'mediumblob',
+                 'longtext' => 'longblob');
+  foreach ($list as $key => $table) {
+    $convert_to_binary = array();
+    $convert_to_utf8 = array();
+
+    // Set table default charset
+    $ret[] = update_sql("ALTER TABLE \{$table} DEFAULT CHARACTER SET utf8");
+
+    // Find out which columns need converting and build SQL statements
+    $result = db_query("SHOW FULL COLUMNS FROM \{$table}");
+    while ($column = db_fetch_array($result)) {
+      list($type) = explode('(', $column['Type']);
+      if (isset($types[$type])) {
+        $names = 'CHANGE `'. $column['Field'] .'` `'. $column['Field'] .'` ';
+        $attributes = ' DEFAULT '. ($column['Default'] == 'NULL' ? 'NULL ' : "'". db_escape_string($column['Default']) ."' ").
+                      ($column['Null'] == 'YES' ? 'NULL' : 'NOT NULL');
+        
+        $convert_to_binary[] = $names . preg_replace('/'. $type .'/i', $types[$type], $column['Type']) . $attributes;
+        $convert_to_utf8[] = $names . $column['Type'] .' CHARACTER SET utf8'. $attributes;
+      }
+    }
+
+    if (count($convert_to_binary)) {
+      // Convert text columns to binary
+      $ret[] = update_sql("ALTER TABLE \{$table} ". implode(', ', $convert_to_binary));
+      // Convert binary columns to UTF-8
+      $ret[] = update_sql("ALTER TABLE \{$table} ". implode(', ', $convert_to_utf8));      
+    }
+
+    // Done
+    unset($list[$key]);
+    if (timer_read('page') > 1000) {
+      break;
+    }
+  }
+
+  // Are we done?
+  if (count($list) == 0) {
+    unset($_SESSION['update_167']);
+    unset($_SESSION['update_167_total']);
+    return $ret;
+  }
+
+  // Progress percentage
+  $ret['#finished'] = 1 - (count($list) / $_SESSION['update_167_total']);
+  drupal_set_message($ret['#finished']);
+  return $ret;
+}
Index: includes/database.mysql.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database.mysql.inc,v
retrieving revision 1.47
diff -u -F^f -r1.47 database.mysql.inc
--- includes/database.mysql.inc	10 Dec 2005 19:26:47 -0000	1.47
+++ includes/database.mysql.inc	6 Jan 2006 06:02:03 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: database.mysql.inc,v 1.47 2005/12/10 19:26:47 dries Exp $
+// $Id: database.mysql.inc,v 1.47 2005-12-10 19:26:47 dries Exp $
 
 /**
  * @file
@@ -62,7 +62,7 @@ function db_connect($url) {
   if (!mysql_select_db(substr($url['path'], 1))) {
     drupal_maintenance_theme();
     drupal_set_title('Unable to select database');
-    print theme('maintenance_page', '<p>We were able to connect to the MySQL database server (which means your username and password is okay) but not able to select the database.</p>
+    print theme('maintenance_page', '<p>We were able to connect to the MySQL database server (which means your username and password are okay) but not able to select the database.</p>
 <p>The MySQL error was: '. theme('placeholder', mysql_error($connection)) .'.</p>
 <p>Currently, the database is '. theme('placeholder', substr($url['path'], 1)) .'. The username is '. theme('placeholder', $url['user']) .' and the database server is '. theme('placeholder', $url['host']) .'.</p>
 <ul>
@@ -74,6 +74,16 @@ function db_connect($url) {
     exit;
   }
 
+  /* On MySQL 4.1 and later, force UTF-8 */
+  if (version_compare(mysql_get_server_info(), '4.1.0', '>=')) {
+    mysql_query('SET NAMES "utf8"', $connection);
+    mysql_query('SET collation_connection="utf8_general_ci"', $connection);
+    mysql_query('SET collation_server="utf8_general_ci"', $connection);
+    mysql_query('SET character_set_client="utf8"', $connection);
+    mysql_query('SET character_set_connection="utf8"', $connection);
+    mysql_query('SET character_set_results="utf8"', $connection);
+    mysql_query('SET character_set_server="utf8"', $connection);
+  }
   return $connection;
 }
 
Index: includes/database.mysqli.inc
===================================================================
RCS file: /cvs/drupal/drupal/includes/database.mysqli.inc,v
retrieving revision 1.10
diff -u -F^f -r1.10 database.mysqli.inc
--- includes/database.mysqli.inc	10 Dec 2005 19:26:47 -0000	1.10
+++ includes/database.mysqli.inc	6 Jan 2006 06:02:03 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: database.mysqli.inc,v 1.10 2005/12/10 19:26:47 dries Exp $
+// $Id: database.mysqli.inc,v 1.10 2005-12-10 19:26:47 dries Exp $
 
 /**
  * @file
@@ -71,6 +71,14 @@ function db_connect($url) {
     exit;
   }
 
+  /* Force UTF-8 */
+  mysqli_query($connection, 'SET NAMES "utf8"');
+  mysqli_query($connection, 'SET collation_connection="utf8_general_ci"');
+  mysqli_query($connection, 'SET collation_server="utf8_general_ci"');
+  mysqli_query($connection, 'SET character_set_client="utf8"');
+  mysqli_query($connection, 'SET character_set_connection="utf8"');
+  mysqli_query($connection, 'SET character_set_results="utf8"');
+  mysqli_query($connection, 'SET character_set_server="utf8"');
 
   /**
    * from: http://bugs.php.net/bug.php?id=33772
