# Rasqal RDF Query Library - Release Notes

## Rasqal 0.9.19 Changes

The only change to this release is to fix the pkg-config `rasqal.pc` file to to restore the dependency on raptor which was accidently deleted. Lesson learnt: do not commit code after midnight local time.

## Rasqal 0.9.18 Changes

The main changes in this release are:

- Add initial draft parsing and API (NOT execution) support for SPARQL 1.1 Update W3C Working Draft of 2010-01-26.
- Add public APIs (row, results, result formatter, variables table) so that query results can be built, read and written without a query.
- Add API resilience checks for invalid NULL pointer arguments.

Fixed Issues:

- 0000320: Add a void* user_data field to rasqal_variable
- 0000323: Official MIME Type for JSON isn't text/json
- 0000343: Mime type for 'table' results format is text/plan
- 0000345: MIME Type and URI for TSV and CSV
- 0000347: rasqal linking fix

### Query API Changes

A user data `void* user_data` field was added to the `rasqal_variable` structure to allow application code to store additional information.

Added a new `rasqal_query_verb` enum value for SPARQL 1.1 (draft) Update: `RASQAL_QUERY_VERB_UPDATE` which indicates that a sequence of update operations are available in the query structure, rather than a query (SELECT, ASK, DESCRIBE).

Added a `rasqal_update_operation` class for holding an updates that adds and/or removes triples from a graph (with possible conditional where) or does a graph administration operation on a grpah.

Added an `rasqal_update_type` enum for the types of graph update - clear, drop, delete, insert and, load.

Added `rasqal_update_type_label()` to get a label for a rasqal-update_type.

      const char* rasqal_update_type_label(rasqal_update_type type);

Added an `rasqal_update_flags` enum for capturing update operations flags such as SPARQL 1.1 Update `SILENT` for silent graph administration operations and `DATA` for bulk insert/delete data, rather than graph pattern templates with variables.

Added `rasqal_query_get_update_operations_sequence()` to get the sequence of updates from a query. Added `rasqal_query_get_update_operation()` get an individual update operation from a query via an index.

      raptor_sequence* rasqal_query_get_update_operations_sequence(rasqal_query* query);

      rasqal_update_operation* rasqal_query_get_update_operation(rasqal_query* query,
        int idx);

### Query Results Class Changes

`rasqal_new_query_results()` added to public API to construct a standalone query result set without being the result of a query execution. (The destructor is already present). Added method `rasqal_query_results_add_row()` to add a row to a query result set.

      rasqal_query_results* rasqal_new_query_results(rasqal_world* world,
         rasqal_query* query, rasqal_query_results_type type,
         rasqal_variables_table* vars_table);

      int rasqal_query_results_add_row(rasqal_query_results* query_results,
         rasqal_row* row);

`rasqal_query_results_type` enum added to public API for use with `rasqal_new_query_results()`.

### Query Results Formatter Class Changes

Registered URIs for the CSV and TSV query result formats and fixed the mime types for those as well as the JSON format as reported in issues Issue #0000345 and Issue #0000323.

Added `rasqal_new_query_results_formatter2()` with format name, mime type and URI args deprecating `rasqal_new_query_results_formatter()` and `rasqal_new_query_results_formatter_by_mime_type()`.

      rasqal_query_results_formatter* rasqal_new_query_results_formatter2(rasqal_world* world,
        const char *name, const char *mime_type, raptor_uri* format_uri);

Added `rasqal_query_results_write2()` and `rasqal_query_results_read2()` with both name and mime_type args deprecating `rasqal_query_results_write()` and `rasqal_query_results_read()` respectively.

      int rasqal_query_results_write2(raptor_iostream *iostr,
        rasqal_query_results *results, const char* name, const char* mime_type,
        raptor_uri *format_uri, raptor_uri *base_uri);

      int rasqal_query_results_read2(raptor_iostream *iostr,
        rasqal_query_results *results, const char* name, const char* mime_type,
        raptor_uri *format_uri, raptor_uri *base_uri);

### Query Result Row Class

Export the query result row class to the public API to allow creating standalone query results set without a query.

Added `rasqal_new_row_for_size()`, `rasqal_free_row()` to construct and destruct a row and `rasqal_row_set_value_at()` to set row literal values.

      rasqal_row* rasqal_new_row_for_size(rasqal_world* world, int size);

      void rasqal_free_row(rasqal_row* row);

      int rasqal_row_set_value_at(rasqal_row* row, int offset,
        rasqal_literal* value);

### Variables Table Class

Added variables table class `rasqal_variables_table` to the public API to allow use in creating a standalone query results.

Added `rasqal_new_variables_table()` and `rasqal_free_variables_table()` to construct and destroy a variables table. Added method `rasqal_variables_table_add()` to add a variable to the variables table.

      rasqal_variables_table* rasqal_new_variables_table(rasqal_world* world);

      void rasqal_free_variables_table(rasqal_variables_table* vt);

      rasqal_variable* rasqal_variables_table_add(rasqal_variables_table* vt,
        rasqal_variable_type type, const unsigned char *name,
        rasqal_literal *value);

### SPARQL Changes

Added syntax-only and API support (no execution) for the SPARQL 1.1 Update W3C Working Draft of 2010-01-26 syntax. These are only available when using the 'laqrs' query language name, until SPARQL 1.1 is stable.

Added new lexer support for keywords: WITH, CLEAR, CREATE, SILENT, DATA, DROP, LOAD

Added `CLEAR` and `CLEAR GRAPH uri`

Added `DROP GRAPH uri`

Added `INSERT DATA { triples }`

Added `DELETE templates` to delete multiple subgraphs.

Added `DELETE DATA { triples }`

Added `LOAD uri` and `LOAD uri INTO graph-uri`

Added `WITH uri DELETE { ... } INSERT { ... } WHERE ...` update form since other combinations are ambiguous.

NOTE: The older LAQRS experimental INSERT and DELETE formats are supported but deprecated.

### Query Engine changes

Nobody reported it, but decimal division was totally broken. Fixed it to do division and not add!

### Other Changes

Multiple code style updates and code file reorganizing.

Link `roqet` directly with `-lraptor` to get raptor symbols used linked directly, to enable alternate library linking approaches to work. Based on the request in Fixes Issue#0000347 and Fedora bug 564885.

Added checks for the public API methods to ensure NULL pointers are not accepted or used.

Added example code for constructing a query result set without a query

Updated `configure` and the build system to use silent rules for the maintainer (by default), or when `--enable-silent-rules` is passed to `configure`. This feature requires building with automake 1.11 which requires autoconf 2.62 or newer when building from GIT.

`autogen.sh` script was updated to enforce the autotools versions above.

The rasqal.pc file now uses the Requires.private field for raptor; it should only be in the link line with
`pkg-config --static ...` is used.

Enforce that only raptor versions <1.9.0 are supported. No Raptor2 or Raptor2 alpha support yet.

## Rasqal 0.9.17 Changes

> WARNING: ABI AND API CHANGED IN THIS RELEASE.

> This means: functions and structs were removed, modified and added.

> Consequently the shared library major soname version has changed from 1 to 2.

The main change in this release is to add a new query engine and to enable it as the default query engine. It supports more of the SPARQL query algebra such as groups and optionals. There were many other changes and fixes.

Fixed Issues: (most of them in query engine 2)

- Issue#0000077: OPTIONAL messes up query results
- Issue#0000128: GROUP graph pattern support in the query engine
- Issue#0000168: Wrong processing of the function "bound" with "OPTIONAL"
- Issue#0000258: Using FILTER with OPTIONAL in SPARQL queries
- Issue#0000261: Some SPARQL queries with multiple OPTIONAL patterns fail to return results
- Issue#0000271: rasqal library does not compile cleanly when using g++ compiler
- Issue#0000279: JSON query binding serializer is returning illegal JSON - extra double quotes before "ordered" and "distinct"
- Issue#0000305: bound gives incoherent results

### Rasqal world API changes

Added methods for setting of an already-opened raptor library to pass into rasqal, rather than it creating one itself. `rasqal_world_open()` can then be called to do the actual initialisation:

      int rasqal_world_open(rasqal_world* world);

      void rasqal_world_set_raptor(rasqal_world* world,
                                   raptor_world* raptor_world_ptr);

      raptor_world *rasqal_world_get_raptor(rasqal_world* world);

Exported new C defines for the library versions: `RASQAL_VERSION` in 6-digit integer MMNNRR format (Major, miNor, Release), `RASQAL_VERSION_STRING` in string "MM.NN.RR" format, `RASQAL_VERSION_MAJOR` for integer major version number, `RASQAL_VERSION_MINOR` for integer minor version number and `RASQAL_VERSION_RELEASE` for integer release number.

API CHANGE: `rasqal_features_enumerate()` gains an initial rasqal_world argument to become a method of the world class:

      int rasqal_features_enumerate(rasqal_world* world,
        const rasqal_feature feature, const char **name,
        raptor_uri **uri, const char **label);

API CHANGE: `rasqal_feature_from_uri()` gains an initial rasqal_world argument to become a method of the world class:

      rasqal_feature rasqal_feature_from_uri(rasqal_world* world,
        raptor_uri *uri);

### Data Graph API changes

API CHANGE: The `rasqal_data_graph` structure gains a new world reference pointer field.

