patch #1595784, add charset information to SQL exported file

This commit is contained in:
Marc Delisle
2006-12-10 12:56:12 +00:00
parent d01f9977fb
commit 6a4e2a1164
2 changed files with 23 additions and 0 deletions

View File

@@ -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 <lem9@users.sourceforge.net>
* libraries/ip_allow_deny.lib.php: checks that the header contains

View File

@@ -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);
}