Revise blank node semantics
First off, this is a divergence from Sparql/RDF that has huge repercussion in the way we use Tracker, so I'm not sure myself we should change to "the right behavior" by default, it would be good to have a TrackerSparqlConnectionFlags
value to enable this purer mode at least.
According to https://www.w3.org/TR/sparql11-query/#BlankNodesInResults, blank nodes in a resultset can only be guaranteed to be consistent within the resultset. The last phrase in that section is fairly clear: An application writer should not expect blank node labels in a query to refer to a particular blank node in the data.
This leaves plenty of room for differing implementations, some may return random numbers/strings that'll change on the next query, some (like us) generate a fixed string for that blank node, and always go with it.
And handling it like that should be fine. However there is a second implication we currently ignore: it should not be possible to query for specific blank nodes in the database. Eg. we allow things like:
SELECT ?p ?o { <urn:bnode:...> ?p ?o }
Which the sparql spec says can't happen, in a scattered but profuse manner.
And wikidata's sparql engine seems to agree, this query returns blank nodes, but it's then not possible to query them back
As said this is not an easy change. Tracker-miner-fs uses blank nodes very much often, and users expect to handle blank nodes as regular IRIs. It sounds possible to come up with a URI scheme, but it's admittedly helpful to have a unique "uri" generated for you.