From cfc06973fc28717c71d6f23693ab37b44bbf4161 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Tue, 21 Sep 2004 10:28:13 +0000 Subject: [PATCH] Allow import of non-UTF-8 SQL files. --- ChangeLog | 5 +++++ db_details.php | 9 ++++++++- read_dump.php | 11 ++++++++--- tbl_query_box.php | 10 +++++++++- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1e895fe35..8a0ecffe6 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-09-21 Alexander M. Turek + * 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 * read_dump.php, libraries/read_dump.lib.php: bug #1030644, error importing when last table exported was empty diff --git a/db_details.php b/db_details.php index 32ef6bc3e..6a928adf6 100644 --- a/db_details.php +++ b/db_details.php @@ -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 ' ' . "\n"; $temp_charset = reset($cfg['AvailableCharsets']); echo ' ' . $strCharsetOfFile . "\n" @@ -204,6 +204,13 @@ if ($is_upload || $is_upload_dir) { echo ' ' . "\n"; echo ' ' . "\n"; echo ' ' . "\n"; + } elseif (PMA_MYSQL_INT_VERSION >= 40100) { + echo ' ' . "\n" + . $strCharsetOfFile . "\n"; + echo PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', NULL, FALSE); + echo ' ' . "\n"; + echo ' ' . "\n"; + echo ' ' . "\n"; }else{ echo ' ' . "\n\n"; } // end if (recoding) diff --git a/read_dump.php b/read_dump.php index 5883bfa17..acbc20c3c 100644 --- a/read_dump.php +++ b/read_dump.php @@ -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']) { diff --git a/tbl_query_box.php b/tbl_query_box.php index 7ee34e061..10d49b1bd 100644 --- a/tbl_query_box.php +++ b/tbl_query_box.php @@ -374,7 +374,7 @@ if (($is_upload || $is_upload_dir) && echo ' ' . "\n"; } // end if (recoding) */ - if ($cfg['AllowAnywhereRecoding'] && $allow_recoding) { + if (PMA_MYSQL_INT_VERSION < 40100 && $cfg['AllowAnywhereRecoding'] && $allow_recoding) { echo ' ' . "\n"; $temp_charset = reset($cfg['AvailableCharsets']); echo ' ' . $strCharsetOfFile @@ -395,6 +395,14 @@ if (($is_upload || $is_upload_dir) && echo ' ' . "\n"; echo ' ' . "\n"; } // end if (recoding) + else if (PMA_MYSQL_INT_VERSION >= 40100) { + echo ' ' . "\n" + . $strCharsetOfFile . "\n" + . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_CHARSET, 'charset_of_file', NULL, FALSE) + . ' ' . "\n" + . ' ' . "\n" + . ' ' . "\n"; + } echo ' ' . "\n" . ' ' . "\n" . ' ' . "\n\n";