openlink / virtuoso-opensource

Virtuoso is a high-performance and scalable Multi-Model RDBMS, Data Integration Middleware, Linked Data Deployment, and HTTP Application Server Platform
https://vos.openlinksw.com
Other
868 stars 210 forks source link

Query with `FILTER` and `BIND` clauses failure #1248

Open achort opened 8 months ago

achort commented 8 months ago

I am using Virtuoso version 07.20.3239 (d698f2171) prebuilt binary.

The following query does not compile and throws:

Virtuoso VECSL Error VECSL: Internal error, ssl refd before set, please report query to support

PREFIX gn: <http://www.geonames.org/ontology#> 

SELECT ?uri ?name ?featureCode ?tX ?tP ?tC ?tM {

    {    SELECT ?uri ?name ?featureCode WHERE { 
             ?uri gn:name ?name . 
             ?uri gn:countryCode "ES" . 
             ?uri gn:featureClass gn:P . 
             ?uri gn:featureCode ?featureCode . 
             VALUES  ?name { "Salamanca" }
         }
         GROUP BY ?uri  ?featureCode
    }

    {    SELECT count(distinct ?uri) as ?cX WHERE {
             ?uri gn:name ?name . 
             ?uri gn:countryCode "ES" . 
             ?uri gn:featureClass gn:P . 
             ?uri gn:featureCode gn:P.PPLX . 
             VALUES  ?name { "Salamanca" }
        } 
    }

    {    SELECT count(distinct ?uri) as ?cP WHERE {
             ?uri gn:name ?name . 
             ?uri gn:countryCode "ES" . 
             ?uri gn:featureClass gn:P . 
             ?uri gn:featureCode ?fc . VALUES ?fc {  gn:P.PPLA1 gn:P.PPLA2 gn:P.PPLA3  gn:P.PPLC }
             VALUES  ?name { "Salamanca" }
        } 
    }

    BIND( if(?cX > 0, "X", "Z") AS ?tX) 
    BIND( if(?cP > 0, "P", "Z") AS ?tP) 
    BIND( str(if( if(?cX > 0, "X", "Z") = "P", "P", "Z")) AS ?tM)
    BIND( if(?featureCode  = gn:P.PPLX, "X", "P") AS ?tC) 

    FILTER(?tM = ?tC)
 }

The problem seems to be triggered by the FILTER(?tM = ?tC) clause. If it is removed, the query executes as expected.

HughWilliams commented 8 months ago

We are looking into this ...