[redland-dev] Query Issues

Christopher Schmidt crschmidt at crschmidt.net
Wed Feb 9 05:26:02 GMT 2005


With the newest Redland installed, there are some issues related to, I 
believe, confusion in what the creation of an RDF Query object is in the 
Python bindings. Each of the following assumes that the Model is set up 
as follows:

import RDF
m = RDF.Model()
p = RDF.Parser()
p.parse_into_model(m, "http://crschmidt.net/foaf.rdf")

Unexepcted Identifier:

The following code produces a RedlandError:

q = RDF.Query("""PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?name
WHERE
  (?x rdf:type foaf:Person)
  (?x foaf:name ?name)
""")
i = q.execute(m)
for j in i:
	print j
RDF.RedlandError: 'syntax error, unexpected IDENTIFIER, expecting SELECT'

This is confirmed on OS X 10.3.7, Gentoo Linux 2004.0.

Repeated queries

This isn't something I'm sure is new: I think I've seen it before, but 
I'm mentioning it anyway. If you q.execute(m) twice in a row, the 
results are nil:

q = RDF.Query("SELECT ?n where (?p <http://xmlns.com/foaf/0.1/name> 
?n)")
i = q.execute(m)
i = q.execute(m)
for j in i:
	print j

Will print nothing, although there should be some results. Also, if you 
try:

q = RDF.Query("SELECT ?n where (?p <http://xmlns.com/foaf/0.1/name> ?n)")
i = q.execute(m)
i = q.execute(m)
print i

at this point, it will cause a segfault. Under OS X, it seems to catch 
the failure, reporting:
*** malloc[22468]: Deallocation of a pointer not malloced: 0x319230; 
This could be a double free(), or free() called with the middle of an 
allocated block; Try setting environment variable MallocHelp to see 
tools to help debug
A segmentation fault then appears to occur during cleanup.

A complete example code snippet:

import RDF    
m = RDF.Model()    
p = RDF.Parser()     
p.parse_into_model(m, "http://crschmidt.net/foaf.rdf")
q = RDF.Query("SELECT ?p where (?p foaf:nick 'crschmidt') using foaf for 
<http://xmlns.com/foaf/0.1/>")
i = q.execute(m)
i = q.execute(m)
print i                                                                         

This causes a bus error on OS X:
#0  rasqal_query_remove_query_result (query=0x3189d0, query_results=0x3188b0) 
at rasqal_query.c:769
#1  0x00282390 in rasqal_free_query_results (query_results=0x3188b0) at 
rasqal_query.c:798
#2  0x004aedd8 in librdf_free_query_results (query_results=0x3188b0) at 
rdf_query_results.c:230
#3  0x0020c360 in _wrap_librdf_free_query_results (self=0x3189d0, 
args=0x3188b0) at Redland_wrap.c:3013

and a Segfault on Linux

#0  rasqal_query_results_is_graph (query_results=0x0) 
    at rasqal_query.c:839
#1  0x404e7900 in librdf_query_rasqal_results_is_graph (query_results=0x0) 
    at rdf_query_rasqal.c:764
#2  0x404e64ea in librdf_query_results_is_graph (query_results=0x0)
    at rdf_query_results.c:404
#3  0x4002965b in _wrap_librdf_query_results_is_graph (self=0x0, args=0x0)
    at Redland_wrap.c:3064

These line numbers appear to match up with Redland 1.0 release, so 
hopefully it's not just a version issue this time.

Sparql XML Results

This one is more of a feature than a bug, but it's a different behavior 
than is expected: When issuing an RDQL Query, "print" ing the 
QueryResults prints the Sparql XML Results format. Since the original 
query is in RDQL, I'm not sure if this is expected behavior or not: One 
of my scripts became a lot more verbose all of a sudden. However, it is 
a nifty feature, so I'm perfectly willing to just accept that and move 
on.

RDFXML-Abbrev Serializer

I'm not really sure on the status on this one: it seems that it was left 
out of RDF.py for the release, so it may be that I'm jumping the gun 
here. However:

s = RDF.Serializer(name="rdfxml-abbrev")
s.serialize_model_to_string(m)

shows a large number of:

rdf_uri.c:201: (librdf_new_uri_from_uri) assertion failed: object 
pointer of type librdf_uri is NULL.

followed by a mostly empty RDF document with lots of <rdf:Description /> 
nodes and not a lot else. I'm not sure exactly how this serializer is 
supposed to be used, however, so as I said, this may be my mistake.

make check on both platforms claims that all tests pass.

I apologize for the length of this email. I also apologize if any of 
these errors are errors on my end in either configuration (*cough*) or 
use.

Thanks.

-- 
Christopher Schmidt

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.gnomehack.com/pipermail/redland-dev/attachments/20050209/8efc7608/attachment.pgp


More information about the redland-dev mailing list