[tracker: 2/3] SPARQL: Drop deprecated support for DROP GRAPH
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker: 2/3] SPARQL: Drop deprecated support for DROP GRAPH
- Date: Wed, 22 Dec 2010 11:15:51 +0000 (UTC)
commit 90b586cccdf5f9da34c70fdf935bc522406ab6e5
Author: Jürg Billeter <j bitron ch>
Date: Tue Dec 21 14:32:13 2010 +0100
SPARQL: Drop deprecated support for DROP GRAPH
The behavior was not conforming to the specification, and all users
have been ported.
src/libtracker-data/libtracker-data.vapi | 1 -
src/libtracker-data/tracker-data-update.c | 234 -------------------------
src/libtracker-data/tracker-data-update.h | 3 -
src/libtracker-data/tracker-sparql-query.vala | 16 +--
4 files changed, 1 insertions(+), 253 deletions(-)
---
diff --git a/src/libtracker-data/libtracker-data.vapi b/src/libtracker-data/libtracker-data.vapi
index bb26b5c..27955a0 100644
--- a/src/libtracker-data/libtracker-data.vapi
+++ b/src/libtracker-data/libtracker-data.vapi
@@ -146,7 +146,6 @@ namespace Tracker {
public void insert_statement (string graph, string subject, string predicate, string object) throws Sparql.Error, DateError;
public void insert_statement_with_uri (string graph, string subject, string predicate, string object) throws Sparql.Error;
public void insert_statement_with_string (string graph, string subject, string predicate, string object) throws Sparql.Error, DateError;
- public void delete_resource_description (string graph, string uri) throws Sparql.Error;
public void update_buffer_flush () throws DBInterfaceError;
public void update_buffer_might_flush () throws DBInterfaceError;
}
diff --git a/src/libtracker-data/tracker-data-update.c b/src/libtracker-data/tracker-data-update.c
index 9f6dc33..5f9bf64 100644
--- a/src/libtracker-data/tracker-data-update.c
+++ b/src/libtracker-data/tracker-data-update.c
@@ -2390,240 +2390,6 @@ format_sql_value_as_string (GString *sql,
}
}
-/**
- * Removes the description of a resource (embedded metadata), but keeps
- * annotations (non-embedded/user metadata) stored about the resource.
- */
-void
-tracker_data_delete_resource_description (const gchar *graph,
- const gchar *url,
- GError **error)
-{
- TrackerDBInterface *iface;
- TrackerDBStatement *stmt;
- TrackerDBResultSet *result_set = NULL, *single_result, *multi_result = NULL;
- TrackerClass *class;
- gchar *urn;
- GString *sql;
- TrackerProperty **properties, *property;
- int i;
- gboolean first, bail_out = FALSE;
- gint resource_id;
- guint p, n_props;
- GError *actual_error = NULL;
-
- /* We use result_sets instead of cursors here because it's possible
- * that otherwise the query of the outer cursor would be reused by the
- * cursors of the inner queries. */
-
- iface = tracker_db_manager_get_db_interface ();
-
- /* DROP GRAPH <url> - url here is nie:url */
-
- stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT, &actual_error,
- "SELECT ID, (SELECT Uri FROM Resource WHERE ID = \"nie:DataObject\".ID) FROM \"nie:DataObject\" WHERE \"nie:DataObject\".\"nie:url\" = ?");
-
- if (stmt) {
- tracker_db_statement_bind_text (stmt, 0, url);
- result_set = tracker_db_statement_execute (stmt, &actual_error);
- g_object_unref (stmt);
- }
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- return;
- }
-
- if (result_set) {
- tracker_db_result_set_get (result_set, 0, &resource_id, -1);
- tracker_db_result_set_get (result_set, 1, &urn, -1);
- g_object_unref (result_set);
- } else {
- /* For fallback to the old behaviour, we could do this here:
- * resource_id = tracker_data_query_resource_id (url); */
- return;
- }
-
- properties = tracker_ontologies_get_properties (&n_props);
-
- stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT, &actual_error,
- "SELECT (SELECT Uri FROM Resource WHERE ID = \"rdf:type\") FROM \"rdfs:Resource_rdf:type\" WHERE ID = ?");
-
- if (stmt) {
- tracker_db_statement_bind_int (stmt, 0, resource_id);
- result_set = tracker_db_statement_execute (stmt, &actual_error);
- g_object_unref (stmt);
- }
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- return;
- }
-
- if (result_set) {
- do {
- gchar *class_uri;
-
- tracker_db_result_set_get (result_set, 0, &class_uri, -1);
-
- class = tracker_ontologies_get_class_by_uri (class_uri);
-
- if (class == NULL) {
- g_warning ("Class '%s' not found in the ontology", class_uri);
- g_free (class_uri);
- continue;
- }
- g_free (class_uri);
-
- /* retrieve single value properties for current class */
-
- sql = g_string_new ("SELECT ");
-
- first = TRUE;
-
- for (p = 0; p < n_props; p++) {
- property = properties[p];
-
- if (tracker_property_get_domain (property) == class) {
- if (!tracker_property_get_embedded (property)) {
- continue;
- }
-
- if (!tracker_property_get_multiple_values (property)) {
- if (!first) {
- g_string_append (sql, ", ");
- }
- first = FALSE;
-
- format_sql_value_as_string (sql, property);
- }
- }
- }
-
- 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, TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT,
- &actual_error, "%s", sql->str);
-
- if (stmt) {
- tracker_db_statement_bind_int (stmt, 0, resource_id);
- single_result = tracker_db_statement_execute (stmt, &actual_error);
- g_object_unref (stmt);
- }
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- bail_out = TRUE;
- break;
- }
- }
-
- g_string_free (sql, TRUE);
-
- i = 0;
- for (p = 0; p < n_props; p++) {
- property = properties[p];
-
- if (tracker_property_get_domain (property) != class) {
- continue;
- }
-
- if (!tracker_property_get_embedded (property)) {
- continue;
- }
-
- if (property == tracker_ontologies_get_rdf_type ()) {
- /* Do not delete rdf:type statements */
- continue;
- }
-
- if (!tracker_property_get_multiple_values (property)) {
- gchar *value;
-
- /* single value property, value in single_result_set */
-
- tracker_db_result_set_get (single_result, i++, &value, -1);
-
- if (value) {
- tracker_data_delete_statement (graph, urn,
- tracker_property_get_uri (property),
- value,
- &actual_error);
- if (actual_error) {
- g_propagate_error (error, actual_error);
- bail_out = TRUE;
- break;
- }
- g_free (value);
- }
-
- } else {
- /* multi value property, retrieve values from DB */
-
- sql = g_string_new ("SELECT ");
-
- format_sql_value_as_string (sql, property);
-
- g_string_append_printf (sql,
- " FROM \"%s\" WHERE ID = ?",
- tracker_property_get_table_name (property));
-
- stmt = tracker_db_interface_create_statement (iface, TRACKER_DB_STATEMENT_CACHE_TYPE_SELECT,
- &actual_error, "%s", sql->str);
-
- if (stmt) {
- tracker_db_statement_bind_int (stmt, 0, resource_id);
- multi_result = tracker_db_statement_execute (stmt, NULL);
- g_object_unref (stmt);
- }
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- bail_out = TRUE;
- break;
- }
-
- if (multi_result) {
- do {
- gchar *value;
-
- tracker_db_result_set_get (multi_result, 0, &value, -1);
-
- tracker_data_delete_statement (graph, urn,
- tracker_property_get_uri (property),
- value,
- &actual_error);
-
- g_free (value);
-
- if (actual_error) {
- g_propagate_error (error, actual_error);
- bail_out = TRUE;
- break;
- }
-
- } while (tracker_db_result_set_iter_next (multi_result));
-
- g_object_unref (multi_result);
- }
-
- g_string_free (sql, TRUE);
- }
- }
-
- if (!first) {
- g_object_unref (single_result);
- }
-
- } while (!bail_out && tracker_db_result_set_iter_next (result_set));
-
- g_object_unref (result_set);
- }
-
- g_free (urn);
-}
-
void
tracker_data_rollback_transaction (void)
{
diff --git a/src/libtracker-data/tracker-data-update.h b/src/libtracker-data/tracker-data-update.h
index 61d39f0..2137541 100644
--- a/src/libtracker-data/tracker-data-update.h
+++ b/src/libtracker-data/tracker-data-update.h
@@ -49,9 +49,6 @@ typedef void (*TrackerCommitCallback) (gboolean start_timer,
GQuark tracker_data_error_quark (void);
/* Metadata */
-void tracker_data_delete_resource_description (const gchar *graph,
- const gchar *url,
- GError **error);
void tracker_data_delete_statement (const gchar *graph,
const gchar *subject,
const gchar *predicate,
diff --git a/src/libtracker-data/tracker-sparql-query.vala b/src/libtracker-data/tracker-sparql-query.vala
index e4be8b6..9411af0 100644
--- a/src/libtracker-data/tracker-sparql-query.vala
+++ b/src/libtracker-data/tracker-sparql-query.vala
@@ -474,8 +474,7 @@ public class Tracker.Sparql.Query : Object {
}
break;
case SparqlTokenType.DROP:
- execute_drop_graph ();
- break;
+ throw get_internal_error ("DROP GRAPH is not supported");
case SparqlTokenType.SELECT:
case SparqlTokenType.CONSTRUCT:
case SparqlTokenType.DESCRIBE:
@@ -745,19 +744,6 @@ public class Tracker.Sparql.Query : Object {
return update_blank_nodes;
}
- void execute_drop_graph () throws DBInterfaceError, Sparql.Error {
- expect (SparqlTokenType.DROP);
- expect (SparqlTokenType.GRAPH);
-
- bool is_var;
- string url = pattern.parse_var_or_term (null, out is_var);
-
- Data.delete_resource_description (url, url);
-
- // ensure possible WHERE clause in next part gets the correct results
- Data.update_buffer_flush ();
- }
-
internal string resolve_prefixed_name (string prefix, string local_name) throws Sparql.Error {
string ns = prefix_map.lookup (prefix);
if (ns == null) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]