[tracker/wip/carlosg/sqlite-3-35-workaround: 1/2] libtracker-data: Workaround SQLite 3.35.x bug
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/wip/carlosg/sqlite-3-35-workaround: 1/2] libtracker-data: Workaround SQLite 3.35.x bug
- Date: Sun, 21 Mar 2021 16:57:44 +0000 (UTC)
commit a9aa8dfcc003e7b4cd3f9ebd94bb2a7499355564
Author: Carlos Garnacho <carlosg gnome org>
Date: Sun Mar 21 17:38:48 2021 +0100
libtracker-data: Workaround SQLite 3.35.x bug
The optimization for UNION ALLs inside JOINs had another unexpected
victim:
SELECT * { GRAPH ?g { ?a ... OPTIONAL { ?a ... } } }
Does now break when matching the graph between both sides of the
LEFT JOIN caused by OPTIONAL, making all other values coming from
the right hand side come back empty. Make it sure this specific case
is ineligible for query flattening optimizations by adding a LIMIT
clause on the right hand side of the LEFT JOIN. This brings back
correct over fast.
This workaround should be revisited when a SQLite fix is available.
src/libtracker-data/tracker-sparql.c | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
---
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index c4aaaaaa9..b2ed0e6b6 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 version.
+ */
+ if (tracker_token_get_variable (&sparql->current_state->graph))
+ _append_string (sparql, "LIMIT -1 ");
+
_append_string (sparql, ") ");
+ }
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]