API CHANGE: `rasqal_new_data_graph()` gains an initial rasqal_world argument:

      rasqal_data_graph* rasqal_new_data_graph(rasqal_world* world,
        raptor_uri* uri, raptor_uri* name_uri, int flags);

### Expression API changes

`rasqal_op` enumeration gains values for LAQRS (possible SPARQL 1.1) expression operators: `RASQAL_EXPR_SUM`, `RASQAL_EXPR_AVG`, `RASQAL_EXPR_MIN` and `RASQAL_EXPR_MAX`. It also gains `RASQAL_EXPR_COALESCE` for LAQRS experimental coalesce expression `COALESCE(expression list)`

API CHANGE: The `rasqal_expression` structure gains a new world reference pointer field.

API CHANGE: All `rasqal_expression` constructors gain an initial rasqal_world argument:

      rasqal_expression* rasqal_new_0op_expression(rasqal_world* world,
        rasqal_op op);
      rasqal_expression* rasqal_new_1op_expression(rasqal_world* world,
        rasqal_op op, rasqal_expression* arg);
      rasqal_expression* rasqal_new_2op_expression(rasqal_world* world,
        rasqal_op op, rasqal_expression* arg1, rasqal_expression* arg2);
      rasqal_expression* rasqal_new_3op_expression(rasqal_world* world,
        rasqal_op op, rasqal_expression* arg1,  rasqal_expression* arg2,
        rasqal_expression* arg3);
      rasqal_expression* rasqal_new_string_op_expression(rasqal_world* world,
        rasqal_op op, rasqal_expression* arg1, rasqal_literal* literal);
      rasqal_expression* rasqal_new_literal_expression(rasqal_world* world,
        rasqal_literal* literal);
      rasqal_expression* rasqal_new_function_expression(rasqal_world* world,
        raptor_uri* name, raptor_sequence* args);
      rasqal_expression* rasqal_new_cast_expression(rasqal_world* world,
        raptor_uri* name, rasqal_expression *value);

API CHANGE: `rasqal_expression_evaluate()` gains an initial rasqal_world argument:

      rasqal_literal* rasqal_expression_evaluate2(rasqal_world *world,
        raptor_locator *locator, rasqal_expression* e, int flags);

Added `rasqal_graph_pattern_get_origin()` to get the graph from a GRAPH graph pattern:

      rasqal_literal* rasqal_graph_pattern_get_origin(rasqal_graph_pattern* gp);

Added `rasqal_graph_pattern_set_filter_expression()` and `rasqal_graph_pattern_get_filter_expression()` methods to set/get an expression for a filter graph pattern:

      int rasqal_graph_pattern_set_filter_expression(rasqal_graph_pattern* gp,
        rasqal_expression* expr);

      rasqal_expression*
        rasqal_graph_pattern_get_filter_expression(rasqal_graph_pattern* gp);

### Graph Pattern API changes

`rasqal_graph_pattern_operator` enumeration gains `RASQAL_GRAPH_PATTERN_OPERATOR_FILTER` for a filter graph pattern and `RASQAL_GRAPH_PATTERN_OPERATOR_LET` for LAQRS experimental assignment 'graph pattern'.

API CHANGE: Removed functions `rasqal_graph_pattern_add_constraint()`, `rasqal_graph_pattern_get_constraint_sequence()` and `rasqal_graph_pattern_get_constraint()`. These are replaced by filter graph pattern with expression - functions `rasqal_graph_pattern_set_filter_expression` and `rasqal_graph_pattern_get_filter_expression()`.

### LAQRS Changes

LAQRS is now available in the configuration and does not need to be explicitly selected with `configure`.

Add `SUM()`, `AVG()`, `MIN()` and `MAX()` aggregate expressions to LAQRS. Supported in syntax only, not in any of the query engines.

Add `LET ?var := expression` experimental syntax. Query engine 2 can execute this.

Add `COALESCE(expression list)` experimental expression to return the first defined expression value in the list. Query engines 1 and 2 can execute this.

### Literal API changes

API CHANGE: Reordered `rasqal_literal_type` enumeration to match numeric type promotion order: float is now between integer and double. Also added `RASQAL_LITERAL_XSD_STRING` for xsd:string typed literals and `RASQAL_LITERAL_UDT` for unknown data typed literals. Both were separated out of `RASQAL_LITERAL_STRING` which is now for RDF plain literals and plain/typed turned into RDF terms only

Added `rasqal_literal_get_rdf_term_type()` method to return the RDF term type of a literal as a `rasqal_literal_type` - uri, blank node, literal or cannot be represented (e.g. qname or internal literal types).

      rasqal_literal_type rasqal_literal_get_rdf_term_type(rasqal_literal* l);

Added `rasqal_literal_same_term()` method to perform SPARQL sameTerm() comparison.

      int rasqal_literal_same_term(rasqal_literal* l1, rasqal_literal* l2);

Added `rasqal_literal_is_rdf_literal()` method to check if a literal is an RDF literal (not qname or other internal types).

      int rasqal_literal_is_rdf_literal(rasqal_literal* l);

### Prefix API changes

API CHANGE: The `rasqal_prefix` structure gain a new world reference pointer field.

API CHANGE: `rasqal_new_prefix()` gains an initial rasqal_world argument:

      rasqal_prefix* rasqal_new_prefix(rasqal_world* world,
        const unsigned char* prefix, raptor_uri* uri);

### Query API changes

Added `rasqal_query_dataset_contains_named_graph()` method to check if a named graph is in a dataset:

      int rasqal_query_dataset_contains_named_graph(rasqal_query* query,
                                                    raptor_uri *graph_uri);

### Query Formatter Changes

SPARQL `DESCRIBE` no longer writes commas between terms.

### Query Results API changes

Added `rasqal_query_results_get_query()` method to get the associated query:

      rasqal_query*
        rasqal_query_results_get_query(rasqal_query_results* query_results);

Added `rasqal_graph_pattern_variable_bound_in()` method to check if a graph pattern in a query defines a variable

      int rasqal_graph_pattern_variable_bound_in(rasqal_graph_pattern *gp,
        rasqal_variable *v);

### Query Results Formatter Changes

SPARQL/JSON: Do not emit double " for distinct/ordered flags. Fixes Issue #0000279

Added comma-separated values (CSV), tab-separated values (TSV) and text table output formats with names `csv`, `tsv` and `table`.

### RDQL Changes

Some updates to handle refactored query list of constraint expressions switching to a filter graph pattern. RDQL only has 0 or 1 such expressions in a single query.

### SPARQL Changes

Ensure GroupOrUnionGraphPattern rule constructs the sequence of graph patterns in document order.

OptionalGraphPattern rule is now a list of 1 group graph patterns.

Fix support for `<>` URI literal.

Support `\b`, `\f`, `\'` and `\"` escapes in all types of quoted literals.

Fixed optional `WHERE` in parser to match SPARQL grammar - optional for `DESCRIBE`, but required for `SELECT`, `CONSTRUCT` and `ASK` queries.

### Triples Source API changes

API CHANGE: The `rasqal_triples_source` and `rasqal_triples_source_factory` structures gain API version fields that must be set to a known API version.

API CHANGE: The `rasqal_set_triples_source_factory()` function for registering a triples source factory now take a function with an int error return code, and it returns an int now:

      int rasqal_set_triples_source_factory(rasqal_world* world,
         rasqal_triples_source_factory_register_fn register_fn,
         void* user_data);

### Variable API changes

API CHANGE: The `rasqal_variable` structure gains a variables table pointer.

### Other API changes

`rasqal_triple_parts` adds value `RASQAL_TRIPLE_NONE` for no parts.

`rasqal_compare_flags` enumeration gains `RASQAL_COMPARE_URI` - now also provides RDQL string to bool comparison.

API CHANGE: `rasqal_new_xsd_decimal()` gains an initial rasqal_world argument:

      rasqal_xsd_decimal* rasqal_new_xsd_decimal(rasqal_world* world);

Removed `rasqal_triple_flags` enumeration with unused values: `RASQAL_TRIPLE_FLAGS_EXACT`, `RASQAL_TRIPLE_FLAGS_OPTIONAL` and `RASQAL_TRIPLE_FLAGS_LAST`

### Configure and Build Changes

configure now prefers `pkg-config raptor` to `raptor-config` but will accept both for now. `pkg-config` will not allow compiling against raptor in source tree in future.

Added `--with-query-engine-version` to configure to allow selecting default query engine version - values 1 or 2. This is allowed for people to switch to old engine if necessary for some existing query that the new engine cannot handle. This option will be removed at some point.

Add SHAVE support (`git clone git://git.lespiau.name/shave` ) to "make autotools output sane" which amounts to much less verbose messages when compiling. It is now enabled for the maintainer.

`rasqal-config(1)` is now a wrapper around `pkg-config rasqal`. Consequently `--prefix=DIR` and `--libtool-libs` are ignored.

### Query Engine Changes

An entirely new query execution engine was written. The existing query execution engine was refactored out of a mess of `rasqal_query` and `rasqal_query_results` code and data. It is the default query engine as of Rasqal 0.9.17

The query engine to use can be selected at configure time wiht `--with-query-engine-version` to allow switching to old engine if necessary for some existing query that the new engine cannot handle. This option will be removed at some point.

The interface between the query API and the query engine is now via the `rasqal_rowsource` abstraction - an evaluation of a query returns a rowsource that generates the result rows of variable bindings.

