Skip to content

core: Handle ROWIDs turned into strings in SparqlPrintIRI()

Carlos Garnacho requested to merge wip/carlosg/numeric-affinity into master

From the main commit:

Even though normally we expect ROWIDs to preserve numeric affinity
when we proceed to print their IRI in the higher parts of the query,
it is not guaranteed by the SQLite documentation:

  "Whether or not a persistent internal datatype conversion occurs
   is undefined and may change from one release of SQLite to the next."

And this in fact changed for the core/property-paths/alternative-path-3
unit test, where it does the '|' union of text and resource (i.e. ROWIDs)
properties. Since SQLite 3.40.0, the SparqlPrintIRI() happening in the
topmost select will get SQLITE_TEXT affinity for all ROWID values received
through the union.

In order to work with both older and newer version of SQLite, attempt to
force integer affinity so ROWID IRIs are correctly resolved instead of
being interpreted as IRI strings.

This opened a small can of worms though, since we do silently allow invalid IRIs like <123> and that will now be mistaken for a ROWID. This is an unlikely situation, but one that is potentially prone to causing confusions in the stored data and returned query results. This MR also moves our own tests to avoid using invalid IRIs, and adds a warning so that these situations do not happen silently. This check will be turned into a GError that will make inserts/deletes/transactions to fail in future releases.

Closes: #387 (closed)

Merge request reports