diff options
Diffstat (limited to 'src/libtracker-data/tracker-sparql.c')
-rw-r--r-- | src/libtracker-data/tracker-sparql.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c index c4aaaaaa9..28c73bf6c 100644 --- a/src/libtracker-data/tracker-sparql.c +++ b/src/libtracker-data/tracker-sparql.c @@ -5085,8 +5085,28 @@ translate_OptionalGraphPattern (TrackerSparql *sparql, _call_rule (sparql, NAMED_RULE_GroupGraphPattern, error); - if (do_join) + if (do_join) { + /* FIXME: This is a workaround for SQLite 3.35.x, where + * the optimization on UNION ALLs inside JOINs (Point 8c in + * the 3.35.0 release notes) break in this very specific + * case: + * + * SELECT * { GRAPH ?g { ?a ... OPTIONAL { ?a ... } } } + * + * This is a workaround to make this one case ineligible + * for query flattening optimizations, specifically make + * it fall through case 8 in the list at + * https://sqlite.org/optoverview.html#flattening, + * "The subquery does not use LIMIT or the outer query is not + * a join.", we will now meet both here. + * + * This should be evaluated again in future SQLite versions. + */ + if (tracker_token_get_variable (&sparql->current_state->graph)) + _append_string (sparql, "LIMIT -1 "); + _append_string (sparql, ") "); + } return TRUE; } |