Rewrote `query_results` class to be a pure wrapper around the rowsource and variables table, handling such things like generating triples (CONSTRUCT) from rows, creating a boolean result (ASK) by counting at least 1 result rows and generating syntax results using a query results formatter.

Added a new `rasqal_query_execution_factory` abstraction to provide the interface that the query execution engines implement to return a rowsource to get the results.

Both query engines can potentially be selected at runtime from the query API but ONLY when rasqal is built for development (`configure --enable-maintainer-mode`).

1. If the envariable `RASQAL_DEBUG_ENGINE` is set with value 1 or 2, the query execution engine is chosen.
2. The `roqet(1)` utility gains a `-g` / `--engine` argument.

Query engine 1 (existing):
Existing lazy evaluated engine that is hard to refactor. Internally, implemented by functions named `rasqal_query_engine_1_...()`. Execution factory instance `rasqal_query_engine_1`

Query engine 2 (new):
Based on transforming a tree of SPARQL algebra nodes constructed from the query, into a tree of rowsource-generating expressions that when evaluated at the top, returns the result rows. Each algebra node type and each rowsource type has it's own set of module unit tests built-in. Execution factory instance `rasqal_query_engine_algebra`

Removed query engine core legacy support for `CONSTRUCT *` - never in the SPARQL 1.0 language.

Pulled out row sorting code from query engine 1 into a rasqal_engine_sort module so it can be used by all query engines.

Implemented rowsource abstraction `rasqal_rowsource` for the following types of rowsources:

- empty rowsource: always returns no rows
- filter rowsource: filter an inner rowsource with an expression - used for SPARQL `FILTER`
- graph rowsource: apply a graph variable to an inner rowsource - used for SPARQL `GRAPH` matching
- join rowsource: join two inner rowsources on common variables and an expression. Two types of join supported: left outer join used for SPARQL `OPTIONAL` and natural join for groups of graph patterns.
- project rowsource: pick [project] certain variables from an inner rowsource
- query engine execution rowsource: rows generated by a query execution engine
- row sequence rowsource: built from a sequence of rows
- SPARQL xml rowsource: make rows from SPARQL Results XML syntax
- triples rowsource: create a rowsource by binding variables to an RDF graph sort rowsource: sorts the inner rowsource by an order expression - used for SPARQL `ORDERBY`
- union rowsource: union/concatenation of two inner rowsources - used for SPARQL `UNION`

Renamed row abstraction from `rasqal_query_result_row` to `rasqal_row` since it is independent of query results and shorter.

Use new `rasqal_engine_error` enumeration for query engine/internal errors - OK, FAILED or FINISHED rather than altering `rasqal_query_results` object fields directly.

Documented query execution engine internals as autodocs.

Added a query algebra abstraction `rasqal_algebra` with node type `rasqal_algebra_node_operator` based on SPARQL algebra operators: BGP, FILTER, JOIN, DIFF, LEFTJOIN, UNION, TOLIST, ORDERBY, PROJECT, DISTINCT, REDUCED, SLICE and GRAPH. Some of these are not needed by the query execution engines since they are handled by the high level query API - such as SLICE (limit and offset) and TOLIST (turning results into user data)

Added a variables table abstraction `rasqal_variables_table` pulled out of the internal query results and query structures which now point to it. Constructor `rasqal_new_variables_table()`, destructor `rasqal_free_variables_table()` and methods `rasqal_variables_table_add()`, `rasqal_variables_table_get()`, `rasqal_variables_table_has()`, `rasqal_variables_table_set()`, `rasqal_variables_table_get_value()`, `rasqal_variables_table_get_named_variables_count()`, `rasqal_variables_table_get_anonymous_variables_count()`, `rasqal_variables_table_get_total_variables_count()`, `rasqal_variables_table_get_named_variables_sequence()` and `rasqal_variables_table_get_anonymous_variables_sequence()`.

Allow queries with no graph pattern to be accepted such as SPARQL `DESCRIBE uri` (which the query engine does not execute at present but now is at least parsed).

Do not warn about unbound variables for variables bound in GRAPH and SELECT expressions.

Renamed query language-specific factory class for creating query structure from SPARQL and RDQL syntaxes from `struct rasqal_query_engine_factory` to `rasqal_query_language_factory` since it is about the language, not the engine.

Query engine known problems:

- Variable binding/use scope is not calculated correctly.
- Consequently no queries with `UNION` work correctly.
- Also consequently, some `OPTIONAL` queries execute and return results when they shouldn't due to scoping of variable rules especially in nested optionals.
- `DISTINCT` uses RDF literal equality not RDF sameTerm equality and thus returns results not to spec.
- `xsd:date` comparison is not date-aware, it uses a simple string equality
- `REDUCED` is not implemented.

Summary of the approved DAWG SPARQL 1.0 tests as of Rasqal SVN r15841

    Fail:       22 (4.99 %)
        algebra                        4
        dataset                        3
        distinct                       4
        graph                          2
        open-world                     3
        optional                       4
        reduced                        2
    Pass:      419 (95.01 %)

The above results in EARL: RDF/XML and Turtle

### Internal Changes

Added sparql algebra tests based on the examples in the SPARQL 1.0 Query Language Specification section 12.2.1 Converting Graph Patterns

Optionally support the experimental raptor V2 API.

Lots of resiliency fixes in the case of out of memory - Lauri Aalto.

Adjusted internal test suite to use a perl `improve` script that generates and uses an RDF-based manifest. The test running is now much more consise when successful.

Switch to final DAWG approved testsuite files from http://www.w3.org/2001/sw/DataAccess/tests/r2/ at CVS Revision 1.6 1008

## Rasqal 0.9.16 Changes

> WARNING: ABI AND API CHANGED IN THIS RELEASE.

> This means: functions were removed, modified and added.

> Consequently the shared library major soname version has changed from 0 to 1.

> The header files moved to be installed in PREFIX/include/rasqal such as `/usr/include/rasqal` for usual installs.

> NOTE: In the next release of rasqal, the `rasqal-config` utility that provides the compile and link args will be deprecated, generate a warning when run and will turn into a wrapper for `pkg-config rasqal ...` It will be removed in a future release.

### Major Changes (break ABI and API)

Removed `rasqal_init()` and `rasqal_finish()` functions.

Added a new `rasqal_world` object to manage library allocations and classes with new library constructor/initializing function `rasqal_world *rasqal_new_world(void)` and destructor/cleanup function: `void rasqal_free_world(rasqal_world*)`

The following functions now take a `librdf_world* world` argument as the first argument: `rasqal_language_name_check()`, `rasqal_languages_enumerate()`, `rasqal_new_query()`, `rasqal_query_results_formats_check ()`, `rasqal_new_query_results_formatter()`, `rasqal_new_query_results_formatter_by_mime_type()`, `rasqal_new_integer_literal()`, `rasqal_new_typed_literal()`, `rasqal_new_double_literal()`, `rasqal_new_float_literal()`, `rasqal_new_uri_literal()`, `rasqal_new_pattern_literal()`, `rasqal_new_string_literal()`, `rasqal_new_simple_literal()`, `rasqal_new_boolean_literal()`, `rasqal_new_variable_literal()`, `rasqal_new_decimal_literal()`, `rasqal_new_decimal_literal_from_decimal()`

Removed deprecated `rasqal_new_floating_literal()`, `rasqal_graph_pattern_get_flags()`, `rasqal_expression_foreach()` functions, `RASQAL_LITERAL_FLOATING` macro and `rasqal_expression_foreach_fn` typedef.

Modified `rasqal_triples_match` struct to add a rasqal_world* world field.

There is no more static data such as error pointers, arrays of query languages, URI objects; it is all attached to the rasqal_world object.

### Misc changes

Fixed memory leaks in lang() expression evaluation. (Lauri Aalto)

Made several low-memory resiliance fixes in query construction and execution. (Lauri Aalto)

Library requires raptor 1.4.17 or newer to get the newly public raptor SAX2 API for reading SPARQL XML Results format.

Updated mpfr configure check to look for modern functions rather than functions that are also in the older gmp-mpfr library too.

Only the first error is reported for syntax errors in lex/parse of SPARQL and RDQL since the lack of error recovery means that the consequent messages are of little use.

Fatal errors in SPARQL and RDQL lexer/parser no longer does an abort, but exits via setjmp/longjmp.

### Query Engine Changes

Added internal rowsource class to get rows from an execution engine or a syntax (query result formatter).

### Graph Pattern Class Changes

Modified `rasqal_graph_pattern_add_sub_graph_pattern()` to have an int return value for catching allocation failures.

### Query Class Changes

Modified `rasqal_query_add_variable()` and `rasqal_query_add_prefix()` to have int return values for catching allocation failures.

### Query Results Class Changes

Updated the internals to allow construction of a query result outside the query engine, such as from a syntax.

Added `rasqal_query_results_read()` to read a query results from an iostream in some format.

Modified `rasqal_query_results_formats_enumerate()` to add a flags argument with `RASQAL_QUERY_RESULTS_FORMAT_FLAG_READER` and `RASQAL_QUERY_RESULTS_FORMAT_FLAG_WRITER` choices to choose formats for read or write enumeration.

Removed function `rasqal_query_results_formats_enumerate_full` now handled by `rasqal_query_results_formats_enumerate()`.

Added `rasqal_query_results_formatter_read()` to read query results from a syntax via an iostream.

### Variable Class Changes

