diff --git a/libraries/sql.lib.php b/libraries/sql.lib.php index 5ed4e8de54..d824586083 100644 --- a/libraries/sql.lib.php +++ b/libraries/sql.lib.php @@ -2131,9 +2131,16 @@ function PMA_executeQueryAndGetQueryResponse($analyzed_sql_results, // assign default full_sql_query $full_sql_query = $sql_query; - // Do append a "LIMIT" clause? - if (PMA_isAppendLimitClause($analyzed_sql_results)) { - $full_sql_query = PMA_getSqlWithLimitClause($analyzed_sql_results); + // Assigning LIMIT clause to an syntactically-wrong query + // is not needed. Also we would want to show the true query + // and the true error message to the query executor + if (isset($analyzed_sql_results['parser']) + && count($analyzed_sql_results['parser']->errors) === 0 + ) { + // Do append a "LIMIT" clause? + if (PMA_isAppendLimitClause($analyzed_sql_results)) { + $full_sql_query = PMA_getSqlWithLimitClause($analyzed_sql_results); + } } $GLOBALS['reload'] = PMA_hasCurrentDbChanged($db);