### Eclipse Workspace Patch 1.0
#P 18stable
Index: lib/setuplib.php
===================================================================
RCS file: /cvsroot/moodle/moodle/lib/setuplib.php,v
retrieving revision 1.19.2.4
diff -u -r1.19.2.4 setuplib.php
--- lib/setuplib.php	28 Mar 2007 17:13:17 -0000	1.19.2.4
+++ lib/setuplib.php	9 Nov 2007 06:49:16 -0000
@@ -159,20 +159,33 @@
     global $CFG, $db, $INSTALL;
 
     $unicodedb = false;
+    $needed_version = ''; //avoid PHP Eclipse variable initialization error 
     
     // Calculate $CFG->dbfamily
     $dbfamily = set_dbfamily();
 
     switch ($dbfamily) {
         case 'mysql':
+        $dbinfo = $db->ServerInfo();
+        $current_version = normalize_version($dbinfo['version']);
+        $needed_verstion = normalize_version('5.0.6');      
+         if (version_compare($current_version, $needed_version, '>=')) { //MySQL is 5.0.6 or greater
+            $rs = $db->Execute("SELECT DEFAULT_CHARACTER_SET_NAME FROM information_schema.SCHEMATA WHERE SCHEMA_NAME = '$CFG->dbname' LIMIT 1; ");
+            if ($rs && $rs->RecordCount() > 0) {
+                $records = $rs->GetAssoc(true);
+                $encoding = $records['DEFAULT_CHARACTER_SET_NAME']['Value'];
+            }     
+         }else { // MySQL is less than version 5.0.6 
             $rs = $db->Execute("SHOW VARIABLES LIKE 'character_set_database'");
             if ($rs && $rs->RecordCount() > 0) {
                 $records = $rs->GetAssoc(true);
                 $encoding = $records['character_set_database']['Value'];
-                if (strtoupper($encoding) == 'UTF8') {
-                    $unicodedb = true;
-                }
             }
+         }
+         if (strtoupper($encoding) == 'UTF8') {
+             $unicodedb = true;
+            }
+            
             break;
         case 'postgres':
         /// Get PostgreSQL server_encoding value