Added `rasqal_new_variable_from_variable()` copy constructor.

## Rasqal 0.9.15 Changes

### General Changes

Many updates for better SPARQL support. Rasqal 0.9.15 passes over 92% of the DAWG SPARQL Test Suite as of 2007-11-13.

Rasqal still does not support either `UNION` or `GROUP` and `OPTIONAL` remains buggy. There remain a few other minor areas not yet completely supported such as XSD `date` and XSD `dateTime` equality and comparisons.

> WARNING: ABI AND API CHANGE in Rasqal 0.9.16. The next release of Rasqal will be incompatible with this one.

> It will have both ABI and API changes that will require source updates.

> The shared library major soname will change from 0 to 1.

> The header files will move to be installed in PREFIX/include/rasqal such as `/usr/include/rasqal` for usual installs.

> The full details of the API change have not been decided but the driving change is that using the library will be done via a new Rasqal world object,k will now be used to working like a Redland `librdf_world`. All constructors will take this world object as an argument and all static data will be indirected from the object. Handlers such as the uri_handler/data and error handlers will also move to be set/get via the world object.

> There are almost certainly other API changes and cleanups that will be done, and some possibly some of the data structures may be made internal.

Fixed issues:

- Issue#0000190: Memory leaks in rasqal_literal.c
- Issue#0000191: RAPTOR_API in rasqal.h
- Issue#0000193: SPARQL "ASK" always returns true
- Issue#0000196: Memory leak with RASQAL_REGEX_PCRE
- Issue#0000197: Problem with float comparison in rasqal
- Issue#0000198: rasqal_redland.c compilation errors
- Issue#0000199: SPARQL effective boolean value: empty string literal not false
- Issue#0000200: SPARQL filter scope
- Issue#0000201: SPARQL langMatches patch
- Issue#0000203: API declarations for Symbian portability
- Issue#0000204: SPARQL WHERE is optional
- Issue#0000219: SPARQL BASE makes rasqal query->locator.uri a dangling pointer
- Issue#0000220: Query offset off by one
- Issue#0000221: rasqal_literal_as_integer() with RASQAL_LITERAL_INTEGER literals
- Issue#0000225: SPARQL parser leaks memory on syntax error
- Issue#0000234: autogen.sh $dir quoting
- Issue#0000235: $(EXEEXT) in tests
- Issue#0000236: EOL issues when building svn version on cygwin

### SPARQL Query Language Changes

Many updates to support the SPARQL Candidate Recommendation and Proposed Recommendation versions of the language including:

- Added `REDUCED` syntax support (no query engine support)
- Added `SAMETERM()` support.
- Allowing numbers at the start of local names.
- Allowing `@`lang and `^^`datatype after triple-quoted literals.
- Make unary + and - work
- Remove `CONSTRUCT *` that is no longer in the spec
- Removed hexadecimal literals which were never in the spec
- Made queries with the `ASK` verb work again.
- Made `LANG()` and `DATATYPE()` work to spec on typed literals.
- Remove warning about optional SPARQL `WHERE` although it is still a dumb idea to have useless keywords.

### Query Engine Changes

Many internal changes were made including refactoring the engine core and adding of additional internal documentation for the engine functions.

Substantial improvements were made to datatypes support:

- SPARQL / XQuery / XPath numeric type promotion is now supported, including derived types of `xsd:integer` etc.
- Added XSD `xsd:decimal` implementation either using GNU MP, MPFR, C99 `_Decimal` (but I have yet to find a working implementation) or by default and inaccurately, C doubles.
- Added XSD `xsd:dateTime` initial support for validation.
- Numeric operations such as +, -, *, / and ! as well as comparisons are now done in the appropriate datatype (which may be a promotion).

Improved the way that literal equality and comparisons work especially with respect to datatypes. Triple pattern matching (equality) works with RDF terms. SPARQL `FILTER` literal equality and comparisons follow SPARQL rules with possible numeric type promotion, then using RDF Term if the types are different. `ORDER` comparison or `DISTINCT` equality checks use RDF Term. RDQL execution uses it's own existing "stringy" rules.

Set the query base URI.

Make queries that bind the origin (SPARQL `GRAPH`) match correctly against the default graph.

Memory reduction in stack usage when evaluation expressions (such as SPARQL `FILTER`s).

### Public API changes

Added `rasqal_home_url_string` static constant.

Added `rasqal_xsd_decimal` class and API calls described below.

Added a `decimal` part to the rasqal_literal union value for `RASQAL_LITERAL_DECIMAL` types.

Added a `parent_type` part to the rasqal_literal when the type can be promoted.

Added `RASQAL_EXPR_SAMETERM` expression

Added `RASQAL_COMPARE_RDF` and `RASQAL_COMPARE_URI` comparison types for RDF Term comparsion rules and allowing URI comparison (without `STR()`) respectively.

Added `rasqal_new_typed_literal()` to make an RDF typed literal from a type and string (no language).

Added `rasqal_new_float_literal()` for wrapping a C `float` as XSD float.

Added new decimal literal constructor rasqal_literal* rasqal_new_decimal_literal_from_decimal(const unsigned char *string, rasqal_ xsd_decimal* decimal)

Added `rasqal_literal_datatype` method to get the datatype URI of a literal.

Added `rasqal_literal_value` method to get the literal value of a literal, looking up any variables to their value. FIXME should this not involve query results?

Added addition `rasqal_triple_parts` enums: `RASQAL_TRIPLE_GRAPH` for just the named graph part `RASQAL_TRIPLE_SPO` for subject, predicate and objects and `RASQAL_TRIPLE_SPOG` for all parts including named grpah.

### Decimal Class

A new `rasqal_xsd_decimal` class was added to handle XSD decimals with accurate decimal arithmetic.

Constructor:

    rasqal_xsd_decimal* rasqal_new_xsd_decimal(void);

Destructor:

    void rasqal_free_xsd_decimal(rasqal_xsd_decimal* dec);

Methods:

    double rasqal_xsd_decimal_get_double(rasqal_xsd_decimal* dec);
    int rasqal_xsd_decimal_set_double(rasqal_xsd_decimal* dec, double d);
    iint rasqal_xsd_decimal_set_string(rasqal_xsd_decimal* dec, const char* string);
    int rasqal_xsd_decimal_set_long(rasqal_xsd_decimal* dec, long l);
    int rasqal_xsd_decimal_print(rasqal_xsd_decimal* dec, FILE* stream);
    char* rasqal_xsd_decimal_as_string(rasqal_xsd_decimal* dec);
    char* rasqal_xsd_decimal_as_counted_string(rasqal_xsd_decimal* dec, size_t* len_p);

