diff --git a/ChangeLog b/ChangeLog index 046c01c10..6fa78042f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,8 @@ $HeadURL$ * many scripts: we were using "uva" in variables and function names, this was code suggested by University of Virginia; I improved the code by removing this uva prefix + * libraries/export/sql.php: patch #1595784, add charset information + to SQL export, thanks to Christian Schmidt 2006-12-07 Marc Delisle * libraries/ip_allow_deny.lib.php: checks that the header contains diff --git a/libraries/export/sql.php b/libraries/export/sql.php index b69782548..37c64eceb 100644 --- a/libraries/export/sql.php +++ b/libraries/export/sql.php @@ -149,6 +149,7 @@ function PMA_exportComment($text) function PMA_exportFooter() { global $crlf; + global $mysql_charset_map; $foot = ''; @@ -160,6 +161,15 @@ function PMA_exportFooter() $foot .= $crlf . 'COMMIT;' . $crlf; } + // restore connection settings + $charset_of_file = $GLOBALS['charset_of_file']; + if (!empty($GLOBALS['asfile']) && isset($mysql_charset_map[$charset_of_file])) { + $foot .= $crlf + . '/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;' . $crlf + . '/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;' . $crlf + . '/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;' . $crlf; + } + return PMA_exportOutputHandler($foot); } @@ -174,6 +184,7 @@ function PMA_exportHeader() { global $crlf; global $cfg; + global $mysql_charset_map; if (PMA_MYSQL_INT_VERSION >= 40100 && isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] != 'NONE') { PMA_DBI_try_query('SET SQL_MODE="' . $GLOBALS['sql_compatibility'] . '"'); @@ -215,6 +226,16 @@ function PMA_exportHeader() $head .= $crlf; + $charset_of_file = $GLOBALS['charset_of_file']; + if (!empty($GLOBALS['asfile']) && isset($mysql_charset_map[$charset_of_file])) { + $head .= $crlf + . '/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;' . $crlf + . '/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;' . $crlf + . '/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;' . $crlf + . '/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;' . $crlf + . '/*!40101 SET NAMES ' . $mysql_charset_map[$charset_of_file] . ' */;' . $crlf . $crlf; + } + return PMA_exportOutputHandler($head); }