[redland-dev] Problems with SPARQL's OPTIONAL pattern matching

Dave Beckett dave at dajobe.org
Mon Mar 6 04:41:54 GMT 2006


fiandro at tiscali.it wrote:
> Hi
> 
> i've encounterd some problems with the following SPARQL query 
> 
> "PREFIX rdf: <http://www.dajobe.org/foaf.rdf> PREFIX foaf: <http:
> //xmlns.com/foaf/0.1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> 
> SELECT ?x, ?y, ?name, ?depiction_title WHERE { ?x foaf:name ?name . ?x 
> foaf:depiction ?y . OPTIONAL { ?y dc:title ?depiction_title } }"
> 
> on the simple RDF document attached at the end of this email.

I tried that query with roqet and in redland 1.0.2 and it runs, giving
no answers on the data you give.  This is wrong, but I know that
OPTIONAL is buggy.

> If the "<dc:title>Me and my friends</dc:title>" line is removed from 
> the RDF document and the query is executed via roqet, i'm told that 
> some values are null but roqet exits correctly.

That didn't make any difference to me.

> attilio at attilaptop:~/rdf$roqet -qs "file:
> ///home/attilio/rdf/foaf/foaf_atti_simplified.rdf"  -e "PREFIX rdf: 
> <http://www.dajobe.org/foaf.rdf> PREFIX foaf: <http://xmlns.com/foaf/0.
> 1/> PREFIX dc: <http://purl.org/dc/elements/1.1/> SELECT ?x, ?y, ?name, 
> ?depiction_title WHERE { ?x foaf:name ?name . ?x foaf:depiction ?y . 
> OPTIONAL { ?y dc:title ?depiction_title } }" -i sparql
> result: [x=uri<file:///home/attilio/rdf/foaf/foaf_atti_simplified.
> rdf#i>, y=uri<http://www.swer.it/~attilio.fiandrotti/fossano/dscn4949.
> jpg>, name=string("Attilio fiandrotti"), depiction_title=NULL]

Cannot get this.

> if the query is done by a c# (or python) application (i did not try to 
> write a C application), it gets the following SIGSEV signal
> 
> Breakpoint 1, librdf_new_node_from_node (node=0x0) at rdf_node.c:624
> 624       LIBRDF_ASSERT_OBJECT_POINTER_RETURN_VALUE(node, librdf_node, 
> NULL);
> (gdb) p node
> $7 = (librdf_node *) 0x0
> (gdb) p *node
> Cannot access memory at address 0x0
> (gdb) bt
> #0  librdf_new_node_from_node (node=0x0) at rdf_node.c:624
> #1  0xb6db5563 in ?? ()
> #2  0x00000000 in ?? ()
> (gdb) c
> Continuing.
> rdf_node.c:624: (librdf_new_node_from_node) assertion failed: object 
> pointer of type librdf_node is NULL.
> 
> Program received signal SIGABRT, Aborted.
> 0xb7b2a7a7 in raise () from /lib/tls/libc.so.6

I think that particular bug is fixed in CVS, at least for python.

> Maybe i doing something wrong in my C# application, reported above 
> (i'm new to both redland and C#) ?
> Note that if the OPTIONAL constraint is removed, then i simply get no 
> matches, as expected, but no crashes.
> 
> thanks a lot

It is probably not your bug, but dealing with the effects of OPTIONAL
not working consistently.

If you want to pursue this, can you let me know the versions of
everything you are using which you didn't mention.  From the gdb
information, it looks like it is running on Linux, so that part is easy
to figure out.

Cheers

Dave



More information about the redland-dev mailing list