SqliteTableModel: Don't add LIMIT to query if it is a PRAGMA or EXPLAIN

Don't add a "LIMIT x,y" at the end of the query in fetchData() when it
is a PRAGMA or EXPLAIN statement. This way correct SQL code is produced
and it also fixes an endless loop when the statement didn't end in a
semicolon.
This commit is contained in:
Martin Kleusberg
2013-07-19 22:36:28 +02:00
parent 427581f51d
commit 26d5645671

View File

@@ -285,7 +285,11 @@ void SqliteTableModel::fetchData(unsigned int from, unsigned to)
{
int currentsize = m_data.size();
QString sLimitQuery = QString("%1 LIMIT %2, %3;").arg(m_sQuery).arg(from).arg(to-from);
QString sLimitQuery;
if(m_sQuery.startsWith("PRAGMA", Qt::CaseInsensitive) || m_sQuery.startsWith("EXPLAIN", Qt::CaseInsensitive))
sLimitQuery = m_sQuery;
else
sLimitQuery = QString("%1 LIMIT %2, %3;").arg(m_sQuery).arg(from).arg(to-from);
m_db->logSQL(sLimitQuery, kLogMsg_App);
QByteArray utf8Query = sLimitQuery.toUtf8();
sqlite3_stmt *stmt;