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

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