Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xChangeLog4
-rw-r--r--libraries/read_dump.lib.php11
-rw-r--r--read_dump.php13
3 files changed, 21 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index ede5a99837..6d918a7ca2 100755
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/libraries/read_dump.lib.php b/libraries/read_dump.lib.php
index 56579fcae9..20f5a3b6c7 100644
--- a/libraries/read_dump.lib.php
+++ b/libraries/read_dump.lib.php
@@ -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;
diff --git a/read_dump.php b/read_dump.php
index 93e10be037..a7a27e2eac 100644
--- a/read_dump.php
+++ b/read_dump.php
@@ -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;