Numeric methods (writing to the `result` argument):

    int rasqal_xsd_decimal_add(rasqal_xsd_decimal* result,
                               rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
    int rasqal_xsd_decimal_subtract(rasqal_xsd_decimal* result,
                                    rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
    int rasqal_xsd_decimal_multiply(rasqal_xsd_decimal* result,
                                    rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
    int rasqal_xsd_decimal_divide(rasqal_xsd_decimal* result,
                                  rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
    int rasqal_xsd_decimal_negate(rasqal_xsd_decimal* result,
                                  rasqal_xsd_decimal* a);

Comparison methods:

    int rasqal_xsd_decimal_compare(rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
    int rasqal_xsd_decimal_equals(rasqal_xsd_decimal* a, rasqal_xsd_decimal* b);
    int rasqal_xsd_decimal_is_zero(rasqal_xsd_decimal* d);

### Query Results Formatter Class Changes

Updated to the 4th version of the SPARQL XML Results format by removing the `ordered` and `distict` attributes. Removed support for all the earlier versions 1 to 3.

### `roqet` Utility Changes

Added `-D` / `--data` options for specifying data URis for the default graph and `-G` / `--named` for URIs of named graphs (the existing `-s` is a also a synonym for the latter).

### Other Changes

Many internal fixes and cleanups after failures so that memory is not lost and/or rasqal does not crash. These many changes were primarily made by Lauri Aalto.

Several portability fixes for helping with low-memory, embedded systems and using a compiler that is not gcc.

The SPARQL test runner `check-sparql` was improved to read the SPARQL XML Results format (but not via `XML::Simple` because it is insanely complex and counterintuitive), handle DAWG test manifests and generate EARL reports. It also has new help and usage messages.

## Rasqal 0.9.14 Changes

### General Changes

Added syntax and API support (but no query engine support) for experimental extensions to SPARQL called LAQRS: LAQRS Adds to Querying RDF in SPARQL.

Updated the query results formatter to allow better introspection of supported formats.

Fixed issues:

- Issue#0000152: Allow `<_:NAME>` to work as `_:NAME` in SPARQL.
- Issue#0000156: Add LAQRS extensions to SPARQL grammar
- Issue#0000160: rasqal_strcasecmp without prototype
- Issue#0000167: Make CONSTRUCT work with LIMIT
- Issue#0000182: Allow '-' in SPARQL language tags (and RDQL)

### LAQRS Adds to Querying RDF in SPARQL (LAQRS)

LAQRS is experimental and Rasqal provides only syntax and API support (but no query engine support) for:

- `DELETE` via query verb `RASQAL_QUERY_VERB_DELETE`
- `EXPLAIN` as a keyword allowed before any query. Returned by `rasqal_query_get_explain()`
- `INSERT` via query verb `RASQAL_QUERY_VERB_INSERT`
- `COUNT()` and COUNT(*) via new expressions `RASQAL_EXPR_COUNT` and `RASQAL_EXPR_VARSTAR`
- `SELECT` expression `AS` variable via the new expression field of rasqal_variable
- `GROUP BY` results via rasqal_query_get_group_conditions_sequence() and rasqal_query_get_group_condition() and new expressions `RASQAL_EXPR_GROUP_COND_ASC` and `RASQAL_EXPR_GROUP_COND_DESC`

Repeating THERE IS NO QUERY ENGINE SUPPORT FOR ANY OF THE ABOVE

LAQRS is not enabled by default in Rasqal (unless using maintainer mode or building from Subversion). To enable it, configure Rasqal like this:

    $ ./configure '--enable-query-languages=sparql rdql laqrs'
    ...

    Rasqal build summary:
      RDF query languages available : rdql sparql
      RDF query languages enabled   : sparql rdql laqrs
      Triples source                : raptor 1.4.15
    $

The API changes for LAQRS are as follows:

Added new query verbs `RASQAL_QUERY_VERB_DELETE` and `RASQAL_QUERY_VERB_INSERT`

Added a constructor to create a constant or 0-operand expression (for COUNT):

    rasqal_expression* rasqal_new_0op_expression(rasqal_op op);

Added a query method to get the explain flag:

    int rasqal_query_get_explain(rasqal_query* query);

Added a query method to get the 'group by' condition expressions:

    raptor_sequence*
    rasqal_query_get_group_conditions_sequence(rasqal_query* query);

    rasqal_expression*
    rasqal_query_get_group_condition(rasqal_query* query, int idx);

Added `rasqal_expression` expression types:

- `RASQAL_EXPR_GROUP_COND_ASC` for group condition ascending.
- `RASQAL_EXPR_GROUP_COND_DESC` for group condition descending.
- `RASQAL_EXPR_COUNT` for select `COUNT()`
- `RASQAL_EXPR_VARSTAR` for select `COUNT(*)`

`rasqal_variable` now has a `rasqal_expression*` field `expression`.

### Configuration and Build Changes

The pkgconfig rasqal.pc file and the `rasqal-config` script now separates directly linked shared libraries and indirectly linked ones. This prevents unnecessary references to libraries. The regular libraries includes -L plus `-lrasqal` and the dynamic and static libraries are available with:

- `pkgconfig rasqal --static --libs`
- `rasqal-config --libs --private-libs`

So for example to statically link with rasqal, use either:

    $ cc .. -o foo foo.c `pkgconfig rasqal --static --libs`

    $ cc .. -o foo foo.c `rasqal-config --libs --private-libs`

### Query Results Formatter Changes

Made it easier to discover and create of query results in a syntax by using a MIME Type.

Added query results formatter constructor by required mime type:

    rasqal_query_results_formatter*
    rasqal_new_query_results_formatter_by_mime_type(const char *mime_type);

Added a method to return the mime type of a selected formatter:

    const char*
    rasqal_query_results_formatter_get_mime_type(
      rasqal_query_results_formatter *formatter);

Added another query results formatter static method to enumerate possible results formats, their names, labels and (new) mime type.

    int
    rasqal_query_results_formats_enumerate_full(const unsigned int counter,
      const char **name, const char **label,
      const unsigned char **uri_string, const char **mime_type);

Added a static method to check for support for a query results format.

    int rasqal_query_results_formats_check(const char *name,
      raptor_uri* uri, const char *mime_type);

### SPARQL Query Language Changes

Updated for the SPARQL Query Language for RDF, W3C Working Draft 26 March 2007

- Added `REDUCED` token. This entailed changing the distinct flag from a boolean to a mode. `rasqal_query_get_distinct` and `rasqal_query_set_distinct` now takes a mode (0, 1 DISTINCT, 2 REDUCED) rather than the former boolean flag. There is no query engine support for REDUCED at present.

### Query Engine Changes

Added the possibility that a query's native result is a syntax (rather than natively bindings, boolean or triples) and added a method to check for that:

    int rasqal_query_results_is_syntax(rasqal_query_results* query_results);

Many query engine internal changes, but these remain unsupported: OPTIONAL graph pattern (partially working), GROUP graph pattern (no support), UNION graph pattern (no support) and new `SELECT REDUCED` (no support).

### `roqet` Utility Changes

`roqet` can use -r to generate a chosen result syntax for bindings results or triples (using raptor).

roqet now generates namespace declarations for triples when serializing output. The result is that they are used when the serializer handles them such as generating RDF/XML (Abbreviated) or Turtle.

### Other Changes

`rasqal_expression` lost the unused `rasqal_variable*` field `variable`

Added exported variables to return the license string in `rasqal_license_string` and home page in `rasqal_home_url_string`

## Rasqal 0.9.13 Changes

### General Changes

Added a new `rasqal_query_results_formatter` class.

Many internal query engine changes, mostly to separate query and query_results internals so that eventually the run-time execution context is entirely separated from the static query structure.

Added query features system with one initial feature `RASQAL_FEATURE_NO_NET`.

### Configuration and Build Changes

Allow shell variable `LEX` to be set to things that aren't exactly `flex` Recommend flex 2.5.33 and update configure to point at the main flex site whichq finally gets 2.5.33 after 9 years.

`PKGCONFIG` vars not substituted correctly in configure.ac. Remove @LDFLAGS from rasqal.pc.in. Fixes Issue#0000098.

Win32 build fixes.Correct win32 static linking of rasqal. (Fixes Issue#0000100) and include float.h and `#define isnan` on win32. (Fixes Issue#0000111).

In maintainer mode, add all the supported compiler `-W` warning flags to the CFLAGS.

Declare several rasqal functions with GCC printf-formatting attributes when using a new enough GCC.

Remove broken debug messages. #0000131.

### SPARQL Query Language Changes

Added labels to grammar tokens using bison to give better error messages.

Fix looking for EOF in an unsigned variable since it may be negative on some systems.

The query engine now implements SPARQL `GRAPH` matching.

### RDQL Query Language Changes

Added labels to grammar tokens using bison to give better error messages.

Fix looking for EOF in an unsigned variable since it may be negative on some systems.

### Query Engine Changes

The query engine now implements SPARQL `GRAPH` matching.

Merge only all adjacent sequences of basic graph pattern triples, not anything with triples such as optional BGP triples. Fixes Issue#0000080.

When an exact triple match is present, do not execute a query forever. Fixes Issue#0000094.

Fail if a variable argument to `LANG()` has an undefined value rather than try to execute a NULL pointer. Fixes Issue#0000113.

Add query / query_results link early so reference counting is done right. Fixes Issue#0000095.

Report failure as well as query finished when an error occurs during making results. Fixes Issue#0000118.

Added a hack to check an outer constraint expression. Fixes Issue#0000129.

Free origins (`GRAPH` nodes) in triples to prevent memory leak. Fixes Issue#0000133.

### Query API Changes

Added a new `rasqal_query_results_formatter` class to format `librdf_query_results` into a syntax. Also added a `rasqal_query_results_formats_enumerate()` function to enumerate all the supported formats. The query results method `rasqal_query_results_write()` was changed to use this class internally.

Added a new feature system to allow setting parameters on the query parser/engine. Initially have one feature `RASQAL_FEATURE_NO_NET` that prevents network requests during a query execution. Added functions: `rasqal_features_enumerate`, `rasqal_get_feature_count`, `rasqal_feature_from_uri`, `rasqal_feature_value_type`, `rasqal_query_set_feature`, `rasqal_query_set_feature_string`, `rasqal_query_get_feature`, `rasqal_query_get_feature_string`.

`roqet` gained a `-f` / `--feature` option to set query features.

## Rasqal 0.9.12 Changes

### General Changes

Added JSON as a query results format based on the Serializing SPARQL Query Results in JSON draft.

Added query writing to a `raptor_iostream` which allows reading in one query language and writing in another. The only useful consequence of this now is that it enables `roqet` to become an RDQL to SPARQL translator.

Rasqal now requires raptor 1.4.9 or newer.

### Configuration and Build Changes

Now using subversion.

### `roqet` utility Changes

Altered the `-d` (`--dump-query`) option to now take an argument of the query format to dump. The values it can take are `debug`, `structure` or `sparql`.

To convert a query from RDQL to SPARQL, use:

    roqet -q -i rdql -d sparql -n query.rdql > query.sparql

Added `-r json` for JSON query results output based on the draft defined in the Serializing SPARQL Query Results in JSON draft

### SPARQL Query Language Changes

Updated to match SPARQL Query Language for RDF, W3C Candidate Recommendation 6 April 2006. All DAWG syntax tests now pass. The update includes near alignment with SPARQL grammar term names except where the flex/bison approach diverged.

Updated SPARQL tests from DAWG CVS

Finally removed long deprecated `ASC[]` and `DESC[]` syntax.

### RDQL Query Language Changes

Handle empty regex `//` Fixes Issue#0000071

### Query Engine Changes

Some updates to handle latest changes to SPARQL grammar.

Added `RASQAL_EXPR_REGEX` 3-arg operation to match the SPARQL `regex()` 2/3-arg function.

Many internal changes to move more of the query execution state from inside `rasqal_query` to inside `rasqal_query_results` and related structures. This is not yet complete but when done, you will be able to execute the same query more than once at the same time.

### Query API Changes

Added `rasqal_query_write` to write a query structure into a syntax onto a raptor_iostream. Implements writing SPARQL format with format URI NULL, http://www.w3.org/TR/rdf-sparql-query/ or http://www.w3.org/TR/2006/CR-rdf-sparql-query-20060406/

Added a JSON SPARQL query results format with format URI identifier http://www.w3.org/2001/sw/DataAccess/json-sparql/ based on the draft defined in http://www.w3.org/2001/sw/DataAccess/json-sparql/ Implemented document with version `alt-ser-sparql.rst,v 1.3 2006/02/16 16:03:08 k Exp`.

`rasqal_query_get_all_variable_sequence` was corrected to match the definition - return all variables, not just the bound (`SELECT`ed) ones. Fixes Issue#00000079.

Added `rasqal_query_get_anonymous_variable_sequence` to return only anonymous variables after change above.

Added `rasqal_graph_pattern_get_index` to get the absolute index of a graph pattern in a graph.

### IOstream class Changes

Added `rasqal_query_iostream_write_escaped_counted_string` and `rasqal_query_escape_counted_string` to format an escaped string suitable for using inside a query.

### Documentation Changes

Updated `roqet.1` for --exec option and new usages.

## Rasqal 0.9.11 Changes

### General Changes

Duplicated `SELECT` variables are now detected, give a warning and are removed.

Rasqal now requires raptor 1.4.8 or newer to get the guess parser that uses URI/name and mime type returned from protocol request (if available) to choose the correct parser.

Added an internal `rasqal_map` key : value map for use with result duplicate detection and ordering.

A major source code regoranisation moved all library source code to the `src/` dir, roqet to `utils/` and other documentation to `docs/`. This should only affect packagers, not any functionality.

Many more function documentation were added to the sources for use by gtk-doc.

### SPARQL Query Language Changes

Updated to the SPARQL Query Language for RDF W3C Working Draft 23 November 2005:

- Added `isIRI` keywords.
- Updated the name definitions to allow initial _ in variable names.
- Changed the decimal and double literal syntax.
- Allow negative numeric literals.
- Change the AND and OR logic when an error is present.

Added a post 2005-11-23 SPARQL WD syntax change: added `langMatches` operator and initial query engine support.

Invalid `\u`HHHH and `\U`HHHHHHHH hex escapes and floating point number formats are detected and warned.

Updates to the query engine make `DISTINCT` and `ORDER BY` now work, including with `LIMIT`.

The lexer now counts line numbers correctly over multi-line comments.

Updated changes to the valid characters allowed in SPARQL names for variable, prefix and QNames.

### RDQL Query Language Changes

The lexer now counts line numbers correctly over multi-line comments.

### Query Engine Changes

When query result sorting is used with limit (SPARQL `LIMIT`) and offset, they now work correctly, performing the limit and offset after ordering the result. This matches the SPARQL query result semantics.

The query engine now implements distinct results (SPARQL `DISTINCT`) including with ordering (SPARQL `ORDER BY`).

More cases with optional graph patterns (SPARQL `OPTIONAL`s) are now executed correctly. Note: this does not mean all cases work, there are known problems with executing optional clauses.

Added types for `xsd:float` (C float) and `xsd:double` (C double); `xsd:decimal` (handled as a string) and `xsd:datetime` (as a string).

Fixed (a compare b) between integers and doubles to be the right sign.

Do not promote literals early on in comparisons to strings "perl style" but do the best type-based comparsion as late as possible.

### Query API Changes

Added `rasqal_new_double_literal`.

Added `rasqal_graph_pattern_visit` and type for visitor function `rasqal_graph_pattern_visit_fn`.

Added `rasqal_new_expression_from_expression`.

Added `rasqal_expression_visit` and type for visitor function `rasqal_expression_visit_fn`.

Deprecated function `rasqal_new_floating_literal` replaced by new `rasqal_new_double_literal`.

Deprecated function `rasqal_expression_foreach`, replaced by new `rasqal_expression_visit`.

Function `rasqal_expression_evaluate` gains a flag argument of new enum `rasqal_compare_flags`.

Added enum `rasqal_compare_flags` flags for `rasqal_expression_evaluate` or `rasqal_literal_compare`. Type `RASQAL_COMPARE_XQUERY` can be used with to ask for use of XQuery comparison and type promotions.

Added `rasqal_literal` types: `RASQAL_LITERAL_DECIMAL`, `RASQAL_LITERAL_DATETIME`, `RASQAL_LITERAL_DOUBLE` (replacing deprecated `RASQAL_LITERAL_FLOATING`) and `RASQAL_LITERAL_FLOAT`. Reordered the `rasqal_literal` types in the enum.

The enum types in `rasqal_literal_type` were reordered to make them match sparql type promotion.

### `roqet` utility program changes

`roqet` gains -e/--exec option to execute a query string directly rather than via a file or URI containing the query.

Now writes out XML results format in format with version URI `http://www.w3.org/2005/06/sparqlResults` and short name "xml". The previous version is available with short name "xml-v2". The latest version now writes `ordered` and `distinct` boolean-valued attributes on the `results` element.

### Configuration Changes

The autogen.sh script for building from CVS was revamped to be more modular.

`configure` now takes an `--enable-gtk-doc` option to enable building of the documentation using the `gtk-doc` utility. It is by default enabled only if the utility is available.

### Documentation Changes

The GNOME `gtk-doc` program is now used to automatically extract documentation from source comments into reference documentation. This is then merged with templates and additional documentation to provide a reference manual for rasqal as XML document which is turned into HTML along with GNOME devhelp support.

This new documentation intended to replace the librasqal manual page/web page as easier to read document with scope for better expanding with more detail of rasqal including examples and tutorial information. The librasqal manual page will continue to contain the summary information for the present.

## Rasqal 0.9.10 Changes

### General Changes

The query engine now supports ordering query results, in SPARQL this is the `ORDER BY` clause.

### SPARQL Query Language Changes

The SPARQL parser now passes (accepts) all the 70+ SyntaxFull tests in the RDF Data Access Working Group (DAWG) test suite for SPARQL. This mostly means accepting optional punctuation in some places.

Sorting results with `ORDER BY` now partially works however comparison is not done with the SPARQL literal comparison rules (after XQuery) but using the existing RDQL-style "string-y" comparisons.

Allow `<>` as a URI.

The SPARQL parser now accepts some changes made by the DAWG after the last published working draft: SPARQL Query Language for RDF, W3C Working Draft, 19 April 2005. This includes:

- In `ORDER BY` `ASC(`expression`)` replaces `ASC[...]`, `DESC(`expression`)` replaces `DESC[...]`, and it also accepts `ORDER BY (`expression`)`. `ORDER BY` func()`` is accepted although at present no extension function support is available that could use it.
- `[]` can be used in the triple predicate position as an anonymous existential variable
- Enforce that ASK queries cannot use `ORDER BY`, `LIMIT` or `OFFSET`

Omitting `WHERE` gives a warning. Don't do that!

### Query Engine Changes

The query engine now allows sorting of results (`ORDER BY` in SPARQL). It performs comparisons using the existing RDQL style and does not yet support the SPARQL literal comparison rules. Sorting can be done by a sequence of expressions, ascending or descending. If the final result is equality, the object pointers are used.

Note: removal of duplicates is not supported yet.

Some test code for datatypes support was added, not enabled by default and not yet useful.

### Query API Changes

Removed functions deprecated in 0.9.9.

Added `rasqal_graph_pattern_operator` enumeration with values for the main SPARQL graph patterns, graph pattern class method `rasqal_graph_pattern_get_operator` and graph pattern utility function `rasqal_graph_pattern_operator_as_string`

Modified the type of the final argument of `rasqal_new_graph_pattern_from_sequence` and `rasqal_graph_pattern_add_triples` from an integer to a `rasqal_graph_pattern_operator` enumeration.

Deprecated function `rasqal_graph_pattern_get_flags` now always returning 0 replaced by the graph pattern operator functions listed above .

### `roqet` utility program changes

Removed deprecated flags -f and -o

## Rasqal 0.9.9 Changes

### General Changes

SPARQL is now the default query language

Added a signing memory debugging system to aid checking when rasqal-allocated memory is freed in another library or vice-versa enabled by `--with-memory-signing` configure option (defaults to on in maintainer mode).

Fixed a few internal malloc/frees to use RASQAL_MALLOC / RASQAL_FREE so that the above signed memory system worked.

### SPARQL Query Language Changes

Grammar updated to follow the SPARQL Query Language for RDF, W3C Working Draft, 19 April 2005. This changes many parts of the syntax:

- Turtle/N3 style for triples with abbreviations
- `{` ... `}` around triple patterns
- `OPTIONAL` instead of `[]`
- `GRAPH` replaces `SOURCE`
- `FROM NAMED` replaces `LOAD`
- `FILTER` replaces `AND`
- `REGEX` replaces `?var =~ /match/flags` and `!~`
- Added `LIMIT`, `OFFSET` and `ORDER BY` with `ASC[]` and `DESC[]`
- Changed function syntax to remove `&`
- Removed old operator tokens: `ne`, `eq`, `==`

(Note: the query engine does not support sorting amongst other recently added SPARQL features)

SPARQL keywords are now case independent rather than just upper or lowercase.

Added """long literals""" after N3 (and soon, Turtle) and '''long literals''' for SPARQL only.

Added many SPARQL tests from DAWG most not yet approved by the working group. Not all pass either because not implemented or known bugs.

Added the revised SPARQL Query Results XML Format (the latest version not yet published) support to `rasqal_query_results_write` when called with format URI `http://www.w3.org/2001/sw/DataAccess/rf1/result2`.

### Query Engine Changes

Uses the query results limit and offset information to skip initial results (offset) and provide a maximum number of results (limit).

Moved some engine-specific operations from RDQL and SPARQL parser.

Added internal `rasqal_formula` class for the Turtle part of the SPARQL parser

Deprecated the `rasqal_triples_source` factory method `new_triples_match`. It is replaced by a new method `init_triples_match` and will be removed from the next release.

### Query API Changes

Added bnode identifier generation functions: `rasqal_query_set_default_generate_bnodeid_parameters`, `rasqal_query_set_generate_bnodeid_handler` based on the raptor API for generating blank node identifiers in the Turtle/N3 triple style.

Added `order_conditions_sequence` to the query structure to store query ordering conditions and added access methods `rasqal_query_get_order_conditions_sequence` and `rasqal_query_get_order_condition` to read the resulting expressions.

Added expressions for SPARQL ordering conditions: `RASQAL_EXPR_ORDER_COND_ASC`, `RASQAL_EXPR_ORDER_COND_DESC` and `RASQAL_EXPR_ORDER_COND_NONE`.

Added types for variables in two version - normal and anonymous with an new enum `rasqal_variable_type` and `rasqal_new_variable_typed` to allow creating them.

Completed the distinct/limit and offset get/set methods by adding: `rasqal_query_set_distinct`, `rasqal_query_set_limit`, `rasqal_query_get_offset` and `rasqal_query_set_offset`

Deprecated the `rasqal_triple` flags field - the value `RASQAL_TRIPLE_FLAGS_EXACT` was only used in internals of the execution engine. The value `RASQAL_TRIPLE_FLAGS_OPTIONAL` was never used. Optionals are now noted on graph patterns. Deprecated `rasqal_triple_set_flags` and `rasqal_triple_get_flags`.

Added enum `rasqal_query_verb` for the main query verbs: `RASQAL_QUERY_VERB_SELECT` `RASQAL_QUERY_VERB_CONSTRUCT` `RASQAL_QUERY_VERB_DESCRIBE` and `RASQAL_QUERY_VERB_ASK`. Added method `rasqal_query_get_verb` to access the verb.

Added `rasqal_query_get_query_graph_pattern` to get the top graph pattern.

Added `rasqal_query_get_wildcard` to get the query verb wildcard flag such as with SPARQL `SELECT *`

Added `rasqal_query_get_construct_triples_sequence` and `rasqal_query_get_construct_triple` to get the triples made from a SPARQL `CONSTRUCT` query.

### `roqet` utility program changes

Updated roqet to include better query structure walking with `-w` / `--walk` including listing query verb, distinct, limit, offset flags, construct triples and easier to read groupings of graph patterns and triples.

Deprecated roqet arguments `-f` / `--format` and `-o` / `--output` in place of `-r` / `--results` as both choose the query results format.

SPARQL is now the default query language for roqet.

## Rasqal 0.9.8 Changes

### SPARQL Query Language Changes

Grammar updated to follow the SPARQL Query Language for RDF, W3C Working Draft, 17 February 2005.

Added support for casting in constraint expresions for datatyped literals with the syntax qname`(`literal`)` such as `xsd:decimal("10")`.

Added named graphs parsing with `LOAD` and note that `UNION` cannot be handled yet, `SOURCE` and `[`...`]` syntax for optionals are deprecated.

### Query Engine Changes

Engine now operates over a hierarchy of `rasqal_graph_pattern` objects, where at the root the query has a single query graph rather than a sequence of graph patterns. The query graph contains the former sequence of graph patterns.

Constraints can be applied to any graph pattern, not just at the top level of a query.

Added casting expressions type `RASQAL_EXPR_CAST` and constructor `rasqal_new_cast_expression`.

Fixed setting of a triple origin (SPARQL `GRAPH`) which was not working in 0.9.7

`xsd:boolean` RDF literals are now promoted into internal `RASQAL_LITERAL_BOOLEAN` typed `rasqal_literal` like for XSD integer and double.

The query engine uses the named graph information when evaluating queries, passing it to the `rasqal_triples_match` factory methods either implemented with raptor or redland as a `rasqal_triples_source_factory` and returning them as results of variable bindings.

### Query API Changes

Added no-arg constructor `rasqal_new_graph_pattern`

Added method `rasqal_graph_pattern_add_triples` to add triples to an existing graph pattern.

Added methods `rasqal_graph_pattern_add_constraint`, `rasqal_graph_pattern_get_constraint_sequence` and `rasqal_graph_pattern_get_constraint` to add constraints to a graph pattern.

Added method `rasqal_graph_pattern_add_sub_graph_pattern` to add a sub-graph pattern to a graph pattern.

Added a Data Graph class with constructor `rasqal_new_data_graph`, destructor `rasqal_free_data_graph` and debug method `rasqal_data_graph_print`.

Added query methods for data graphs: `rasqal_query_add_data_graph`, `rasqal_query_get_data_graph_sequence`, `rasqal_query_get_data_graph`.

Deprecated query methods `rasqal_query_add_constraint`, `rasqal_query_get_constraint_sequence` `rasqal_query_get_constraint`, `rasqal_query_add_source`, `rasqal_query_get_source_sequence` and `rasqal_query_get_source`. These will be removed in the next release.

Removed functions deprecated in previous version: `rasqal_query_get_variable_sequence` and `rasqal_query_add_triple`.

## Rasqal 0.9.7 Changes

### General Changes

Fix a resource clean up when query results are either not read at all or not fully exhausted. This caused a problem in Redland when it held on to MySQL database handles despite a query having ended.

Added option `-n/--dryrun` to `roqet` to stop after preparing the query. Added option `-w/--walk-query` to walk and print the query using the graph API.

New build configuration and portability fixes for win32 (John Barstow)

Portability fixes for win32 - define `RASQAL_INLINE` and use it as for raptor. (Dave Viner)

Make rasqal tests work when building against raptor in a sibling source tree.

### Query Engine Changes

Added a graph pattern API with `rasqal_graph_pattern` typedef and `rasqal_pattern_flags` enum with value `RASQAL_PATTERN_FLAGS_OPTIONAL` to allow complete walking of the query structure.

Two new methods to the query class were added to support this: `rasqal_query_get_graph_pattern_sequence` to get the raptor_sequence of graph patterns in a query and `rasqal_query_get_graph_pattern` to get individual an graph pattern by index.

The new graph pattern methods added are:

- `rasqal_graph_pattern_get_triple` to get a `raptor_triple` inside a graph pattern.
- `rasqal_graph_pattern_get_sub_graph_pattern_sequence` to get the raptor_sequence of sub-graph patterns.
- `rasqal_graph_pattern_get_sub_graph_pattern` to get a sub-graph pattern inside a graph pattern by index.
- `rasqal_graph_pattern_get_flags` to get a graph pattern's flags.
- `rasqal_graph_pattern_print` to print a graph pattern in a debug form.

Deprecated `rasqal_query_add_triple` as it doesn't construct the graph patterns and is of little use as it does not build the correct query structures.

Added query API methods to get the bound and all variables in a query: `rasqal_query_get_bound_variable_sequence` and `rasqal_query_get_all_variable_sequence` respectively. Deprecated `rasqal_query_get_variable_sequence` as too ambiguous.

With the aid of gcc `-Wswitch-enum`, found and fixed cases where switch on enumerated values were missing cases. The remaining cases return failure or an error message rather than abort(). This fixed a crash when comparing for equality a variable ?x with a blank node value and an interger.

Deleted `RASQAL_EXPR_PATTERN` as it was never used.

Added `rasqal_query_get_distinct` to get a query-specified distinct results flag.

Added `rasqal_query_get_limit` to get a query-specified limit on the number of results.

### SPARQL Query Language Changes

Updated some of the SPARQL syntax to match the changes in the SPARQL Query Language for RDF W3C Working Draft of 17 February 2005. Added `GRAPH` replacing `SOURCE` and `WITH` replacing `FROM`. Added warnings about using the older forms and about using `[`...`]` instead of `OPTIONAL`.

Added recording of `DISTINCT` and `LIMIT` in the query structures but not yet used by the query engine.

### RDQL Query Language Changes

None.

## Rasqal 0.9.6 Changes

### General Changes

Fix a bug in writing a query result to XML when blank nodes are used. Now also correctly uses the base URI when pass in to the writing method.

Added support for three types of query result - bindings (the only one in previous versions), an RDF graph and a boolean. Added `rasqal_query_results` methods to test the type of the result: `rasqal_query_results_is_bindings`, `rasqal_query_results_is_boolean` and `rasqal_query_results_is_graph`.

Added `rasqal_query_results_get_triple` to get current triple as a `raptor_statement` and `rasqal_query_results_next_triple` to move to the next triple.

Added `rasqal_query_results_get_boolean` to get a boolean query result value.

Added `rasqal_triple` copy constructor `rasqal_new_triple_from_triple`.

### Query Engine Changes

Constructs an RDF graph result as a sequence of triples. This enables the SPARQL `CONSTRUCT` form to work.

Can return a boolean result indicating that there were variable binding results, but not returning them. This enables the SPARQL `ASK` form to work.

Added a new function expression - rasqal_op enum value `RASQAL_EXPR_FUNCTION`, added new `name` and `args` fields to the `rasqal_expression` structure and added `rasqal_new_function_expression` to construct this expression.

Added new 1-argument expression `RASQAL_EXPR_STR` returning a string version of the expression.

Added new 1-argument expressions operating on RDF literals: `RASQAL_EXPR_LANG` returning the language string of an RDF literal, `RASQAL_EXPR_DATATYPE` returning the datatype URI of an RDF literal.

Added new 1-argument testing expressions returning booleans: `RASQAL_EXPR_BOUND` true if the variable argument is bound to a value, `RASQAL_EXPR_ISURI` true if the argument is a URI, `RASQAL_EXPR_ISBLANK` true if the argument is a blank node and `RASQAL_EXPR_ISLITERAL` true if the argument is an RDF literal.

Fixed a problem in optional results returning extra results with no new bindings.

### SPARQL Query Language Changes

The SPARQL Parser now allows UTF-8 and \u, \U in prefixes and QNames.

Now supports `CONSTRUCT` and `ASK` queries using the updated query engine features.

`OPTIONAL` can now be used wherever `[` ... `]` could be used (parser bug fix).

Now supports the SPARQL built-in functions `STR()` returning a string version of the expression, `LANG()` returning the language string of an RDF literal, `DATATYPE()` returning the datatype URI of an RDF literal, `BOUND()` testing if a variable is bound, `ISURI()` testing if an expression is a URI, `ISBLANK()` testing if an expression is a blank node and `ISLITERAL()` testing if an expression is an RDF literal.

Now supports SPARQL `BASE` directive for setting the base URI of a query. This is experimental and may not be in the next version or may not be in the final SPARQL language.

The parser now expands QNames correctly when used in literals like `"blah"^^xsd:string`.

### RDQL Query Language Changes

The RDQL Parser now allows UTF-8 and \u, \U in prefixes and QNames. This makes RDQL testsuite tests S-03, S-04 and S-05 work.

## Rasqal 0.9.5 Changes

A release with major changes internal to the query engine to operate over graph patterns instead of sequences of triple patterns and to add execution of optional graph patterns. Additionally the query results can now be written in a recognised XML format.

This version of Rasqal requires Raptor 1.4.4.

### Core Changes

Added a `rasqal_graph_pattern` class for handling matching a graph pattern (set of triple patterns) in an `rasqal_query`. RDQL only has one of these wheras SPARQL may have many, and they may be nested (this may change, as SPARQL is under development).

Added `rasqal_query_results_write` method to write variable binding query results to a `raptor_iostream` in the XML format defined by SPARQL Variable Binding Results XML Format, W3C Working Draft, 21 December 2004.

### Query Engine Changes

Updated the query engine to operate over graph patterns rather than a single sequence of triple patterns. The graph patterns may be optional, which is used to implement SPARQL optionals. Nested graph patterns are constructed but cannot yet be executed.

Added a unary minus expression type.

Improved the type promotion for expression evaluation. Try to evaluate strings as doubles or integers if the operation contains one double or integer respectively.

Fixed a memory leak with string matches/non-matches.

### SPARQL Query Language Changes

Optional graph patterns `OPTIONAL` and `[` ... `]` now work.

Added the `{` ... `}` group syntax and removed the `(` ... `)` form.

`$` was added as an allowed variable prefixes.

A warning was added to show `SOURCE *` is ignored.

Added the `UNION` keyword, unsupported.

Rasqal now passes the DAWG SPARQL test cases: Optional triples (dawg-opt-query-001, dawg-opt-query-002, dawg-opt-query-003, dawg-opt-query-004) and examples from query WD (sparql-query-example-2.1a, sparql-query-example-2.2a, sparql-query-example-2.3a, sparql-query-example-2.4a, sparql-query-example-3)

Allow UTF-8 qname prefixes and check name against XML name constraints.

Recover lexer state from errors in regexes.

Terminate the lexer on a syntax error, rather than produce multiple errors.

### RDQL Query Language Changes

The lexer now handles UTF-8 qname prefixes, enabling RDQL testsuite test S-02 to pass.

Allow UTF-8 qname prefixes and check name against XML name constraints.

Recover lexer state from errors in regexes.

Terminate the lexer on a syntax error, rather than produce multiple errors.

## Rasqal 0.9.4 Changes

Pass on raptor parser errors to rasqal's error routines and upwards.

Clean up several memory allocations when a query fails to prepare or execute fully.

Fixed lexer jams when a query contained an illegal variable name after a '?'.

Fixed lexer crashes when a query ended in a regex pattern like `/abc/`.

Tidied up the testing framework so 'make distcheck' works.

## Rasqal 0.9.3 Changes

Rasqal's License was changed from LGPL 2.1/MPL 1.1 to LGPL 2.1/Apache 2

Added support for the SPARQL Query Language for RDF, W3C Working Draft, 12 October 2004 from the W3C RDF Data Access Working Group (DAWG). The support is at the basic syntax level - token lexer and grammar parser which passes the first simple tests from the proposed DAWG testcases. No additional query engine support has been added for SPARQL features that are not supported by RDQL. The Rasqal to do list contains full details of the implementation state.

Queries can now be prepared and then executed multiple times.

Added configure `--enable-query-languages` option with `rdql` and `sparql` as the choices.

Thanks to Chris Pointon for several patches to make Rasqal easier to build under Win32. Applied with some modifications. Renamed the RDQL and SPARQL syntax tokens ERROR to ERROR_TOKEN to help.

Added experimental support for querying multiple sources; the same query is executed over each source in turn. Also added some support for returning the source URI which is not yet enabled as this feature is in flux in the DAWG work. This may change or be removed in future versions.

`roqet` can specify a data source URI on the command line with `-s` / `--source`) URI for queries executing against an implicit model.

Added the DAWG SPARQL test cases driven from the manifest.n3 format. Created tests from the examples in the working draft.

Added an experimental XML result format for bindings, based on DAWG work. Enabled in `roqet` with `-o xml`. This is very likely to change or replaced in future versions.

Added `roqet` argument `-d` / `--dump-query` to dump the processed query, rather than do it by default (0.9.2 and earlier).

`roqet` can now read queries from URIs, using the `raptor_www` class to do the retrieval.

Fixed the `configure` checks for a posix regex function regcomp to correctly discover it is present.

### Internal changes

Added support for declaring prefixes for XML-style QNames both before and after their use.

The struct `rasqal_prefix` gained a `declared` field.

The struct `rasqal_triple` gained an origin field; not used at present but intended to support work on tracking triple provenance such as provided by Redland Contexts.

Added methods `rasqal_triple_set_origin` and `rasqal_triple_get_origin` to support the above.

struct `rasqal_triple_meta` now takes a 4-array of bindings, the fourth being the origin.

Exported function `rasqal_set_triples_source_factory` publically as originally intended.

## Rasqal 0.9.2 Changes

This release made minor portability fixes for building with C++ and Win32 (untested).

Several functions changed their parameters or return values from char* to unsigned char* or const unsigned char* to reflect the actual use.

Changed to return a `const unsigned char*`:
`rasqal_literal_as_string`

Changed to take `const unsigned char*` (or add `const`):
`rasqal_new_floating_literal`
`rasqal_new_pattern_literal`
`rasqal_new_prefix`
`rasqal_new_simple_literal`
`rasqal_new_string_literal`
`rasqal_new_variable`
`rasqal_query_has_variable`
`rasqal_query_results_get_binding_name`
`rasqal_query_results_get_binding_value_by_name`
`rasqal_query_results_get_bindings`
`rasqal_query_set_variable`

## Rasqal 0.9.1 Changes

This release changed the way that results were returned. A new `rasqal_query_results` class was created. This allows for a clean separation of the two concepts allowing multiple form of the results to be retrieved as methods of the query_results class, rather than the query class. The only form of results currently available is variable bindings, but RDF graphs will be returned in future, as a set of triples in a serialised form.

The execution method `rasqal_query_execute` was changed to return a new object of that class rather than an `int` success or failure.

The following methods of the `rasqal_query` class were renamed and moved to the new `rasqal_query_results` class:

0.9.0 name | 0.9.1+ name
--- | ---
`rasqal_query_get_result_count` | `rasqal_query_results_get_count`
`rasqal_query_next_result` | `rasqal_query_results_next`
`rasqal_query_results_finished` | `rasqal_query_results_finished`
`rasqal_query_get_result_bindings` | `rasqal_query_results_get_bindings`
`rasqal_query_get_result_binding_value` | `rasqal_query_results_get_binding_value`
`rasqal_query_get_result_binding_name` | `rasqal_query_results_get_binding_name`
`rasqal_query_get_result_binding_by_name` | `rasqal_query_results_get_binding_value_by_name`
`rasqal_query_get_bindings_count` | `rasqal_query_results_get_bindings_count`

A new `rasqal_free_query_results` destructor was created to delete the query results. (There is no public constructor).

Other minor bugs were fixed such as multiple constraints now being ANDed and not ORed, and adding defensive code for when queries fail and results methods are invoked.

## Rasqal 0.9.0 Changes

It is all new.

Copyright (C) 2004-2010 Dave Beckett
Copyright (C) 2003-2005 University of Bristol