Skip to content

Commit b9b67cc

Browse files
committed
Disable lazy popululation for queries with compound operators
This disables the lazy population feature for queries in the Execute SQL tab which contain a compound operator (UNION, EXCEPT, INTERSECT). Adding a LIMIT clause to the statements (as needed for lazy population) results in a syntax error, so running these queries does not show any data. See issue #2316.
1 parent ea6d008 commit b9b67cc

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

src/RowLoader.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,14 @@ void RowLoader::process (Task & t)
208208
// Remove trailing trailing semicolon
209209
QString queryTemp = rtrimChar(query, ';');
210210

211-
// If the query ends with a LIMIT statement take it as it is, if not append our own LIMIT part for lazy population
212-
if(queryTemp.contains(QRegExp("LIMIT\\s+.+\\s*((,|\\b(OFFSET)\\b)\\s*.+\\s*)?$", Qt::CaseInsensitive)))
211+
// If the query ends with a LIMIT statement or contains a compound operator take it as it is,
212+
// if not append our own LIMIT part for lazy population. The compound operator test is a very
213+
// weak check and does not detect whether the keyword is in a string or similar. This means
214+
// that lazy population is disabled for more queries than necessary. We should fix this once
215+
// we have a parser for SELECT statements but until then it is better to disable lazy population
216+
// for more statements than required instead of failing to run some statements entirely.
217+
if(queryTemp.contains(QRegExp("LIMIT\\s+.+\\s*((,|\\b(OFFSET)\\b)\\s*.+\\s*)?$", Qt::CaseInsensitive)) ||
218+
queryTemp.contains(QRegExp("\\s(UNION)|(INTERSECT)|(EXCEPT)\\s", Qt::CaseInsensitive)))
213219
sLimitQuery = queryTemp;
214220
else
215221
sLimitQuery = queryTemp + QString(" LIMIT %1, %2;").arg(t.row_begin).arg(t.row_end-t.row_begin);

0 commit comments

Comments
 (0)