Merge pull request #12580 from devenbansod/fix_12321

Assign LIMIT clause only to syntactically correct queries
This commit is contained in:
Michal Čihař 2016-09-22 09:50:16 +02:00 committed by GitHub
commit b83ba03bd4

View File

@ -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);