Skip to content

Commit

Permalink
Fixed phpmyadmin#3789 Erroneous LIMIT clause in prettyprinted SQL.
Browse files Browse the repository at this point in the history
Moved the default sql limit append such that it will only get append, if the limit is not added to the sql query explicitly.
  • Loading branch information
hisamith committed Feb 17, 2013
1 parent 7bc990f commit bc57dfd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -560,16 +560,15 @@
PMA_handleSortOrder($db, $table, $analyzed_sql, $full_sql_query);
}

$sql_limit_to_append = ' LIMIT ' . $_SESSION['tmp_user_values']['pos']
. ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";

// Do append a "LIMIT" clause?
if (($_SESSION['tmp_user_values']['max_rows'] != 'all')
&& ! ($is_count || $is_export || $is_func || $is_analyse)
&& isset($analyzed_sql[0]['queryflags']['select_from'])
&& ! isset($analyzed_sql[0]['queryflags']['offset'])
&& empty($analyzed_sql[0]['limit_clause'])
) {
$sql_limit_to_append = ' LIMIT ' . $_SESSION['tmp_user_values']['pos']
. ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";
$full_sql_query = PMA_getSqlWithLimitClause(
$full_sql_query,
$analyzed_sql,
Expand Down Expand Up @@ -1517,6 +1516,8 @@ function getTableHtmlForMultipleQueries(
&& ! isset($analyzed_sql[0]['queryflags']['offset'])
&& empty($analyzed_sql[0]['limit_clause'])
) {
$sql_limit_to_append = ' LIMIT ' . $_SESSION['tmp_user_values']['pos']
. ', ' . $_SESSION['tmp_user_values']['max_rows'] . " ";
$sql_data['valid_sql'][$sql_no] = PMA_getSqlWithLimitClause(
$sql_data['valid_sql'][$sql_no],
$analyzed_sql,
Expand Down

0 comments on commit bc57dfd

Please sign in to comment.