summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2020-04-26 21:53:39 +0200
committerCarlos Garnacho <carlosg@gnome.org>2020-04-27 19:05:58 +0200
commita6013fe3d92c3f9e6de3baf9a1ff203c1f637e13 (patch)
tree4159996a9a35434f2efc9c9b9d9ab09bec171f7e /src
parent77662eae30af129b294c4644c53474df65e289d5 (diff)
downloadtracker-a6013fe3d92c3f9e6de3baf9a1ff203c1f637e13.tar.gz
libtracker-data: Fix lifetime of blank node labels
According to https://www.w3.org/TR/sparql11-query/#grammarBNodes: Blank node labels are scoped to the SPARQL Request String in which they occur. Different uses of the same blank node label in a request string refer to the same blank node. Scope correctly blank node labels to the full update string, instead of each InsertClause within.
Diffstat (limited to 'src')
-rw-r--r--src/libtracker-data/tracker-sparql.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/src/libtracker-data/tracker-sparql.c b/src/libtracker-data/tracker-sparql.c
index ebc8b6608..781ee469d 100644
--- a/src/libtracker-data/tracker-sparql.c
+++ b/src/libtracker-data/tracker-sparql.c
@@ -2293,6 +2293,9 @@ translate_Update (TrackerSparql *sparql,
*/
_call_rule (sparql, NAMED_RULE_Prologue, error);
+ sparql->current_state.blank_node_map =
+ g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
+
if (_check_in_rule (sparql, NAMED_RULE_Update1)) {
if (sparql->blank_nodes)
g_variant_builder_open (sparql->blank_nodes, G_VARIANT_TYPE ("aa{ss}"));
@@ -2308,6 +2311,9 @@ translate_Update (TrackerSparql *sparql,
_call_rule (sparql, NAMED_RULE_Update, error);
}
+ g_clear_pointer (&sparql->current_state.blank_node_map,
+ g_hash_table_unref);
+
return TRUE;
}
@@ -3818,9 +3824,6 @@ translate_InsertData (TrackerSparql *sparql,
g_variant_builder_open (sparql->blank_nodes, G_VARIANT_TYPE ("a{ss}"));
}
- sparql->current_state.blank_node_map =
- g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
sparql->current_state.type = TRACKER_SPARQL_TYPE_INSERT;
_call_rule (sparql, NAMED_RULE_QuadData, error);
@@ -3828,9 +3831,6 @@ translate_InsertData (TrackerSparql *sparql,
g_variant_builder_close (sparql->blank_nodes);
}
- g_clear_pointer (&sparql->current_state.blank_node_map,
- g_hash_table_unref);
-
return TRUE;
}
@@ -4155,9 +4155,6 @@ translate_InsertClause (TrackerSparql *sparql,
g_variant_builder_open (sparql->blank_nodes, G_VARIANT_TYPE ("a{ss}"));
}
- sparql->current_state.blank_node_map =
- g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-
sparql->current_state.type = TRACKER_SPARQL_TYPE_INSERT;
_expect (sparql, RULE_TYPE_LITERAL, LITERAL_INSERT);
@@ -4189,9 +4186,6 @@ translate_InsertClause (TrackerSparql *sparql,
g_variant_builder_close (sparql->blank_nodes);
}
- g_clear_pointer (&sparql->current_state.blank_node_map,
- g_hash_table_unref);
-
return TRUE;
}