INSERT .. WHERE + GRAPH leads to server error

Dear OpenLink team,

When I try to run the following query (against 7.2.11 OSS), I get an error:

Virtuoso 22023 Error SR002: Function string_output_string needs a string output as argument 1, not an arg of type INTEGER (189)`

INSERT {
    GRAPH ?g { ?s <http://acme.org/what#ever> "abc" . }
}
WHERE { GRAPH ?g { ?s rdfs:label [] . } }
  • The error does not occur if the where clause doesn’t match anything.
  • The error does not occur if a variable is not used for the graph in the `INSERT clause (i.e. hard-coding it)
  • Despite the error, if the where clause matches then the triple appears to actually be inserted before the server returns the error

Inlike for SPARQL query, I couldn’t find a spec page in the community docs regarding what syntax you support for SPARQL update but I presume it’s 1.1.
Is this a bug or do you not support GRAPH variables in updates?

Regards,
VT

Using my latest Virtuoso Version 07.20.3237-pthreads for Linux as of Sep 26 2023 (ec28543a2) binary, if I insert at triple to match your search condition ie

INSERT INTO GRAPH <http://example.org> { <1> rdfs:label <3> }

Then run your query via a Virtuoso ~/sparql-auth endpoint as the dba user ie

INSERT {
    GRAPH ?g { ?s <http://acme.org/what#ever> "abc" . }
}
WHERE { GRAPH ?g { ?s rdfs:label [] . } }

The query runs successfully without any error and inserts the ?s <http://acme.org/what#ever> "abc" triple pattern in the graph ie

Thus, what are the version, gitid, build date etc of your Virtuoso build which can be obtained as detailed at https://community.openlinksw.com/t/interrogating-attributes-of-a-virtuoso-server-instance-via-sparql/3629 ? And was is the simplest test case you can provide for recreating the problem ?

Thank you for the quick response.
I used the openlink/virtuoso-opensource-7:7.2.11 docker image (Server: Virtuoso/07.20.3238 (Linux) x86_64-ubuntu_bionic-linux-gnu), which reports:

name version build_date thread opsys
OpenLink Virtuoso Server 07.20.3238 Sep 26 2023 -pthreads Linux

I then ran:

curl -v --digest -u dba:pass -X POST -H "Content-Type: application/sparql-update" --data @update.sparql http://localhost:8890/sparql-auth

… with update.sparql containing:

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

INSERT INTO GRAPH <http://example.org> { <1> rdfs:label <3> };

INSERT { GRAPH ?g { ?s <http://acme.org/what#ever> "abc" . } }
WHERE { GRAPH ?g { ?s rdfs:label [] . } }

… and I get a 500 response with body:

Virtuoso 22023 Error SR002: Function string_output_string needs a string output as argument 1, not an arg of type INTEGER (189)

SPARQL query:
define sql:big-data-const 0
* Connection #1 to host localhost left intact
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>INSERT INTO GRAPH <http://example.org> { <1> rdfs:label <3> };INSERT { GRAPH ?g { ?s <http://acme.org/what#ever> "abc" . } }WHERE { GRAPH ?g { ?s rdfs:label [] . } }

Thanks for the steps for recreating, which have enabled me to recreate and I have reported to development to look into and fix …

Note the query does run successfully against the latest Virtuoso 08.03.3329 commercial release