Allow import of non-UTF-8 SQL files.

This commit is contained in:
Alexander M. Turek
2004-09-21 10:28:13 +00:00
parent 91b6f4c225
commit cfc06973fc
4 changed files with 30 additions and 5 deletions

View File

@@ -5,6 +5,11 @@ phpMyAdmin - Changelog
$Id$
$Source$
2004-09-21 Alexander M. Turek <me@derrabus.de>
* db_details.php, read_dump.php, tbl_query_box.php: Allow import of
non-UTF-8 SQL dumps. Thanks to Marc for the initial patch.
FIXME: The current solution breaks the display of the executed queries.
2004-09-20 Marc Delisle <lem9@users.sourceforge.net>
* read_dump.php, libraries/read_dump.lib.php: bug #1030644,
error importing when last table exported was empty

View File

@@ -183,7 +183,7 @@ if (!empty($cfg['UploadDir'])) {
} // end if (web-server upload directory)
// Charset conversion options
if ($is_upload || $is_upload_dir) {
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
if (PMA_MYSQL_INT_VERSION < 40100 && $cfg['AllowAnywhereRecoding'] && $allow_recoding) {
echo ' <tr bgcolor="' .$cfg['BgcolorTwo'] . '"><td>' . "\n";
$temp_charset = reset($cfg['AvailableCharsets']);
echo '&nbsp;' . $strCharsetOfFile . "\n"
@@ -204,6 +204,13 @@ if ($is_upload || $is_upload_dir) {
echo ' </td>' . "\n";
echo ' <td align="right"><input type="submit" name="SQL" value="' . $strGo . '" /></td>' . "\n";
echo ' </tr>' . "\n";
} elseif (PMA_MYSQL_INT_VERSION >= 40100) {
echo ' <tr bgcolor="' .$cfg['BgcolorTwo'] . '"><td>' . "\n"
. $strCharsetOfFile . "\n";
echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', NULL, FALSE);
echo ' </td>' . "\n";
echo ' <td align="right"><input type="submit" name="SQL" value="' . $strGo . '" /></td>' . "\n";
echo ' </tr>' . "\n";
}else{
echo ' <tr bgcolor="' . $cfg['BgcolorTwo'] . '"><td align="right" colspan="2"><input type="submit" name="SQL" value="' . $strGo . '" /></td></tr>' . "\n\n";
} // end if (recoding)

View File

@@ -121,9 +121,16 @@ if ($sql_file != 'none') {
}
// Convert the file's charset if necessary
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding
if (PMA_MYSQL_INT_VERSION < 40100
&& $cfg['AllowAnywhereRecoding'] && $allow_recoding
&& isset($charset_of_file) && $charset_of_file != $charset) {
$sql_query = PMA_convert_string($charset_of_file, $charset, $sql_query);
} else if (PMA_MYSQL_INT_VERSION >= 40100
&& isset($charset_of_file) && $charset_of_file != 'utf8') {
$sql_query = "SET NAMES '" . $charset_of_file . "';\n"
. $sql_query . "\n"
. "SET CHARACTER SET utf8;\n"
. "SET SESSION collation_connection ='" . $collation_connection . "';";
}
} // end uploaded file stuff
}
@@ -237,7 +244,6 @@ if ($sql_query != '') {
$save_bandwidth_pieces = $max_nofile_pieces;
}
}
// really run the query?
if ($view_bookmark == 0) {
// Only one query to run
@@ -270,7 +276,6 @@ if ($sql_query != '') {
$sql_query = $a_sql_query;
require('./sql.php');
}
$result = PMA_DBI_try_query($a_sql_query);
if ($result == FALSE) { // readdump failed
if (isset($my_die) && $cfg['IgnoreMultiSubmitErrors']) {

View File

@@ -374,7 +374,7 @@ if (($is_upload || $is_upload_dir) &&
echo ' </div>' . "\n";
} // end if (recoding)
*/
if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) {
if (PMA_MYSQL_INT_VERSION < 40100 && $cfg['AllowAnywhereRecoding'] && $allow_recoding) {
echo ' <tr bgcolor="' .$cfg['BgcolorTwo'] . '"><td' . $queryframe_thcolspan . '>' . "\n";
$temp_charset = reset($cfg['AvailableCharsets']);
echo '&nbsp;' . $strCharsetOfFile
@@ -395,6 +395,14 @@ if (($is_upload || $is_upload_dir) &&
echo ' </td>' . "\n";
echo ' </tr>' . "\n";
} // end if (recoding)
else if (PMA_MYSQL_INT_VERSION >= 40100) {
echo ' <tr bgcolor="' .$cfg['BgcolorTwo'] . '"><td>' . "\n"
. $strCharsetOfFile . "\n"
. PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', NULL, FALSE)
. ' </td>' . "\n"
. ' <td align="right"><input type="submit" name="SQL" value="' . $strGo . '" /></td>' . "\n"
. ' </tr>' . "\n";
}
echo ' <tr bgcolor="' . $cfg['BgcolorTwo'] . '">' . "\n"
. ' <td align="right"' . $queryframe_thcolspan . '><input type="submit" name="SQL" value="' . $strGo . '" /></td>' . "\n"
. ' </tr>' . "\n\n";