diff --git a/ChangeLog b/ChangeLog index 73168a846..865b03846 100755 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,8 @@ $Source$ * read_dump.php: Fix handling of comments -- and # (bug #1009494). * libraries/relation.lib.php: Fix typo, CONVERT is for MySQL >= 4.1 and not for MySQL >= 4.0. + * sql.php, libraries/common.lib.php: Better appending of LIMIT (bug + #978930). 2004-08-15 Marc Delisle (Patches from Michael Keck) diff --git a/libraries/common.lib.php b/libraries/common.lib.php index 5f5715a2c..d1c4eaf87 100644 --- a/libraries/common.lib.php +++ b/libraries/common.lib.php @@ -1706,17 +1706,6 @@ if (typeof(document.getElementById) != 'undefined' echo ' ' . $GLOBALS['strSQLQuery'] . ': '; echo '
' . "\n"; echo ' ' . $query_base; - // If a 'LIMIT' clause has been programatically added to the query - // displays it - if (!empty($GLOBALS['sql_limit_to_append'])) { - if (!empty($GLOBALS['show_as_php'])) { - echo $GLOBALS['sql_limit_to_append']; - } else if (!empty($GLOBALS['validatequery'])) { - // skip the extra bit here - } else { - echo ' ' . PMA_formatSql(PMA_SQP_parse($GLOBALS['sql_limit_to_append'], $GLOBALS['sql_limit_to_append'])); - } - } unset($local_query); //Clean up the end of the PHP diff --git a/sql.php b/sql.php index 184838300..0e48eb8f8 100644 --- a/sql.php +++ b/sql.php @@ -319,6 +319,12 @@ else { } else { $full_sql_query = $sql_query . $sql_limit_to_append; } + if (preg_match('@((.|\n)*)(([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))|;)[[:space:]]*$@i', $display_query, $regs)) { + $display_query = $regs[1] . $sql_limit_to_append . $regs[3]; + } else { + $display_query = $display_query . $sql_limit_to_append; + } + unset($sql_limit_to_append); } else { $full_sql_query = $sql_query; } // end if...else @@ -666,12 +672,9 @@ else { // Display previous update query (from tbl_replace) if (isset($disp_query) && $cfg['ShowSQL'] == TRUE) { $tmp_sql_query = $GLOBALS['sql_query']; - $tmp_sql_limit_to_append = (isset($GLOBALS['sql_limit_to_append'])?$GLOBALS['sql_limit_to_append']:''); $GLOBALS['sql_query'] = $disp_query; - $GLOBALS['sql_limit_to_append'] = ''; PMA_showMessage($disp_message); $GLOBALS['sql_query'] = $tmp_sql_query; - $GLOBALS['sql_limit_to_append'] = $tmp_sql_limit_to_append; } // Displays the results in a table