[tracker/lru-stmt-cache] libtracker-data: Don't cache stmt if the query contains a regular expression
- From: Philip Van Hoof <pvanhoof src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker/lru-stmt-cache] libtracker-data: Don't cache stmt if the query contains a regular expression
- Date: Tue, 21 Sep 2010 09:50:37 +0000 (UTC)
commit 24362e28822bd6a7afefbc5580ace4476981c369
Author: Philip Van Hoof <philip codeminded be>
Date: Tue Sep 21 11:48:03 2010 +0200
libtracker-data: Don't cache stmt if the query contains a regular expression
src/libtracker-data/libtracker-data.vapi | 2 +-
src/libtracker-data/tracker-data-manager.c | 26 ++++++-----
src/libtracker-data/tracker-data-query.c | 4 +-
src/libtracker-data/tracker-data-update.c | 44 +++++++++++--------
src/libtracker-data/tracker-db-interface-sqlite.c | 27 ++++++++----
src/libtracker-data/tracker-db-interface.h | 3 +-
src/libtracker-data/tracker-db-manager.c | 2 +-
src/libtracker-data/tracker-sparql-expression.vala | 1 +
src/libtracker-data/tracker-sparql-pattern.vala | 4 +-
src/libtracker-data/tracker-sparql-query.vala | 5 ++-
10 files changed, 69 insertions(+), 49 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index 4bdef4f..067a984 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -37,7 +37,7 @@ namespace Tracker {
[CCode (cheader_filename = "libtracker-data/tracker-db-interface.h")]
public interface DBInterface : GLib.Object {
[PrintfFormat]
- public abstract DBStatement create_statement (...) throws DBInterfaceError;
+ public abstract DBStatement create_statement (bool cache_stmt, ...) throws DBInterfaceError;
}
[CCode (cheader_filename = "libtracker-data/tracker-data-update.h")]
diff --git a/src/libtracker-data/tracker-data-manager.c b/src/libtracker-data/tracker-data-manager.c
index 912e693..f1a2db9 100644
--- a/src/libtracker-data/tracker-data-manager.c
+++ b/src/libtracker-data/tracker-data-manager.c
@@ -1445,7 +1445,7 @@ class_add_super_classes_from_db (TrackerDBInterface *iface,
TrackerDBCursor *cursor;
GError *error = NULL;
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT (SELECT Uri FROM Resource WHERE ID = \"rdfs:subClassOf\") "
"FROM \"rdfs:Class_rdfs:subClassOf\" "
"WHERE ID = (SELECT ID FROM Resource WHERE Uri = ?)");
@@ -1483,7 +1483,7 @@ class_add_domain_indexes_from_db (TrackerDBInterface *iface,
TrackerDBCursor *cursor;
GError *error = NULL;
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT (SELECT Uri FROM Resource WHERE ID = \"tracker:domainIndex\") "
"FROM \"rdfs:Class_tracker:domainIndex\" "
"WHERE ID = (SELECT ID FROM Resource WHERE Uri = ?)");
@@ -1521,7 +1521,7 @@ property_add_super_properties_from_db (TrackerDBInterface *iface,
TrackerDBCursor *cursor;
GError *error = NULL;
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT (SELECT Uri FROM Resource WHERE ID = \"rdfs:subPropertyOf\") "
"FROM \"rdf:Property_rdfs:subPropertyOf\" "
"WHERE ID = (SELECT ID FROM Resource WHERE Uri = ?)");
@@ -1560,7 +1560,7 @@ db_get_static_data (TrackerDBInterface *iface)
guint n_classes, i;
GError *error = NULL;
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT (SELECT Uri FROM Resource WHERE ID = \"tracker:Ontology\".ID), "
"\"nao:lastModified\" "
"FROM \"tracker:Ontology\"");
@@ -1598,7 +1598,7 @@ db_get_static_data (TrackerDBInterface *iface)
g_clear_error (&error);
}
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT (SELECT Uri FROM Resource WHERE ID = \"tracker:Namespace\".ID), "
"\"tracker:prefix\" "
"FROM \"tracker:Namespace\"");
@@ -1636,7 +1636,7 @@ db_get_static_data (TrackerDBInterface *iface)
g_clear_error (&error);
}
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT \"rdfs:Class\".ID, "
"(SELECT Uri FROM Resource WHERE ID = \"rdfs:Class\".ID), "
"\"tracker:notify\" "
@@ -1690,7 +1690,9 @@ db_get_static_data (TrackerDBInterface *iface)
if (!g_str_has_prefix (tracker_class_get_name (class), "xsd:") &&
(tracker_db_manager_get_flags () & TRACKER_DB_MANAGER_READONLY) == 0) {
/* update statistics */
- stmt = tracker_db_interface_create_statement (iface, &error, "SELECT COUNT(1) FROM \"%s\"", tracker_class_get_name (class));
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
+ "SELECT COUNT(1) FROM \"%s\"",
+ tracker_class_get_name (class));
if (error) {
g_warning ("%s", error->message);
@@ -1716,7 +1718,7 @@ db_get_static_data (TrackerDBInterface *iface)
g_clear_error (&error);
}
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT \"rdf:Property\".ID, (SELECT Uri FROM Resource WHERE ID = \"rdf:Property\".ID), "
"(SELECT Uri FROM Resource WHERE ID = \"rdfs:domain\"), "
"(SELECT Uri FROM Resource WHERE ID = \"rdfs:range\"), "
@@ -1899,7 +1901,7 @@ insert_uri_in_resource_table (TrackerDBInterface *iface,
TrackerDBStatement *stmt;
GError *error = NULL;
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"INSERT "
"INTO Resource "
"(ID, Uri) "
@@ -2690,7 +2692,7 @@ get_new_service_id (TrackerDBInterface *iface)
iface = tracker_db_manager_get_db_interface ();
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT MAX(ID) AS A FROM Resource");
if (stmt) {
@@ -2973,7 +2975,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
* for all the ontology files in ontologies_dir whether the last-modified
* has changed since we dealt with the file last time. */
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT Resource.Uri, \"rdfs:Resource\".\"nao:lastModified\" FROM \"tracker:Ontology\""
"INNER JOIN Resource ON Resource.ID = \"tracker:Ontology\".ID "
"INNER JOIN \"rdfs:Resource\" ON \"tracker:Ontology\".ID = \"rdfs:Resource\".ID");
@@ -3070,7 +3072,7 @@ tracker_data_manager_init (TrackerDBManagerFlags flags,
if (update_nao) {
/* Update the nao:lastModified in the database */
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"UPDATE \"rdfs:Resource\" SET \"nao:lastModified\"= ? "
"WHERE \"rdfs:Resource\".ID = "
"(SELECT Resource.ID FROM Resource INNER JOIN \"rdfs:Resource\" "
diff --git a/src/libtracker-data/tracker-data-query.c b/src/libtracker-data/tracker-data-query.c
index b89819f..6165608 100644
--- a/src/libtracker-data/tracker-data-query.c
+++ b/src/libtracker-data/tracker-data-query.c
@@ -47,7 +47,7 @@ tracker_data_query_rdf_type (gint id)
iface = tracker_db_manager_get_db_interface ();
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") "
"FROM \"rdfs:Resource_rdf:type\" "
"WHERE ID = ?");
@@ -106,7 +106,7 @@ tracker_data_query_resource_id (const gchar *uri)
iface = tracker_db_manager_get_db_interface ();
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT ID FROM Resource WHERE Uri = ?");
if (stmt) {
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 7d15047..a124f6e 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -344,7 +344,7 @@ tracker_data_update_get_new_service_id (void)
iface = tracker_db_manager_get_db_interface ();
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT MAX(ID) AS A FROM Resource");
if (stmt) {
@@ -389,7 +389,7 @@ tracker_data_update_get_next_modseq (void)
temp_iface = tracker_db_manager_get_db_interface ();
- stmt = tracker_db_interface_create_statement (temp_iface, &error,
+ stmt = tracker_db_interface_create_statement (temp_iface, TRUE, &error,
"SELECT MAX(\"tracker:modified\") AS A FROM \"rdfs:Resource\"");
if (stmt) {
@@ -565,7 +565,8 @@ ensure_resource_id (const gchar *uri,
iface = tracker_db_manager_get_db_interface ();
id = tracker_data_update_get_new_service_id ();
- stmt = tracker_db_interface_create_statement (iface, &error, "INSERT INTO Resource (ID, Uri) VALUES (?, ?)");
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
+ "INSERT INTO Resource (ID, Uri) VALUES (?, ?)");
if (stmt) {
tracker_db_statement_bind_int (stmt, 0, id);
@@ -660,12 +661,12 @@ tracker_data_resource_buffer_flush (GError **error)
if (table->delete_value) {
/* delete rows for multiple value properties */
- stmt = tracker_db_interface_create_statement (iface, &actual_error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
"DELETE FROM \"%s\" WHERE ID = ? AND \"%s\" = ?",
table_name,
property->name);
} else if (property->date_time) {
- stmt = tracker_db_interface_create_statement (iface, &actual_error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
"INSERT OR IGNORE INTO \"%s\" (ID, \"%s\", \"%s:localDate\", \"%s:localTime\", \"%s:graph\") VALUES (?, ?, ?, ?, ?)",
table_name,
property->name,
@@ -673,7 +674,7 @@ tracker_data_resource_buffer_flush (GError **error)
property->name,
property->name);
} else {
- stmt = tracker_db_interface_create_statement (iface, &actual_error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
"INSERT OR IGNORE INTO \"%s\" (ID, \"%s\", \"%s:graph\") VALUES (?, ?, ?)",
table_name,
property->name,
@@ -707,7 +708,8 @@ tracker_data_resource_buffer_flush (GError **error)
} else {
if (table->delete_row) {
/* remove entry from rdf:type table */
- stmt = tracker_db_interface_create_statement (iface, &actual_error, "DELETE FROM \"rdfs:Resource_rdf:type\" WHERE ID = ? AND \"rdf:type\" = ?");
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
+ "DELETE FROM \"rdfs:Resource_rdf:type\" WHERE ID = ? AND \"rdf:type\" = ?");
if (stmt) {
tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
@@ -726,7 +728,8 @@ tracker_data_resource_buffer_flush (GError **error)
}
/* remove row from class table */
- stmt = tracker_db_interface_create_statement (iface, &actual_error, "DELETE FROM \"%s\" WHERE ID = ?", table_name);
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
+ "DELETE FROM \"%s\" WHERE ID = ?", table_name);
if (stmt) {
tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
@@ -745,7 +748,7 @@ tracker_data_resource_buffer_flush (GError **error)
if (table->insert) {
if (strcmp (table_name, "rdfs:Resource") == 0) {
/* ensure we have a row for the subject id */
- stmt = tracker_db_interface_create_statement (iface, &actual_error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
"INSERT OR IGNORE INTO \"%s\" (ID, \"tracker:added\", \"tracker:modified\", Available) VALUES (?, ?, ?, 1)",
table_name);
@@ -759,7 +762,7 @@ tracker_data_resource_buffer_flush (GError **error)
}
} else {
/* ensure we have a row for the subject id */
- stmt = tracker_db_interface_create_statement (iface, &actual_error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
"INSERT OR IGNORE INTO \"%s\" (ID) VALUES (?)",
table_name);
@@ -800,7 +803,8 @@ tracker_data_resource_buffer_flush (GError **error)
g_string_append (sql, " WHERE ID = ?");
- stmt = tracker_db_interface_create_statement (iface, &actual_error, "%s", sql->str);
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
+ "%s", sql->str);
g_string_free (sql, TRUE);
if (actual_error) {
@@ -1199,7 +1203,9 @@ get_property_values (TrackerProperty *property)
iface = tracker_db_manager_get_db_interface ();
- stmt = tracker_db_interface_create_statement (iface, &error, "SELECT \"%s\" FROM \"%s\" WHERE ID = ?", field_name, table_name);
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
+ "SELECT \"%s\" FROM \"%s\" WHERE ID = ?",
+ field_name, table_name);
if (stmt) {
tracker_db_statement_bind_int (stmt, 0, resource_buffer->id);
@@ -1602,7 +1608,7 @@ cache_delete_resource_type (TrackerClass *class,
/* retrieve all subclasses we need to remove from the subject
* before we can remove the class specified as object of the statement */
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"SELECT (SELECT Uri FROM Resource WHERE ID = \"rdfs:Class_rdfs:subClassOf\".ID) "
"FROM \"rdfs:Resource_rdf:type\" INNER JOIN \"rdfs:Class_rdfs:subClassOf\" ON (\"rdf:type\" = \"rdfs:Class_rdfs:subClassOf\".ID) "
"WHERE \"rdfs:Resource_rdf:type\".ID = ? AND \"rdfs:subClassOf\" = (SELECT ID FROM Resource WHERE Uri = ?)");
@@ -2340,7 +2346,7 @@ tracker_data_delete_resource_description (const gchar *graph,
/* DROP GRAPH <url> - url here is nie:url */
- stmt = tracker_db_interface_create_statement (iface, &actual_error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
"SELECT ID, (SELECT Uri FROM Resource WHERE ID = \"nie:DataObject\".ID) FROM \"nie:DataObject\" WHERE \"nie:DataObject\".\"nie:url\" = ?");
if (stmt) {
@@ -2366,7 +2372,7 @@ tracker_data_delete_resource_description (const gchar *graph,
properties = tracker_ontologies_get_properties (&n_props);
- stmt = tracker_db_interface_create_statement (iface, &actual_error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error,
"SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
if (stmt) {
@@ -2423,7 +2429,7 @@ tracker_data_delete_resource_description (const gchar *graph,
single_result = NULL;
if (!first) {
g_string_append_printf (sql, " FROM \"%s\" WHERE ID = ?", tracker_class_get_name (class));
- stmt = tracker_db_interface_create_statement (iface, &actual_error, "%s", sql->str);
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error, "%s", sql->str);
if (stmt) {
tracker_db_statement_bind_int (stmt, 0, resource_id);
@@ -2488,7 +2494,7 @@ tracker_data_delete_resource_description (const gchar *graph,
" FROM \"%s\" WHERE ID = ?",
tracker_property_get_table_name (property));
- stmt = tracker_db_interface_create_statement (iface, &actual_error, "%s", sql->str);
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &actual_error, "%s", sql->str);
if (stmt) {
tracker_db_statement_bind_int (stmt, 0, resource_id);
@@ -2720,7 +2726,7 @@ ontology_transaction_end (GList *ontology_queue,
* db. See tracker-data-manager.c for more info. */
last_mod = (gint) tracker_ontology_get_last_modified (ontology);
- stmt = tracker_db_interface_create_statement (iface, &error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &error,
"UPDATE \"rdfs:Resource\" SET \"nao:lastModified\"= ? "
"WHERE \"rdfs:Resource\".ID = "
"(SELECT Resource.ID FROM Resource INNER JOIN \"rdfs:Resource\" "
@@ -2828,7 +2834,7 @@ tracker_data_replay_journal (GHashTable *classes,
iface = tracker_db_manager_get_db_interface ();
- stmt = tracker_db_interface_create_statement (iface, &new_error,
+ stmt = tracker_db_interface_create_statement (iface, TRUE, &new_error,
"INSERT "
"INTO Resource "
"(ID, Uri) "
diff --git a/src/libtracker-data/tracker-db-interface-sqlite.c b/src/libtracker-data/tracker-db-interface-sqlite.c
index 5e45fa8..acb768f 100644
--- a/src/libtracker-data/tracker-db-interface-sqlite.c
+++ b/src/libtracker-data/tracker-db-interface-sqlite.c
@@ -814,6 +814,7 @@ add_row (TrackerDBResultSet *result_set,
TrackerDBStatement *
tracker_db_interface_create_statement (TrackerDBInterface *db_interface,
+ gboolean cache_stmt,
GError **error,
const gchar *query,
...)
@@ -829,10 +830,14 @@ tracker_db_interface_create_statement (TrackerDBInterface *db_interface,
full_query = g_strdup_vprintf (query, args);
va_end (args);
- stmt = g_hash_table_lookup (db_interface->dynamic_statements, full_query);
+ if (cache_stmt) {
+ stmt = g_hash_table_lookup (db_interface->dynamic_statements, full_query);
- if (stmt && stmt->stmt_is_sunk) {
- /* prepared statement is still in use, create new one */
+ if (stmt && stmt->stmt_is_sunk) {
+ /* prepared statement is still in use, create new one */
+ stmt = NULL;
+ }
+ } else {
stmt = NULL;
}
@@ -866,19 +871,21 @@ tracker_db_interface_create_statement (TrackerDBInterface *db_interface,
stmt = tracker_db_statement_sqlite_new (db_interface, sqlite_stmt);
- /* use replace instead of insert to make sure we store the string that
- belongs to the right sqlite statement to ensure the lifetime of the string
- matches the statement */
- g_hash_table_replace (db_interface->dynamic_statements,
- (gpointer) sqlite3_sql (sqlite_stmt),
- stmt);
+ if (cache_stmt) {
+ /* use replace instead of insert to make sure we store the string that
+ belongs to the right sqlite statement to ensure the lifetime of the string
+ matches the statement */
+ g_hash_table_replace (db_interface->dynamic_statements,
+ (gpointer) sqlite3_sql (sqlite_stmt),
+ stmt);
+ }
} else {
tracker_db_statement_sqlite_reset (stmt);
}
g_free (full_query);
- return g_object_ref (stmt);
+ return cache_stmt ? g_object_ref (stmt) : stmt;
}
static TrackerDBResultSet *
diff --git a/src/libtracker-data/tracker-db-interface.h b/src/libtracker-data/tracker-db-interface.h
index d63e1b1..4668a14 100644
--- a/src/libtracker-data/tracker-db-interface.h
+++ b/src/libtracker-data/tracker-db-interface.h
@@ -88,9 +88,10 @@ GType tracker_db_result_set_get_type (void);
/* Functions to create queries/procedures */
TrackerDBStatement * tracker_db_interface_create_statement (TrackerDBInterface *interface,
+ gboolean cache_stmt,
GError **error,
const gchar *query,
- ...) G_GNUC_PRINTF (3, 4);
+ ...) G_GNUC_PRINTF (4, 5);
TrackerDBResultSet * tracker_db_interface_execute_vquery (TrackerDBInterface *interface,
GError **error,
const gchar *query,
diff --git a/src/libtracker-data/tracker-db-manager.c b/src/libtracker-data/tracker-db-manager.c
index 3aaaf6d..122019c 100644
--- a/src/libtracker-data/tracker-db-manager.c
+++ b/src/libtracker-data/tracker-db-manager.c
@@ -895,7 +895,7 @@ tracker_db_manager_init (TrackerDBManagerFlags flags,
loaded = TRUE;
- stmt = tracker_db_interface_create_statement (dbs[i].iface, NULL,
+ stmt = tracker_db_interface_create_statement (dbs[i].iface, FALSE, NULL,
"PRAGMA integrity_check(1)");
if (stmt) {
diff --git a/src/libtracker-data/tracker-sparql-expression.vala b/src/libtracker-data/tracker-sparql-expression.vala
index 4a4af2f..baa8455 100644
--- a/src/libtracker-data/tracker-sparql-expression.vala
+++ b/src/libtracker-data/tracker-sparql-expression.vala
@@ -940,6 +940,7 @@ class Tracker.Sparql.Expression : Object {
return PropertyType.BOOLEAN;
case SparqlTokenType.REGEX:
translate_regex (sql);
+ query.has_regex = true;
return PropertyType.BOOLEAN;
case SparqlTokenType.EXISTS:
case SparqlTokenType.NOT:
diff --git a/src/libtracker-data/tracker-sparql-pattern.vala b/src/libtracker-data/tracker-sparql-pattern.vala
index 394dfac..8435896 100644
--- a/src/libtracker-data/tracker-sparql-pattern.vala
+++ b/src/libtracker-data/tracker-sparql-pattern.vala
@@ -37,7 +37,7 @@ namespace Tracker.Sparql {
DBResultSet result_set = null;
if (subject_id > 0) {
var iface = DBManager.get_db_interface ();
- var stmt = iface.create_statement ("SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+ var stmt = iface.create_statement (true, "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
stmt.bind_int (0, subject_id);
result_set = stmt.execute ();
}
@@ -84,7 +84,7 @@ namespace Tracker.Sparql {
var object_id = Data.query_resource_id (object);
var iface = DBManager.get_db_interface ();
- var stmt = iface.create_statement ("SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
+ var stmt = iface.create_statement (true, "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
stmt.bind_int (0, object_id);
var result_set = stmt.execute ();
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index 4238a10..9eed70e 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -219,7 +219,10 @@ public class Tracker.Sparql.Query : Object {
uchar[] base_uuid;
HashTable<string,string> blank_nodes;
+ public bool has_regex { get; set; }
+
public Query (string query) {
+ has_regex = false; /* Start with false, expression sets it */
tokens = new TokenInfo[BUFFER_SIZE];
prefix_map = new HashTable<string,string>.full (str_hash, str_equal, g_free, g_free);
@@ -486,7 +489,7 @@ public class Tracker.Sparql.Query : Object {
DBStatement prepare_for_exec (string sql) throws DBInterfaceError, Sparql.Error, DateError {
var iface = DBManager.get_db_interface ();
- var stmt = iface.create_statement ("%s", sql);
+ var stmt = iface.create_statement (!has_regex, "%s", sql);
// set literals specified in query
int i = 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]