Show last SELECT result also when there are comments behind last query.

This commit is contained in:
Michal Čihař
2004-06-24 13:02:23 +00:00
parent de04757024
commit b00dbf08f5
3 changed files with 21 additions and 7 deletions

View File

@@ -22,7 +22,9 @@ $Source$
otherwise unmatched quotes cause problems (bug #978113).
* libraries/common.lib.php: Use read_dump.php instead of sql.php for
links, otherwise we'll fail on commas.
* read_dump.php, libraries/read_dump.lib.php: Show last SELECT result also
when there are comments behind last query.
2004-06-23 Marc Delisle <lem9@users.sourceforge.net>
* many files: remove references to older /images, and
erase /images contents

View File

@@ -23,6 +23,7 @@ function PMA_splitSqlFile(&$ret, $sql, $release)
$char = '';
$string_start = '';
$in_string = FALSE;
$nothing = TRUE;
$time0 = time();
for ($i = 0; $i < $sql_len; ++$i) {
@@ -83,7 +84,8 @@ function PMA_splitSqlFile(&$ret, $sql, $release)
// We are not in a string, first check for delimiter...
else if ($char == ';') {
// if delimiter found, add the parsed part to the returned array
$ret[] = substr($sql, 0, $i);
$ret[] = array('query' => substr($sql, 0, $i), 'empty' => $nothing);
$nothing = TRUE;
$sql = ltrim(substr($sql, min($i + 1, $sql_len)));
$sql_len = strlen($sql);
if ($sql_len) {
@@ -97,9 +99,14 @@ function PMA_splitSqlFile(&$ret, $sql, $release)
// ... then check for start of a string,...
else if (($char == '"') || ($char == '\'') || ($char == '`')) {
$in_string = TRUE;
$nothing = FALSE;
$string_start = $char;
} // end else if (is start of string)
elseif ($nothing) {
$nothing = FALSE;
}
// loic1: send a fake header each 30 sec. to bypass browser timeout
$time1 = time();
if ($time1 >= $time0 + 30) {
@@ -110,7 +117,7 @@ function PMA_splitSqlFile(&$ret, $sql, $release)
// add any rest to the returned array
if (!empty($sql) && preg_match('@[^[:space:]]+@', $sql)) {
$ret[] = $sql;
$ret[] = array('query' => $sql, 'empty' => $nothing);
}
return TRUE;

View File

@@ -223,7 +223,7 @@ if ($sql_query != '') {
$save_bandwidth_pieces = $max_file_pieces;
} else {
$sql_query_cpy = implode(";\n", $pieces) . ';';
$sql_query_cpy = $sql_query;
// Be nice with bandwidth... for now, an arbitrary limit of 500,
// could be made configurable but probably not necessary
if (($max_nofile_length != 0 && (strlen($sql_query_cpy) > $max_nofile_length))
@@ -252,9 +252,14 @@ if ($sql_query != '') {
$info_msg = '';
$info_count = 0;
for ($i = 0; $i < $pieces_count; $i++) {
$a_sql_query = $pieces[$i];
if ($i == $pieces_count - 1 && preg_match('@^(SELECT|SHOW)@i', $a_sql_query)) {
// just skip last empty query (can contain just comments at the end)
$count = $pieces_count;
if ($pieces[$count - 1]['empty']) $count--;
for ($i = 0; $i < $count; $i++) {
$a_sql_query = $pieces[$i]['query'];
if ($i == $count - 1 && preg_match('@^(SELECT|SHOW)@i', $a_sql_query)) {
$complete_query = $sql_query;
$display_query = $sql_query;
$sql_query = $a_sql_query;