[redland-dev] NULL string for librdf_query_results_to_string() on empty results?

Dave Beckett dave at dajobe.org
Wed Jan 24 03:20:36 UTC 2007


Dutton, Jeff wrote:
> I am trying to implement a SPARQL endpoint webservice to a Redland
> database.  When I do a query that finds no results, the stringification
> of the query results is NULL (undef in Perl).  My understanding of the
> required XML output(http://www.w3.org/TR/rdf-sparql-XMLres/) for the
> results of an empty (but not malformed or otherwise errant) query should
> list the <head> section of selected variables and an empty <results>
> element.
>  
> My simple SELECT * WHERE { ?s ?p ?o } query isn't getting any errors
> when I put some data in the database, but when there is no data (or when
> the WHERE clause doesn't match any data I get this bogus string, with no
> error or warning from Redland.
>  
> I am using Redland v 1.0.4 with Rasqal 0.9.13.

You are correct, this is a bug.

It's a 1 line fix (this is redland 1.0.4)

--- rasqal/src/rasqal_query_results.c.orig      2006-04-29
23:38:19.000000000 -0700
+++ rasqal/src/rasqal_query_results.c   2007-01-23 19:18:31.000000000 -0800
@@ -737,7 +737,7 @@
                            raptor_uri *format_uri,
                            raptor_uri *base_uri)
 {
-  if(!results || results->failed || results->finished)
+  if(!results || results->failed)
     return 1;

   /*

Dave


More information about the redland-dev mailing list