diff --git a/ChangeLog b/ChangeLog index 7da7071d0..f26326839 100755 --- a/ChangeLog +++ b/ChangeLog @@ -7,7 +7,8 @@ $Source$ 2003-01-08 Marc Delisle * libraries/sqlparser.lib.php3, libraries/functions.js, - sql.php3: use the parser for confirmation requests + sql.php3: - use the parser for confirmation requests + - better check before appending LIMIT 2003-01-08 Michal Cihar * libraries/url_generating.lib.php3, libraries/common.lib.php3: New URL diff --git a/libraries/sqlparser.lib.php3 b/libraries/sqlparser.lib.php3 index 9ebc0d6c2..7a74fadc0 100644 --- a/libraries/sqlparser.lib.php3 +++ b/libraries/sqlparser.lib.php3 @@ -600,6 +600,17 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { * * There is a debug section at the end of the main loop, if you want to * see the exact contents of select_expr and table_ref + * + * lem9: queryflags + * ---------- + * + * In $subresult, array 'queryflags' is filled, according to what we + * find in the query. + * + * Currently, those are generated: + * + * ['queryflags']['need_confirm'] = 1; if the query needs confirmation + * ['queryflags']['select_from'] = 1; if this is a real SELECT...FROM */ // must be sorted // TODO: current logic checks for only one word, so I put only the @@ -982,7 +993,8 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { for ($i = 0; $i < $size; $i++) { //echo "trace 2" . $arr[$i]['data'] . " (" . $arr[$i]['type'] . ")
"; - // c o n f i r m a t i o n r e q u e s t s + + // c o n f i r m a t i o n r e q u e s t s (need_confirm) // // check for reserved words that will have to generate // a confirmation request later in sql.php3 @@ -1014,7 +1026,10 @@ if (!defined('PMA_SQP_LIB_INCLUDED')) { if ($upper_data=='DROP' && $first_reserved_word=='ALTER') { $subresult['queryflags']['need_confirm'] = 1; break; - + } + if ($upper_data=='FROM' && $first_reserved_word=='SELECT') { + $subresult['queryflags']['select_from'] = 1; + break; } } } diff --git a/sql.php3 b/sql.php3 index d94e86ada..70654b077 100755 --- a/sql.php3 +++ b/sql.php3 @@ -254,9 +254,13 @@ else { // Do append a "LIMIT" clause? if (isset($pos) && (!$cfg['ShowAll'] || $session_max_rows != 'all') - && $is_select && !($is_count || $is_export || $is_func || $is_analyse) - && eregi('[[:space:]]FROM[[:space:]]', $sql_query) + + //&& $is_select + //&& eregi('[[:space:]]FROM[[:space:]]', $sql_query) + + && isset($analyzed_sql[0]['queryflags']['select_from']) + && !eregi('[[:space:]]LIMIT[[:space:]0-9,-]+$', $sql_query)) { $sql_limit_to_append = " LIMIT $pos, ".$cfg['MaxRows']; if (eregi('(.*)([[:space:]](PROCEDURE[[:space:]](.*)|FOR[[:space:]]+UPDATE|LOCK[[:space:]]+IN[[:space:]]+SHARE[[:space:]]+MODE))$', $sql_query, $regs)) {