[tracker] libtracker-data: Wrap BIND argument with () in SQL
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker] libtracker-data: Wrap BIND argument with () in SQL
- Date: Mon, 21 Nov 2016 13:03:13 +0000 (UTC)
commit 8fc47cfed03030e5377bc7989e5afd24e9b24c5b
Author: Carlos Garnacho <carlosg gnome org>
Date: Mon Nov 21 13:24:42 2016 +0100
libtracker-data: Wrap BIND argument with () in SQL
Constructing the query as "SELECT $bind * FROM (...)" may trigger
sqlite parser overflows if the BIND form turns out to be too complex,
Doing the query as "SELECT ($bind) * FROM (...)" seems to be more
friendly to the parser.
This error was seen in gnome-music search, where the BIND() argument
is something like:
BIND((IF(STRSTARTS(?title_lower, "the "), SUBSTR(?title_lower, 5),
IF(STRSTARTS(?title_lower, "a "), SUBSTR(?title_lower, 3),
IF(STRSTARTS(?title_lower, "an "), SUBSTR(?title_lower, 4),
fn:replace(fn:lower-case(?title_lower),
"^[ !\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]+|[
!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~]+$", "")
)
)
)
) AS ?title_collation)
Which, despite the fn:replace regex argument being passed as a host
parameter, seemed too much to sqlite.
src/libtracker-data/tracker-sparql-pattern.vala | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
---
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index 6a67679..d37474b 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -1130,9 +1130,9 @@ class Tracker.Sparql.Pattern : Object {
if (in_group_graph_pattern) {
// Surround the entire group graph pattern with
// SELECT $binding , * FROM (...)
- var binding_sql = new StringBuilder ("SELECT ");
+ var binding_sql = new StringBuilder ("SELECT (");
add_variable_binding (binding_sql, binding, VariableState.BOUND);
- binding_sql.append (" * FROM (");
+ binding_sql.append (") * FROM (");
sql.insert (group_graph_pattern_start, binding_sql.str);
sql.append (")");
} else {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]