mirror of
https://github.com/sqlitebrowser/sqlitebrowser.git
synced 2026-01-19 18:40:13 -06:00
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.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user