[redland-dev] SQLite Storage Bug

Dave Beckett dave.beckett at bristol.ac.uk
Fri Apr 15 13:50:02 BST 2005


On Tue, 12 Apr 2005 09:57:30 -0500, Darrin Thompson <darrint at progeny.com> wrote:

> All,
> 
> I've been attempting to use the sqlite storage for redland, but get the
> following error:
> 
>   File "/usr/lib/python2.3/site-packages/RDF.py", line 852, in
> find_statements
>     statement._statement)
> RDF.RedlandError: SQLite database rdf SQL compile 'SELECT
>   SubjectURIs.uri     AS subjectUri,
>   SubjectBlanks.blank AS subjectBlank,
>   PredicateURIs.uri   AS predicateUri,
>   ObjectURIs.uri      AS objectUri,
>   ObjectBlanks.blank  AS objectBlank,
>   ObjectLiterals.text AS objectLiteralText,
>   ObjectLiterals.language AS objectLiteralLanguage,
>   ObjectLiterals.datatype AS objectLiteralDatatype,
>   ObjectDatatypeURIs.uri  AS objectLiteralDatatypeUri,
>   ContextURIs.uri         AS contextUri
> FROM triples AS T
>   LEFT JOIN uris     AS SubjectURIs    ON SubjectURIs.id    =
> T.subjectUri
>   LEFT JOIN blanks   AS a' failed - near " ": syntax error (1)
> 
> Notice the garbage character at the end of the quote. Here is a snip
> from hexdump -C, notice the 03.
> 000004c0  20 20 4c 45 46 54 20 4a  4f 49 4e 20 62 6c 61 6e  |  LEFT JOIN
> blan|
> 000004d0  6b 73 20 20 20 41 53 20  61 03 27 20 66 61 69 6c  |ks   AS a.'
> fail|
> 
> I'm using the redland packages from Debian.
> 
> $ apt-cache policy librdf0
> librdf0:
>   Installed: 1.0.0-2
>   Candidate: 1.0.0-2
>   Version Table:
>  *** 1.0.0-2 0
>         500 http://archive.progeny.com sarge/main Packages
>         500 http://archive.progeny.com unstable/main Packages
>         100 /var/lib/dpkg/status

Those are the latest yeah.

> I looked at the code myself but didn't see any obvious cause for this
> problem.

I also.  It's a garbage character in the middle of a fixed string that's appended to the earlier query.  Something else must be messing with the data.  If I found it
I'd do:
  valgrind --tool=memcheck --leak-check=yes --num-callers=20 /usr/bin/python /your/script

and look for errors...

or maybe gdb /usr/bin/python /your/script and set a breakpoint on raptor_stringbuffer_as_string to see what it actually constructs before giving it to sqlite3_prepare/sqlite_compile

I should point out that there is bug getting data out of sqlite that i have yet to fix, it's possible it's related:
  SQLite store skips triples when serializing
  http://bugs.librdf.org/mantis/view.php?id=6

Dave



More information about the redland-dev mailing list