[tracker] SPARQL: Do not use nested subquery for EXISTS / NOT EXISTS
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] SPARQL: Do not use nested subquery for EXISTS / NOT EXISTS
- Date: Fri, 17 Dec 2010 11:57:10 +0000 (UTC)
commit c819b9ab6a3cdf057c6dbe6cdfda1ed9c56fb7d8
Author: Jürg Billeter <j bitron ch>
Date: Fri Dec 17 12:44:19 2010 +0100
SPARQL: Do not use nested subquery for EXISTS / NOT EXISTS
SQLite cannot handle a subquery with a nested correlated subquery.
Fixes NB#211928.
src/libtracker-data/tracker-sparql-pattern.vala | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index c657857..da907ab 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -439,11 +439,15 @@ class Tracker.Sparql.Pattern : Object {
result = new SelectContext.subquery (query, context);
context = result;
- var pattern_sql = new StringBuilder ();
-
- sql.append ("SELECT ");
+ if (not) {
+ // NOT EXISTS
+ sql.append ("NOT EXISTS (");
+ } else {
+ // EXISTS
+ sql.append ("EXISTS (");
+ }
- var pattern = translate_group_graph_pattern (pattern_sql);
+ var pattern = translate_group_graph_pattern (sql);
foreach (var key in pattern.var_set.get_keys ()) {
context.var_set.insert (key, VariableState.BOUND);
}
@@ -455,17 +459,6 @@ class Tracker.Sparql.Pattern : Object {
}
}
- if (not) {
- // NOT EXISTS
- sql.append ("COUNT(1) = 0");
- } else {
- // EXISTS
- sql.append ("COUNT(1) > 0");
- }
-
- // select from results of WHERE clause
- sql.append (" FROM (");
- sql.append (pattern_sql.str);
sql.append (")");
context = context.parent_context;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]