Created
September 12, 2011 17:17
-
-
Save dajobe/1211808 to your computer and use it in GitHub Desktop.
4store reported query issue C test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
gcc -g -Wall -o rasqal-parsing rasqal-parsing.c `pkg-config rasqal --cflags --libs` | |
When this sequence of queries is parsed inside 4store this error is seen: | |
parser error: syntax error, unexpected $end, expecting integer literal on line 1 parser error: rasqal_new_typed_literal failed on line 1 | |
*/ | |
#include <rasqal.h> | |
static void | |
write_query_sparql(rasqal_world* world, rasqal_query* query, FILE* stream) { | |
raptor_iostream* iostr; | |
raptor_world* raptor_world_ptr = rasqal_world_get_raptor(world); | |
iostr = raptor_new_iostream_to_file_handle(raptor_world_ptr, stream); | |
rasqal_query_write(iostr, query, NULL, NULL); | |
raptor_free_iostream(iostr); | |
} | |
int | |
main(int argc, char* argv[]) | |
{ | |
static const unsigned char* query1 = | |
(const unsigned char*)"SELECT (?o as ?o2) WHERE { ?s ?p ?o } ORDER BY ?o" | |
; | |
static const unsigned char* query2 = | |
(const unsigned char*)"SELECT ?s WHERE { ?s ?p ?o } LIMIT 1" | |
; | |
rasqal_world *world; | |
fprintf(stdout, "Initialising world\n"); | |
world = rasqal_new_world(); | |
fprintf(stdout, "Query 1: '%s'\n", query1); | |
rasqal_query *q1 = rasqal_new_query(world, "sparql", NULL); | |
rasqal_query_prepare(q1, query1, NULL); | |
if(1) | |
write_query_sparql(world, q1, stdout); | |
else | |
rasqal_query_print(q1, stdout); | |
rasqal_free_query(q1); q1 = NULL; | |
fprintf(stdout, "Query 2: '%s'\n", query2); | |
rasqal_query *q2 = rasqal_new_query(world, "sparql", NULL); | |
rasqal_query_prepare(q2, query2, NULL); | |
if(1) | |
write_query_sparql(world, q2, stdout); | |
else | |
rasqal_query_print(q2, stdout); | |
rasqal_free_query(q2); q2 = NULL; | |
fprintf(stdout, "Freeing world\n"); | |
rasqal_free_world(world); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment