From 044907f655131ce305fa59b25add681e418a1292 Mon Sep 17 00:00:00 2001 From: Martin Kleusberg Date: Wed, 1 Jan 2014 14:45:27 +0100 Subject: [PATCH] Fix infinite loop when executing some SQL statements with limit part Issue #31 was about some problems in the SqliteTableModel which caused an endless loop in the Execute SQL tab when executing statements with a LIMIT part that didn't end with a semicolon. This was fixed in 0362d615fd but the regular expression in this commit only worked for statements like 'SELECT * FROM t LIMIT 0,10' and didn't detect a statement like 'SELECT * FROM t LIMIT 10' where there is only one number after 'limit', so the bug still ocurred for those commands. This is fixed by this commit. --- src/sqlitetablemodel.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/sqlitetablemodel.cpp b/src/sqlitetablemodel.cpp index c14886cb..fd4e47ab 100644 --- a/src/sqlitetablemodel.cpp +++ b/src/sqlitetablemodel.cpp @@ -328,7 +328,7 @@ void SqliteTableModel::fetchData(unsigned int from, unsigned to) QString queryTemp = rtrimChar(m_sQuery, ';'); // If the query ends with a LIMIT statement take it as it is, if not append our own LIMIT part for lazy population - if(queryTemp.contains(QRegExp("LIMIT\\s+\\d+\\s*,\\s*\\d+\\s*$", Qt::CaseInsensitive))) + if(queryTemp.contains(QRegExp("LIMIT\\s+\\d+\\s*(,\\s*\\d+\\s*)?$", Qt::CaseInsensitive))) sLimitQuery = queryTemp; else sLimitQuery = QString("%1 LIMIT %2, %3;").arg(queryTemp).arg(from).arg(to-from);