Handle correctly dumps with commented out commands (eg. from mysqldump).

This commit is contained in:
Michal Čihař
2005-12-25 21:43:27 +00:00
parent 898f0192db
commit ccee74104a
3 changed files with 24 additions and 11 deletions

View File

@@ -5,6 +5,10 @@ phpMyAdmin - Changelog
$Id$
$Source$
2005-12-25 Michal Čihař <michal@cihar.com>
* libraries/import.lib.php, libraries/import/sql.php: Handle correctly
dumps with commented out commands (eg. from mysqldump).
2005-12-22 Marc Delisle <lem9@users.sourceforge.net>
* tbl_change.php, libraries/common.lib.php: bug #1381856,
Cannot edit a table having 40 columns

View File

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

View File

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