Skip to content

Commit 15a9a81

Browse files
author
James Leigh
committed
Merge branch 'develop' of github.com:eclipse/rdf4j into issues/#870-repo-mgr-sail
2 parents 7fd6901 + 36cb449 commit 15a9a81

9 files changed

Lines changed: 106 additions & 11 deletions

File tree

core/console/src/main/java/org/eclipse/rdf4j/console/ConsoleIO.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,11 @@ protected String readCommand()
5353
}
5454
write("> ");
5555
}
56-
String line = input.readLine().trim();
56+
String line = input.readLine();
57+
if (line == null) {
58+
return null;
59+
}
60+
line = line.trim();
5761
if (line.endsWith(".")) {
5862
line = line.substring(0, line.length() - 1);
5963
}

core/model/src/main/java/org/eclipse/rdf4j/model/vocabulary/DCAT.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,16 @@
2222
*/
2323
public class DCAT {
2424

25-
/**
26-
* The DCAT namespace: http://www.w3.org/ns/dcat#
27-
*/
28-
public static final String NAMESPACE = "http://www.w3.org/ns/dcat#";
29-
3025
/**
3126
* Recommended prefix for the Data Catalog Vocabulary namespace: "dcat"
3227
*/
3328
public static final String PREFIX = "dcat";
3429

30+
/**
31+
* The DCAT namespace: http://www.w3.org/ns/dcat#
32+
*/
33+
public static final String NAMESPACE = "http://www.w3.org/ns/dcat#";
34+
3535
/**
3636
* An immutable {@link Namespace} constant that represents the Data Catalog Vocabulary namespace.
3737
*/

core/model/src/main/java/org/eclipse/rdf4j/model/vocabulary/DOAP.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,35 @@
88
package org.eclipse.rdf4j.model.vocabulary;
99

1010
import org.eclipse.rdf4j.model.IRI;
11+
12+
import org.eclipse.rdf4j.model.Namespace;
13+
1114
import org.eclipse.rdf4j.model.ValueFactory;
15+
16+
import org.eclipse.rdf4j.model.impl.SimpleNamespace;
17+
1218
import org.eclipse.rdf4j.model.impl.SimpleValueFactory;
1319

1420
/**
1521
* Constants for DOAP primitives and for the DOAP namespace.
1622
*/
1723
public class DOAP {
1824

25+
/**
26+
* The recommended prefix for the DOAP namespace: "doap"
27+
*/
28+
public static final String PREFIX = "doap";
29+
30+
/**
31+
* The DOAP namespace: http://usefulinc.com/ns/doap#
32+
*/
1933
public static final String NAMESPACE = "http://usefulinc.com/ns/doap#";
2034

35+
/**
36+
* An immutable {@link Namespace} constant that represents the DOAP namespace.
37+
*/
38+
public static final Namespace NS = new SimpleNamespace(PREFIX, NAMESPACE);
39+
2140
/**
2241
* Classes
2342
*/

core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/QueryBindingSet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ public void setBinding(Binding binding) {
8686
}
8787

8888
public void setBinding(String name, Value value) {
89-
assert value != null : "null value for variable " + name;
9089
bindings.put(name, value);
9190
}
9291

core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/impl/StrictEvaluationStrategy.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Service
347347
if (serviceRef.hasValue())
348348
serviceUri = serviceRef.getValue().stringValue();
349349
else {
350-
if (bindings != null && bindings.hasBinding(serviceRef.getName())) {
350+
if (bindings != null && bindings.getValue(serviceRef.getName()) != null) {
351351
serviceUri = bindings.getBinding(serviceRef.getName()).getValue().stringValue();
352352
}
353353
else {
@@ -465,6 +465,13 @@ public CloseableIteration<BindingSet, QueryEvaluationException> evaluate(Stateme
465465
CloseableIteration<? extends Statement, QueryEvaluationException> stIter3 = null;
466466
ConvertingIteration<Statement, BindingSet, QueryEvaluationException> result = null;
467467

468+
if (isUnbound(subjVar, bindings) || isUnbound(predVar, bindings) || isUnbound(objVar, bindings)
469+
|| isUnbound(conVar, bindings))
470+
{
471+
// the variable must remain unbound for this solution see https://www.w3.org/TR/sparql11-query/#assignment
472+
return new EmptyIteration<BindingSet, QueryEvaluationException>();
473+
}
474+
468475
boolean allGood = false;
469476
try {
470477
try {
@@ -649,6 +656,15 @@ protected BindingSet convert(Statement st) {
649656
}
650657
}
651658

659+
protected boolean isUnbound(Var var, BindingSet bindings) {
660+
if (var == null) {
661+
return false;
662+
}
663+
else {
664+
return bindings.hasBinding(var.getName()) && bindings.getValue(var.getName()) == null;
665+
}
666+
}
667+
652668
protected Value getVarValue(Var var, BindingSet bindings) {
653669
if (var == null) {
654670
return null;

core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/ExtensionIterator.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,10 @@ public BindingSet convert(BindingSet sourceBindings)
5757
}
5858
catch (ValueExprEvaluationException e) {
5959
// silently ignore type errors in extension arguments. They should not cause the
60-
// query to fail but just result in no additional binding.
60+
// query to fail but result in no bindings for this solution
61+
// see https://www.w3.org/TR/sparql11-query/#assignment
62+
// use null as place holder for unbound variables that must remain so
63+
targetBindings.setBinding(extElem.getName(), null);
6164
}
6265
}
6366
}

core/queryalgebra/evaluation/src/main/java/org/eclipse/rdf4j/query/algebra/evaluation/iterator/PathIteration.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,11 @@ private void createIteration()
261261
throws QueryEvaluationException
262262
{
263263

264-
if (currentLength == 0L) {
264+
if (isUnbound(startVar, bindings) || isUnbound(endVar, bindings)) {
265+
// the variable must remain unbound for this solution see https://www.w3.org/TR/sparql11-query/#assignment
266+
currentIter = new EmptyIteration<BindingSet, QueryEvaluationException>();
267+
}
268+
else if (currentLength == 0L) {
265269
ZeroLengthPath zlp = new ZeroLengthPath(scope, startVar, endVar, contextVar);
266270
currentIter = this.evaluationStrategyImpl.evaluate(zlp, bindings);
267271
currentLength++;
@@ -334,6 +338,15 @@ else if (currentLength == 1) {
334338
}
335339
}
336340

341+
protected boolean isUnbound(Var var, BindingSet bindings) {
342+
if (var == null) {
343+
return false;
344+
}
345+
else {
346+
return bindings.hasBinding(var.getName()) && bindings.getValue(var.getName()) == null;
347+
}
348+
}
349+
337350
protected Set<ValuePair> makeSet() {
338351
return new HashSet<ValuePair>(64, 0.9f);
339352
}

core/repository/sparql/src/main/java/org/eclipse/rdf4j/repository/sparql/query/SPARQLQueryBindingSet.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public void setBinding(Binding binding) {
8888
}
8989

9090
public void setBinding(String name, Value value) {
91-
assert value != null : "null value for variable " + name;
9291
bindings.put(name, value);
9392
}
9493

testsuites/sparql/src/main/java/org/eclipse/rdf4j/query/parser/sparql/ComplexSPARQLQueryTest.java

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2333,6 +2333,48 @@ public void testSES1979MinMaxInf()
23332333

23342334
}
23352335

2336+
@Test
2337+
public void testSES2250BindErrors() throws Exception {
2338+
StringBuilder ub = new StringBuilder();
2339+
ub.append("insert data { <urn:test:subj> <urn:test:pred> _:blank }");
2340+
2341+
conn.prepareUpdate(QueryLanguage.SPARQL, ub.toString()).execute();
2342+
2343+
StringBuilder qb = new StringBuilder();
2344+
qb.append("SELECT * {\n"
2345+
+ " ?s1 ?p1 ?blank . "
2346+
+ " FILTER(isBlank(?blank))"
2347+
+ " BIND (iri(?blank) as ?biri)"
2348+
+ " ?biri ?p2 ?o2 ."
2349+
+ "}");
2350+
2351+
TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, qb.toString());
2352+
try (TupleQueryResult evaluate = tq.evaluate();) {
2353+
assertFalse("The query should not return a result", evaluate.hasNext());
2354+
}
2355+
}
2356+
2357+
@Test
2358+
public void testSES2250BindErrorsInPath() throws Exception {
2359+
StringBuilder ub = new StringBuilder();
2360+
ub.append("insert data { <urn:test:subj> <urn:test:pred> _:blank }");
2361+
2362+
conn.prepareUpdate(QueryLanguage.SPARQL, ub.toString()).execute();
2363+
2364+
StringBuilder qb = new StringBuilder();
2365+
qb.append("SELECT * {\n"
2366+
+ " ?s1 ?p1 ?blank . "
2367+
+ " FILTER(isBlank(?blank))"
2368+
+ " BIND (iri(?blank) as ?biri)"
2369+
+ " ?biri <urn:test:pred>* ?o2 ."
2370+
+ "}");
2371+
2372+
TupleQuery tq = conn.prepareTupleQuery(QueryLanguage.SPARQL, qb.toString());
2373+
try (TupleQueryResult evaluate = tq.evaluate();) {
2374+
assertFalse("The query should not return a result", evaluate.hasNext());
2375+
}
2376+
}
2377+
23362378
private boolean containsSolution(List<BindingSet> result, Binding... solution) {
23372379
final MapBindingSet bs = new MapBindingSet();
23382380
for (Binding b : solution) {

0 commit comments

Comments
 (0)