diff --git a/ChangeLog b/ChangeLog index 6a6266157..5e389b4d9 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,10 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-12-25 Michal Čihař + * libraries/import.lib.php, libraries/import/sql.php: Handle correctly + dumps with commented out commands (eg. from mysqldump). + 2005-12-22 Marc Delisle * tbl_change.php, libraries/common.lib.php: bug #1381856, Cannot edit a table having 40 columns diff --git a/libraries/import.lib.php b/libraries/import.lib.php index 683a40253..9d91dda81 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -168,7 +168,7 @@ function PMA_importRunQuery($sql = '', $full = '') { if (!empty($sql) || !empty($full)) { $import_run_buffer = array('sql' => $sql, 'full' => $full); } else { - unset($import_run_buffer); + unset($GLOBALS['import_run_buffer']); } } diff --git a/libraries/import/sql.php b/libraries/import/sql.php index 34f594e38..337674cc7 100644 --- a/libraries/import/sql.php +++ b/libraries/import/sql.php @@ -139,22 +139,31 @@ if (isset($plugin_list)) { // End of SQL if ($ch == ';' || ($finished && ($i == $len - 1))) { + $tmp_sql = $sql; if ($start_pos < $len) { - $sql .= substr($buffer, $start_pos, $i - $start_pos + 1); + $tmp_sql .= substr($buffer, $start_pos, $i - $start_pos + 1); + } + // Do not try to execute empty SQL + if (!preg_match('/^([\s]*;)*$/', trim($tmp_sql))) { + $sql = $tmp_sql; + PMA_importRunQuery($sql, substr($buffer, 0, $i + 1)); + $buffer = substr($buffer, $i + 1); + // Reset parser: + $len = strlen($buffer); + $sql = ''; + $i = 0; + $start_pos = 0; + // Any chance we will get a complete query? + if ((strpos($buffer, ';') === FALSE) && !$finished) break; + } else { + $i++; + $start_pos = $i; } - PMA_importRunQuery($sql, substr($buffer, 0, $i + 1)); - $buffer = substr($buffer, $i + 1); - // Reset parser: - $len = strlen($buffer); - $sql = ''; - $i = 0; - $start_pos = 0; - // Any chance we will get a complete query? - if ((strpos($buffer, ';') === FALSE) && !$finished) break; } } // End of parser loop } // End of import loop // Commit any possible data in buffers + PMA_importRunQuery('', substr($buffer, 0, $len)); PMA_importRunQuery(); } ?>