jackrabbit-oak-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexparvule...@apache.org
Subject svn commit: r1478354 - in /jackrabbit/oak/trunk: oak-core/src/main/java/org/apache/jackrabbit/oak/query/ oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/ oak-core/src/test/java/org/apache/jackrabbit/oak/query/ oak-core/src/test/...
Date Thu, 02 May 2013 12:55:32 GMT
Author: alexparvulescu
Date: Thu May  2 12:55:31 2013
New Revision: 1478354

URL: http://svn.apache.org/r1478354
Log:
OAK-807 Keep original xpath query as a comment appended to the generated sql2 query

Added:
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java   (with props)
Modified:
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
    jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java
    jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
    jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java
    jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java?rev=1478354&r1=1478353&r2=1478354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/SQL2Parser.java Thu May  2 12:55:31 2013
@@ -144,6 +144,8 @@ public class SQL2Parser {
             read("BY");
             orderings = parseOrder();
         }
+        parseComment();
+
         if (!currentToken.isEmpty()) {
             throw getSyntaxError("<end>");
         }
@@ -804,6 +806,16 @@ public class SQL2Parser {
         }
     }
 
+    private void parseComment() throws ParseException {
+        if (readIf("/") && readIf("*")) {
+            while (!(readIf("*") && readIf("/"))) {
+                if (!isToken("*")) {
+                    read();
+                }
+            }
+        }
+    }
+
     private boolean readIf(String token) throws ParseException {
         if (isToken(token)) {
             read();
@@ -944,6 +956,9 @@ public class SQL2Parser {
     }
 
     private void read() throws ParseException {
+        if (parseIndex >= characterTypes.length) {
+            throw getSyntaxError();
+        }
         currentTokenQuoted = false;
         if (expected != null) {
             expected.clear();

Modified: jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java?rev=1478354&r1=1478353&r2=1478354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/main/java/org/apache/jackrabbit/oak/query/XPathToSQL2Converter.java Thu May  2 12:55:31 2013
@@ -348,7 +348,7 @@ public class XPathToSQL2Converter {
         if (condition.length() > 0) {
             buff.append(" where ").append(condition.toString());
         }
-        
+
         // order by ...
         if (!orderList.isEmpty()) {
             buff.append(" order by ");
@@ -359,9 +359,14 @@ public class XPathToSQL2Converter {
                 buff.append(orderList.get(i));
             }
         }
+
+        // leave original xpath string as a comment
+        buff.append(" /* xpath: ");
+        buff.append(query);
+        buff.append(" */");
         return buff.toString();
     }
-    
+
     private void nextSelector(boolean force) throws ParseException {
         boolean isFirstSelector = selectors.size() == 0;
         String path = currentSelector.path;

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java?rev=1478354&r1=1478353&r2=1478354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/plugins/index/property/PropertyIndexQueryTest.java Thu May  2 12:55:31 2013
@@ -16,14 +16,24 @@
  */
 package org.apache.jackrabbit.oak.plugins.index.property;
 
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
 import org.apache.jackrabbit.oak.Oak;
 import org.apache.jackrabbit.oak.api.ContentRepository;
+import org.apache.jackrabbit.oak.api.PropertyValue;
+import org.apache.jackrabbit.oak.api.ResultRow;
 import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexEditorProvider;
 import org.apache.jackrabbit.oak.plugins.index.property.PropertyIndexProvider;
 import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
 import org.apache.jackrabbit.oak.query.AbstractQueryTest;
+import org.apache.jackrabbit.oak.query.JsopUtil;
+import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -42,14 +52,50 @@ public class PropertyIndexQueryTest exte
     }
 
     @Test
+    public void xpath() throws Exception {
+        test("xpath.txt");
+    }
+
+    @Test
+    public void bindVariableTest() throws Exception {
+        JsopUtil.apply(
+                root,
+                "/ + \"test\": { \"hello\": {\"id\": \"1\"}, \"world\": {\"id\": \"2\"}}");
+        root.commit();
+
+        Map<String, PropertyValue> sv = new HashMap<String, PropertyValue>();
+        sv.put("id", PropertyValues.newString("1"));
+        Iterator<? extends ResultRow> result;
+        result = executeQuery("select * from [nt:base] where id = $id",
+                SQL2, sv).getRows().iterator();
+        assertTrue(result.hasNext());
+        assertEquals("/test/hello", result.next().getPath());
+
+        sv.put("id", PropertyValues.newString("2"));
+        result = executeQuery("select * from [nt:base] where id = $id",
+                SQL2, sv).getRows().iterator();
+        assertTrue(result.hasNext());
+        assertEquals("/test/world", result.next().getPath());
+    }
+
+    @Test
     public void sql2Index() throws Exception {
         test("sql2_index.txt");
     }
 
     @Test
-    @Ignore("OAK-590")
-    public void sql2Explain() throws Exception {
-        test("sql2_explain.txt");
+    public void sql2Measure() throws Exception {
+        test("sql2_measure.txt");
+    }
+
+    @Test
+    public void sql1() throws Exception {
+        test("sql1.txt");
+    }
+
+    @Test
+    public void sql2() throws Exception {
+        test("sql2.txt");
     }
 
 }
\ No newline at end of file

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java?rev=1478354&r1=1478353&r2=1478354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/AbstractQueryTest.java Thu May  2 12:55:31 2013
@@ -25,9 +25,7 @@ import java.io.PrintWriter;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Collections;
-import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
 
@@ -41,16 +39,12 @@ import org.apache.jackrabbit.oak.api.Roo
 import org.apache.jackrabbit.oak.api.QueryEngine;
 import org.apache.jackrabbit.oak.api.Tree;
 import org.apache.jackrabbit.oak.api.Type;
-import org.apache.jackrabbit.oak.spi.query.PropertyValues;
 import org.junit.Before;
-import org.junit.Test;
 
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.INDEX_DEFINITIONS_NODE_TYPE;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.REINDEX_PROPERTY_NAME;
 import static org.apache.jackrabbit.oak.plugins.index.IndexConstants.TYPE_PROPERTY_NAME;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 /**
@@ -59,6 +53,7 @@ import static org.junit.Assert.fail;
 public abstract class AbstractQueryTest {
 
     protected static final String TEST_INDEX_NAME = "test-index";
+    protected static final String SQL2 = QueryEngineImpl.SQL2;
 
     protected QueryEngine qe;
     protected ContentSession session;
@@ -101,48 +96,6 @@ public abstract class AbstractQueryTest 
         return qe.executeQuery(statement, language, Long.MAX_VALUE, 0, sv, null);
     }
 
-    @Test
-    public void sql1() throws Exception {
-        test("sql1.txt");
-    }
-
-    @Test
-    public void sql2() throws Exception {
-        test("sql2.txt");
-    }
-
-    @Test
-    public void xpath() throws Exception {
-        test("xpath.txt");
-    }
-
-    @Test
-    public void sql2Measure() throws Exception {
-        test("sql2_measure.txt");
-    }
-
-    @Test
-    public void bindVariableTest() throws Exception {
-        JsopUtil.apply(
-                root,
-                "/ + \"test\": { \"hello\": {\"id\": \"1\"}, \"world\": {\"id\": \"2\"}}");
-        root.commit();
-
-        Map<String, PropertyValue> sv = new HashMap<String, PropertyValue>();
-        sv.put("id", PropertyValues.newString("1"));
-        Iterator<? extends ResultRow> result;
-        result = executeQuery("select * from [nt:base] where id = $id",
-                QueryEngineImpl.SQL2, sv).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("/test/hello", result.next().getPath());
-
-        sv.put("id", PropertyValues.newString("2"));
-        result = executeQuery("select * from [nt:base] where id = $id",
-                QueryEngineImpl.SQL2, sv).getRows().iterator();
-        assertTrue(result.hasNext());
-        assertEquals("/test/world", result.next().getPath());
-    }
-
     protected void test(String file) throws Exception {
         InputStream in = AbstractQueryTest.class.getResourceAsStream(file);
         LineNumberReader r = new LineNumberReader(new InputStreamReader(in));

Added: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java?rev=1478354&view=auto
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java (added)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java Thu May  2 12:55:31 2013
@@ -0,0 +1,30 @@
+package org.apache.jackrabbit.oak.query;
+
+import static org.apache.jackrabbit.JcrConstants.JCR_SYSTEM;
+import static org.apache.jackrabbit.oak.plugins.memory.EmptyNodeState.EMPTY_NODE;
+import static org.apache.jackrabbit.oak.plugins.nodetype.NodeTypeConstants.JCR_NODE_TYPES;
+
+import java.text.ParseException;
+
+import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
+import org.apache.jackrabbit.oak.spi.state.NodeState;
+import org.junit.Test;
+
+public class SQL2ParserTest {
+
+    private final NodeState types = new InitialContent().initialize(EMPTY_NODE)
+            .getChildNode(JCR_SYSTEM).getChildNode(JCR_NODE_TYPES);
+    private final SQL2Parser p = new SQL2Parser(types);
+
+    @Test
+    public void testIgnoreSqlComment() throws ParseException {
+        p.parse("select * from [nt:unstructured] /* sql comment */");
+        p.parse("select [jcr:path], [jcr:score], * from [nt:base] as a /* xpath: //* */");
+    }
+
+    @Test(expected = ParseException.class)
+    public void testUnfinishedSqlComment() throws ParseException {
+        p.parse("select [jcr:path], [jcr:score], * from [nt:base] as a /* xpath: //* ");
+    }
+
+}

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/SQL2ParserTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java?rev=1478354&r1=1478353&r2=1478354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/java/org/apache/jackrabbit/oak/query/index/TraversingIndexQueryTest.java Thu May  2 12:55:31 2013
@@ -18,6 +18,7 @@ import org.apache.jackrabbit.oak.api.Con
 import org.apache.jackrabbit.oak.plugins.nodetype.write.InitialContent;
 import org.apache.jackrabbit.oak.query.AbstractQueryTest;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
+import org.junit.Test;
 
 /**
  * Tests the query engine using the default index implementation: the
@@ -33,4 +34,14 @@ public class TraversingIndexQueryTest ex
             .createContentRepository();
     }
 
+    @Test
+    public void sql1() throws Exception {
+        test("sql1.txt");
+    }
+
+    @Test
+    public void sql2() throws Exception {
+        test("sql2.txt");
+    }
+
 }

Modified: jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt?rev=1478354&r1=1478353&r2=1478354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt (original)
+++ jackrabbit/oak/trunk/oak-core/src/test/resources/org/apache/jackrabbit/oak/query/xpath.txt Thu May  2 12:55:31 2013
@@ -26,28 +26,28 @@
 # jackrabbit test queries
 
 xpath2sql testroot//child/..[@foo1]
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(a, b) where name(a) = 'child' and isdescendantnode(a, '/testroot') and b.[foo1] is not null
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(a, b) where name(a) = 'child' and isdescendantnode(a, '/testroot') and b.[foo1] is not null /* xpath: testroot//child/..[@foo1] */
 
 xpath2sql testroot//child/.[@foo1]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [foo1] is not null and name(a) = 'child' and isdescendantnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [foo1] is not null and name(a) = 'child' and isdescendantnode(a, '/testroot') /* xpath: testroot//child/.[@foo1] */
 
 xpath2sql testroot//child[@foo1]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [foo1] is not null and name(a) = 'child' and isdescendantnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [foo1] is not null and name(a) = 'child' and isdescendantnode(a, '/testroot') /* xpath: testroot//child[@foo1] */
 
 xpath2sql /jcr:root/testroot/node11
-select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/testroot/node11')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/testroot/node11') /* xpath: /jcr:root/testroot/node11 */
 
 xpath2sql /jcr:root/testroot/./node11
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where ischildnode(a, '/testroot') and name(b) = 'node11'
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where ischildnode(a, '/testroot') and name(b) = 'node11' /* xpath: /jcr:root/testroot/./node11 */
 
 xpath2sql /jcr:root/testroot/././node11
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where ischildnode(a, '/testroot') and name(b) = 'node11'
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where ischildnode(a, '/testroot') and name(b) = 'node11' /* xpath: /jcr:root/testroot/././node11 */
 
 xpath /jcr:root/testroot//*[0]
-java.text.ParseException: /jcr:root/testroot//*[0] converted to SQL-2 Query: select [jcr:path], [jcr:score], * from [nt:base] as a where 0(*)is not null and isdescendantnode(a, '/testroot'); expected: NOT, (
+java.text.ParseException: /jcr:root/testroot//*[0] converted to SQL-2 Query: select [jcr:path], [jcr:score], * from [nt:base] as a where 0(*)is not null and isdescendantnode(a, '/testroot') /* xpath: /jcr:root/testroot//*[0] */; expected: NOT, (
 
 xpath2sql /test
-select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'test' and issamenode(a, '/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'test' and issamenode(a, '/') /* xpath: /test */
 
 xpath2sql /
 invalid: Query: (*)/; expected: jcr:root, /, *, text, element, @, (, .
@@ -68,43 +68,43 @@ xpath2sql [@name='data']
 invalid: Query: [(*)@name='data']; expected: /, *, text, element, @, (, .
 
 xpath2sql test
-select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test') /* xpath: test */
 
 xpath2sql jcr:root
-select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/jcr:root')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/jcr:root') /* xpath: jcr:root */
 
 xpath2sql /jcr:root
-select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/') /* xpath: /jcr:root */
 
 xpath2sql //jcr:root
-select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'jcr:root'
+select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'jcr:root' /* xpath: //jcr:root */
 
 xpath2sql *
-select [jcr:path], [jcr:score], * from [nt:base] as a where ischildnode(a, '/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ischildnode(a, '/') /* xpath: * */
 
 xpath2sql /*
-select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/') /* xpath: /* */
 
 xpath2sql //*
-select [jcr:path], [jcr:score], * from [nt:base] as a
+select [jcr:path], [jcr:score], * from [nt:base] as a /* xpath: //* */
 
 xpath2sql test/*
-select [jcr:path], [jcr:score], * from [nt:base] as a where ischildnode(a, '/test')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ischildnode(a, '/test') /* xpath: test/* */
 
 xpath2sql element(*, nt:folder)
-select [jcr:path], [jcr:score], * from [nt:folder] as a where ischildnode(a, '/')
+select [jcr:path], [jcr:score], * from [nt:folder] as a where ischildnode(a, '/') /* xpath: element(*, nt:folder) */
 
 xpath2sql //test
-select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'test'
+select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'test' /* xpath: //test */
 
 xpath2sql /jcr:root[@foo = 'does-not-exist']
-select [jcr:path], [jcr:score], * from [nt:base] as a where [foo] = 'does-not-exist' and issamenode(a, '/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [foo] = 'does-not-exist' and issamenode(a, '/') /* xpath: /jcr:root[@foo = 'does-not-exist'] */
 
 xpath2sql 
-select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'jcr:root'
+select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'jcr:root' /* xpath: //jcr:root */
 
 xpath2sql /jcr:root/testroot/*/node11
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where ischildnode(a, '/testroot') and name(b) = 'node11'
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where ischildnode(a, '/testroot') and name(b) = 'node11' /* xpath: /jcr:root/testroot/*/node11 */
 
 # eq can't currently be supported as there is no equivalent in SQL-2
 # (the behavior is different from = if one of the operands is a multi-valued property)
@@ -112,259 +112,259 @@ xpath2sql //testRoot/*[@jcr:primaryType=
 invalid: Query: //testRoot/*[@jcr:primaryType='nt:unstructured' and @text eq(*)'foo']; expected: ]
 
 xpath2sql //testRoot/*[@text = 'foo']
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testRoot' and b.[text] = 'foo'
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testRoot' and b.[text] = 'foo' /* xpath: //testRoot/*[@text = 'foo'] */
 
 xpath2sql /testRoot/*[@jcr:primaryType='nt:unstructured' and fn:not(@mytext)]
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testRoot' and issamenode(a, '/') and b.[jcr:primaryType] = 'nt:unstructured' and b.[mytext] is null
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testRoot' and issamenode(a, '/') and b.[jcr:primaryType] = 'nt:unstructured' and b.[mytext] is null /* xpath: /testRoot/*[@jcr:primaryType='nt:unstructured' and fn:not(@mytext)] */
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(., '"quick brown" -cat')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, '"quick brown" -cat') and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, '"quick brown" -cat') and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[jcr:contains(., '"quick brown" -cat')] */
 
 xpath2sql //element(*,rep:Authorizable)[(((jcr:contains(profile/givenName,'**') or jcr:contains(profile/familyName,'**')) or jcr:contains(profile/email,'**')) or (jcr:like(rep:principalName,'%%') or jcr:like(fn:name(.),'%%')))] order by rep:principalName ascending
-select [jcr:path], [jcr:score], * from [rep:Authorizable] as a where contains([profile/givenName/*], '**') or contains([profile/familyName/*], '**') or contains([profile/email/*], '**') or [rep:principalName/*] like '%%' or name(a) like '%%' order by [rep:principalName/*]
+select [jcr:path], [jcr:score], * from [rep:Authorizable] as a where contains([profile/givenName/*], '**') or contains([profile/familyName/*], '**') or contains([profile/email/*], '**') or [rep:principalName/*] like '%%' or name(a) like '%%' order by [rep:principalName/*] /* xpath: //element(*,rep:Authorizable)[(((jcr:contains(profile/givenName,'**') or jcr:contains(profile/familyName,'**')) or jcr:contains(profile/email,'**')) or (jcr:like(rep:principalName,'%%') or jcr:like(fn:name(.),'%%')))] order by rep:principalName ascending */
 
 xpath2sql //element(*,rep:Authorizable)[(((jcr:contains(profile/@givenName,'**') or jcr:contains(profile/@familyName,'**')) or jcr:contains(profile/@email,'**')) or (jcr:like(@rep:principalName,'%%') or jcr:like(fn:name(.),'%%')))] order by @rep:principalName ascending
-select [jcr:path], [jcr:score], * from [rep:Authorizable] as a where contains([profile/givenName], '**') or contains([profile/familyName], '**') or contains([profile/email], '**') or [rep:principalName] like '%%' or name(a) like '%%' order by [rep:principalName]
+select [jcr:path], [jcr:score], * from [rep:Authorizable] as a where contains([profile/givenName], '**') or contains([profile/familyName], '**') or contains([profile/email], '**') or [rep:principalName] like '%%' or name(a) like '%%' order by [rep:principalName] /* xpath: //element(*,rep:Authorizable)[(((jcr:contains(profile/@givenName,'**') or jcr:contains(profile/@familyName,'**')) or jcr:contains(profile/@email,'**')) or (jcr:like(@rep:principalName,'%%') or jcr:like(fn:name(.),'%%')))] order by @rep:principalName ascending */
 
 xpath2sql /jcr:root/testroot//*[jcr:contains(@jcr:data, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where contains([jcr:data], 'lazy') and isdescendantnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([jcr:data], 'lazy') and isdescendantnode(a, '/testroot') /* xpath: /jcr:root/testroot//*[jcr:contains(@jcr:data, 'lazy')] */
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(jcr:content, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where contains([jcr:content/*], 'lazy') and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([jcr:content/*], 'lazy') and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[jcr:contains(jcr:content, 'lazy')] */
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(*, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/*], 'lazy') and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/*], 'lazy') and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[jcr:contains(*, 'lazy')] */
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(*/@jcr:data, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/jcr:data], 'lazy') and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/jcr:data], 'lazy') and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[jcr:contains(*/@jcr:data, 'lazy')] */
 
 xpath2sql /jcr:root/testroot/*[jcr:contains(*/@*, 'lazy')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/*], 'lazy') and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains([*/*], 'lazy') and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[jcr:contains(*/@*, 'lazy')] */
 
 xpath2sql /jcr:root/testroot/*[@prop1 = 1 and jcr:like(fn:name(), 'F%')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [prop1] = 1 and name(a) like 'F%' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [prop1] = 1 and name(a) like 'F%' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[@prop1 = 1 and jcr:like(fn:name(), 'F%')] */
 
 # TODO support rep:excerpt() and rep:similar()? how?
 xpath2sql /jcr:root/testroot/*[jcr:contains(., 'jackrabbit')]/rep:excerpt(.)
 invalid: Query: /jcr:root/testroot/*[jcr:contains(., 'jackrabbit')]/rep:excerpt((*).); expected: <end>
 
 xpath2sql //testroot/*[@jcr:primaryType='nt:unstructured' and fn:not(@mytext)]
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testroot' and b.[jcr:primaryType] = 'nt:unstructured' and b.[mytext] is null
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testroot' and b.[jcr:primaryType] = 'nt:unstructured' and b.[mytext] is null /* xpath: //testroot/*[@jcr:primaryType='nt:unstructured' and fn:not(@mytext)] */
 
 xpath2sql /jcr:root/testroot/people/jcr:deref(@worksfor, '*')
 invalid: Query: /jcr:root/testroot/people/jcr:deref((*)@worksfor, '*'); expected: <end>
 
 xpath2sql //*[@jcr:primaryType='nt:unstructured' and jcr:like(@foo,"%ar'ba%")]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'nt:unstructured' and [foo] like '%ar''ba%'
+select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'nt:unstructured' and [foo] like '%ar''ba%' /* xpath: //*[@jcr:primaryType='nt:unstructured' and jcr:like(@foo,"%ar'ba%")] */
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) = 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) = 'foo' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) = 'foo' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[fn:lower-case(@prop1) = 'foo'] */
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) != 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) <> 'foo' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) <> 'foo' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[fn:lower-case(@prop1) != 'foo'] */
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) <= 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) <= 'foo' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) <= 'foo' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[fn:lower-case(@prop1) <= 'foo'] */
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) >= 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) >= 'foo' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) >= 'foo' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[fn:lower-case(@prop1) >= 'foo'] */
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) < 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) < 'foo' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) < 'foo' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[fn:lower-case(@prop1) < 'foo'] */
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) > 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) > 'foo' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) > 'foo' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[fn:lower-case(@prop1) > 'foo'] */
 
 xpath2sql /jcr:root/testroot/*[fn:lower-case(@prop1) <> 'foo']
-select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) <> 'foo' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where lower([prop1]) <> 'foo' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[fn:lower-case(@prop1) <> 'foo'] */
 
 xpath2sql /jcr:root/testroot/*[@prop1 = 1 and fn:name() = 'node1']
-select [jcr:path], [jcr:score], * from [nt:base] as a where [prop1] = 1 and name(a) = 'node1' and ischildnode(a, '/testroot')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [prop1] = 1 and name(a) = 'node1' and ischildnode(a, '/testroot') /* xpath: /jcr:root/testroot/*[@prop1 = 1 and fn:name() = 'node1'] */
 
 # sling queries
 
 xpath2sql //element(*,mix:language)[fn:lower-case(@jcr:language)='en']//element(*,sling:Message)[@sling:message]/(@sling:key|@sling:message)
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.[sling:key] as [sling:key], b.[sling:message] as [sling:message] from [mix:language] as a inner join [sling:Message] as b on isdescendantnode(b, a) where lower(a.[jcr:language]) = 'en' and b.[sling:message] is not null
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.[sling:key] as [sling:key], b.[sling:message] as [sling:message] from [mix:language] as a inner join [sling:Message] as b on isdescendantnode(b, a) where lower(a.[jcr:language]) = 'en' and b.[sling:message] is not null /* xpath: //element(*,mix:language)[fn:lower-case(@jcr:language)='en']//element(*,sling:Message)[@sling:message]/(@sling:key|@sling:message) */
 
 xpath2sql //element(*,mix:language)[fn:upper-case(@jcr:language)='en']//element(*,sling:Message)[@sling:message]/(@sling:key|@sling:message)
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.[sling:key] as [sling:key], b.[sling:message] as [sling:message] from [mix:language] as a inner join [sling:Message] as b on isdescendantnode(b, a) where upper(a.[jcr:language]) = 'en' and b.[sling:message] is not null
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.[sling:key] as [sling:key], b.[sling:message] as [sling:message] from [mix:language] as a inner join [sling:Message] as b on isdescendantnode(b, a) where upper(a.[jcr:language]) = 'en' and b.[sling:message] is not null /* xpath: //element(*,mix:language)[fn:upper-case(@jcr:language)='en']//element(*,sling:Message)[@sling:message]/(@sling:key|@sling:message) */
 
 # jboss example queries
 
 xpath2sql //element(*,my:type)
-select [jcr:path], [jcr:score], * from [my:type] as a
+select [jcr:path], [jcr:score], * from [my:type] as a /* xpath: //element(*,my:type) */
 
 xpath2sql //element(*,my:type)/@my:title
-select [jcr:path], [jcr:score], [my:title] from [my:type] as a
+select [jcr:path], [jcr:score], [my:title] from [my:type] as a /* xpath: //element(*,my:type)/@my:title */
 
 xpath2sql //element(*,my:type)/(@my:title | @my:text)
-select [jcr:path], [jcr:score], [my:title], [my:text] from [my:type] as a
+select [jcr:path], [jcr:score], [my:title], [my:text] from [my:type] as a /* xpath: //element(*,my:type)/(@my:title | @my:text) */
 
 # other queries
 
 xpath2sql /jcr:root/testdata/node[@jcr:primaryType]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] is not null and issamenode(a, '/testdata/node')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] is not null and issamenode(a, '/testdata/node') /* xpath: /jcr:root/testdata/node[@jcr:primaryType] */
 
 xpath2sql //testroot/*[@jcr:primaryType='nt:unstructured'] order by @prop2, @prop1
-select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testroot' and b.[jcr:primaryType] = 'nt:unstructured' order by b.[prop2], b.[prop1]
+select b.[jcr:path] as [jcr:path], b.[jcr:score] as [jcr:score], b.* from [nt:base] as a inner join [nt:base] as b on ischildnode(b, a) where name(a) = 'testroot' and b.[jcr:primaryType] = 'nt:unstructured' order by b.[prop2], b.[prop1] /* xpath: //testroot/*[@jcr:primaryType='nt:unstructured'] order by @prop2, @prop1 */
 
 xpath2sql /jcr:root/test//jcr:xmltext
-select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'jcr:xmltext' and isdescendantnode(a, '/test')
+select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'jcr:xmltext' and isdescendantnode(a, '/test') /* xpath: /jcr:root/test//jcr:xmltext */
 
 xpath2sql /jcr:root/test//text()
-select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'jcr:xmltext' and isdescendantnode(a, '/test')
+select [jcr:path], [jcr:score], * from [nt:base] as a where name(a) = 'jcr:xmltext' and isdescendantnode(a, '/test') /* xpath: /jcr:root/test//text() */
 
 xpath2sql /jcr:root/test/jcr:xmltext
-select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test/jcr:xmltext')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test/jcr:xmltext') /* xpath: /jcr:root/test/jcr:xmltext */
 
 xpath2sql /jcr:root/test/text()
-select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test/jcr:xmltext')
+select [jcr:path], [jcr:score], * from [nt:base] as a where issamenode(a, '/test/jcr:xmltext') /* xpath: /jcr:root/test/text() */
 
 xpath2sql //*[@name='Hello']
-select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello'
+select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello' /* xpath: //*[@name='Hello'] */
 
 xpath2sql /jcr:root//*[@name='Hello']
-select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello' and isdescendantnode(a, '/')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello' and isdescendantnode(a, '/') /* xpath: /jcr:root//*[@name='Hello'] */
 
 xpath2sql content/*
-select [jcr:path], [jcr:score], * from [nt:base] as a where ischildnode(a, '/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ischildnode(a, '/content') /* xpath: content/* */
 
 xpath2sql content//*
-select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/content') /* xpath: content//* */
 
 xpath2sql content//*[@name='Hello']
-select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello' and isdescendantnode(a, '/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello' and isdescendantnode(a, '/content') /* xpath: content//*[@name='Hello'] */
 
 xpath2sql /jcr:root/content//*[@name='Hello']
-select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello' and isdescendantnode(a, '/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [name] = 'Hello' and isdescendantnode(a, '/content') /* xpath: /jcr:root/content//*[@name='Hello'] */
 
 xpath2sql //*[jcr:contains(., 'test')] order by @jcr:score
-select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, 'test') order by [jcr:score]
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, 'test') order by [jcr:score] /* xpath: //*[jcr:contains(., 'test')] order by @jcr:score */
 
 xpath2sql /jcr:root//*[jcr:contains(., 'test')] order by @jcr:score
-select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, 'test') and isdescendantnode(a, '/') order by [jcr:score]
+select [jcr:path], [jcr:score], * from [nt:base] as a where contains(*, 'test') and isdescendantnode(a, '/') order by [jcr:score] /* xpath: /jcr:root//*[jcr:contains(., 'test')] order by @jcr:score */
 
 xpath2sql /jcr:root//element(*, test)
-select [jcr:path], [jcr:score], * from [test] as a where isdescendantnode(a, '/')
+select [jcr:path], [jcr:score], * from [test] as a where isdescendantnode(a, '/') /* xpath: /jcr:root//element(*, test) */
 
 xpath2sql /jcr:root//element(*, user)[test/@jcr:primaryType]
-select [jcr:path], [jcr:score], * from [user] as a where [test/jcr:primaryType] is not null and isdescendantnode(a, '/')
+select [jcr:path], [jcr:score], * from [user] as a where [test/jcr:primaryType] is not null and isdescendantnode(a, '/') /* xpath: /jcr:root//element(*, user)[test/@jcr:primaryType] */
 
 xpath2sql /jcr:root/content//*[(@sling:resourceType = 'start')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] = 'start' and isdescendantnode(a, '/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] = 'start' and isdescendantnode(a, '/content') /* xpath: /jcr:root/content//*[(@sling:resourceType = 'start')] */
 
 xpath2sql /jcr:root/content//*[(@sling:resourceType = 'page')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] = 'page' and isdescendantnode(a, '/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] = 'page' and isdescendantnode(a, '/content') /* xpath: /jcr:root/content//*[(@sling:resourceType = 'page')] */
 
 xpath2sql /jcr:root/content//*[@offTime > xs:dateTime('2012-03-28T15:56:18.327+02:00') or @onTime > xs:dateTime('2012-03-28T15:56:18.327+02:00')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where ([offTime] > cast('2012-03-28T15:56:18.327+02:00' as date) or [onTime] > cast('2012-03-28T15:56:18.327+02:00' as date)) and isdescendantnode(a, '/content')
+select [jcr:path], [jcr:score], * from [nt:base] as a where ([offTime] > cast('2012-03-28T15:56:18.327+02:00' as date) or [onTime] > cast('2012-03-28T15:56:18.327+02:00' as date)) and isdescendantnode(a, '/content') /* xpath: /jcr:root/content//*[@offTime > xs:dateTime('2012-03-28T15:56:18.327+02:00') or @onTime > xs:dateTime('2012-03-28T15:56:18.327+02:00')] */
 
 xpath2sql /jcr:root/content/campaigns//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified descending
-select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'Page' and isdescendantnode(a, '/content/campaigns') order by [jcr:content/lastModified] desc
+select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'Page' and isdescendantnode(a, '/content/campaigns') order by [jcr:content/lastModified] desc /* xpath: /jcr:root/content/campaigns//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified descending */
 
 xpath2sql /jcr:root/content/campaigns//element(*, PageContent)[(@sling:resourceType = 'teaser' or @sling:resourceType = 'newsletter' or @teaserPageType = 'newsletter' or @teaserPageType = 'tweet') and ((@onTime < xs:dateTime('2012-04-01T00:00:00.000+02:00')) or not(@onTime)) and ((@offTime >= xs:dateTime('2012-02-26T00:00:00.000+01:00')) or not(@offTime))] order by @onTime
-select [jcr:path], [jcr:score], * from [PageContent] as a where ([sling:resourceType] = 'teaser' or [sling:resourceType] = 'newsletter' or [teaserPageType] = 'newsletter' or [teaserPageType] = 'tweet') and ([onTime] < cast('2012-04-01T00:00:00.000+02:00' as date) or [onTime] is null) and ([offTime] >= cast('2012-02-26T00:00:00.000+01:00' as date) or [offTime] is null) and isdescendantnode(a, '/content/campaigns') order by [onTime]
+select [jcr:path], [jcr:score], * from [PageContent] as a where ([sling:resourceType] = 'teaser' or [sling:resourceType] = 'newsletter' or [teaserPageType] = 'newsletter' or [teaserPageType] = 'tweet') and ([onTime] < cast('2012-04-01T00:00:00.000+02:00' as date) or [onTime] is null) and ([offTime] >= cast('2012-02-26T00:00:00.000+01:00' as date) or [offTime] is null) and isdescendantnode(a, '/content/campaigns') order by [onTime] /* xpath: /jcr:root/content/campaigns//element(*, PageContent)[(@sling:resourceType = 'teaser' or @sling:resourceType = 'newsletter' or @teaserPageType = 'newsletter' or @teaserPageType = 'tweet') and ((@onTime < xs:dateTime('2012-04-01T00:00:00.000+02:00')) or not(@onTime)) and ((@offTime >= xs:dateTime('2012-02-26T00:00:00.000+01:00')) or not(@offTime))] order by @onTime */
 
 xpath2sql /jcr:root/content/dam//element(*, asset)
-select [jcr:path], [jcr:score], * from [asset] as a where isdescendantnode(a, '/content/dam')
+select [jcr:path], [jcr:score], * from [asset] as a where isdescendantnode(a, '/content/dam') /* xpath: /jcr:root/content/dam//element(*, asset) */
 
 xpath2sql /jcr:root/content/dam//element(*, asset)[jcr:content/metadata/@dam:scene]
-select [jcr:path], [jcr:score], * from [asset] as a where [jcr:content/metadata/dam:scene] is not null and isdescendantnode(a, '/content/dam')
+select [jcr:path], [jcr:score], * from [asset] as a where [jcr:content/metadata/dam:scene] is not null and isdescendantnode(a, '/content/dam') /* xpath: /jcr:root/content/dam//element(*, asset)[jcr:content/metadata/@dam:scene] */
 
 xpath2sql /jcr:root/etc/cloud//*[(@sling:resourceType = 'framework')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] = 'framework' and isdescendantnode(a, '/etc/cloud')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] = 'framework' and isdescendantnode(a, '/etc/cloud') /* xpath: /jcr:root/etc/cloud//*[(@sling:resourceType = 'framework')] */
 
 xpath2sql /jcr:root/etc/cloud//*[(@sling:resourceType = 'analytics')]
-select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] = 'analytics' and isdescendantnode(a, '/etc/cloud')
+select [jcr:path], [jcr:score], * from [nt:base] as a where [sling:resourceType] = 'analytics' and isdescendantnode(a, '/etc/cloud') /* xpath: /jcr:root/etc/cloud//*[(@sling:resourceType = 'analytics')] */
 
 xpath2sql /jcr:root/etc/reports//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified descending
-select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'Page' and isdescendantnode(a, '/etc/reports') order by [jcr:content/lastModified] desc
+select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'Page' and isdescendantnode(a, '/etc/reports') order by [jcr:content/lastModified] desc /* xpath: /jcr:root/etc/reports//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified descending */
 
 xpath2sql /jcr:root/etc/segment//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified descending
-select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'Page' and isdescendantnode(a, '/etc/segment') order by [jcr:content/lastModified] desc
+select [jcr:path], [jcr:score], * from [nt:base] as a where [jcr:primaryType] = 'Page' and isdescendantnode(a, '/etc/segment') order by [jcr:content/lastModified] desc /* xpath: /jcr:root/etc/segment//*[@jcr:primaryType='Page'] order by jcr:content/@lastModified descending */
 
 xpath2sql /jcr:root/etc/workflow//element(*,Item)[not(meta/@archived) and not(meta/@archived = true)]
-select [jcr:path], [jcr:score], * from [Item] as a where [meta/archived] is null and not([meta/archived] = true) and isdescendantnode(a, '/etc/workflow')
+select [jcr:path], [jcr:score], * from [Item] as a where [meta/archived] is null and not([meta/archived] = true) and isdescendantnode(a, '/etc/workflow') /* xpath: /jcr:root/etc/workflow//element(*,Item)[not(meta/@archived) and not(meta/@archived = true)] */
 
 xpath2sql /jcr:root/home//element()
-select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/home')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/home') /* xpath: /jcr:root/home//element() */
 
 xpath2sql /jcr:root/home//element(*)
-select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/home')
+select [jcr:path], [jcr:score], * from [nt:base] as a where isdescendantnode(a, '/home') /* xpath: /jcr:root/home//element(*) */
 
 # other queries
 
 xpath2sql //element(*, my:type)
-select [jcr:path], [jcr:score], * from [my:type] as a
+select [jcr:path], [jcr:score], * from [my:type] as a /* xpath: //element(*, my:type) */
 
 xpath2sql //element(*, my:type)/@my:title
-select [jcr:path], [jcr:score], [my:title] from [my:type] as a
+select [jcr:path], [jcr:score], [my:title] from [my:type] as a /* xpath: //element(*, my:type)/@my:title */
 
 xpath2sql //element(*, my:type)/(@my:title | @my:text)
-select [jcr:path], [jcr:score], [my:title], [my:text] from [my:type] as a
+select [jcr:path], [jcr:score], [my:title], [my:text] from [my:type] as a /* xpath: //element(*, my:type)/(@my:title | @my:text) */
 
 xpath2sql /jcr:root/nodes//element(*, my:type)
-select [jcr:path], [jcr:score], * from [my:type] as a where isdescendantnode(a, '/nodes')
+select [jcr:path], [jcr:score], * from [my:type] as a where isdescendantnode(a, '/nodes') /* xpath: /jcr:root/nodes//element(*, my:type) */
 
 xpath2sql /jcr:root/some/element(nodes, my:type)
-select [jcr:path], [jcr:score], * from [my:type] as a where issamenode(a, '/some/nodes')
+select [jcr:path], [jcr:score], * from [my:type] as a where issamenode(a, '/some/nodes') /* xpath: /jcr:root/some/element(nodes, my:type) */
 
 xpath2sql /jcr:root/some/nodes/element(*, my:type)
-select [jcr:path], [jcr:score], * from [my:type] as a where ischildnode(a, '/some/nodes')
+select [jcr:path], [jcr:score], * from [my:type] as a where ischildnode(a, '/some/nodes') /* xpath: /jcr:root/some/nodes/element(*, my:type) */
 
 xpath2sql /jcr:root/some/nodes//element(*, my:type)
-select [jcr:path], [jcr:score], * from [my:type] as a where isdescendantnode(a, '/some/nodes')
+select [jcr:path], [jcr:score], * from [my:type] as a where isdescendantnode(a, '/some/nodes') /* xpath: /jcr:root/some/nodes//element(*, my:type) */
 
 xpath2sql //element(*, my:type)[@my:title = 'JSR 170']
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] = 'JSR 170'
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] = 'JSR 170' /* xpath: //element(*, my:type)[@my:title = 'JSR 170'] */
 
 xpath2sql //element(*, my:type)[jcr:like(@title,'%Java%')]
-select [jcr:path], [jcr:score], * from [my:type] as a where [title] like '%Java%'
+select [jcr:path], [jcr:score], * from [my:type] as a where [title] like '%Java%' /* xpath: //element(*, my:type)[jcr:like(@title,'%Java%')] */
 
 xpath2sql //element(*, my:type)[jcr:contains(., 'JSR 170')]
-select [jcr:path], [jcr:score], * from [my:type] as a where contains(*, 'JSR 170')
+select [jcr:path], [jcr:score], * from [my:type] as a where contains(*, 'JSR 170') /* xpath: //element(*, my:type)[jcr:contains(., 'JSR 170')] */
 
 xpath2sql //element(*, my:type)[@my:title]
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is not null
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is not null /* xpath: //element(*, my:type)[@my:title] */
 
 xpath2sql //element(*, my:type)[not(@my:title)]
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is null
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is null /* xpath: //element(*, my:type)[not(@my:title)] */
 
 xpath2sql //element(*, my:type)[@my:value < -1.0]
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] < -1.0
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] < -1.0 /* xpath: //element(*, my:type)[@my:value < -1.0] */
 
 xpath2sql //element(*, my:type)[@my:value > +10123123123]
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] > 10123123123
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] > 10123123123 /* xpath: //element(*, my:type)[@my:value > +10123123123] */
 
 xpath2sql //element(*, my:type)[@my:value <= 10.3e-3]
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] <= 10.3e-3
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] <= 10.3e-3 /* xpath: //element(*, my:type)[@my:value <= 10.3e-3] */
 
 xpath2sql //element(*, my:type)[@my:value >= 0e3]
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] >= 0e3
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] >= 0e3 /* xpath: //element(*, my:type)[@my:value >= 0e3] */
 
 xpath2sql //element(*, my:type)[@my:value <> 'Joe''s Caffee']
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] <> 'Joe''s Caffee'
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:value] <> 'Joe''s Caffee' /* xpath: //element(*, my:type)[@my:value <> 'Joe''s Caffee'] */
 
 xpath2sql //element(*, my:type)[(not(@my:title) and @my:subject)]
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is null and [my:subject] is not null
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is null and [my:subject] is not null /* xpath: //element(*, my:type)[(not(@my:title) and @my:subject)] */
 
 xpath2sql //element(*, my:type)[not(@my:title) or @my:subject]
-select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is null or [my:subject] is not null
+select [jcr:path], [jcr:score], * from [my:type] as a where [my:title] is null or [my:subject] is not null /* xpath: //element(*, my:type)[not(@my:title) or @my:subject] */
 
 xpath2sql //element(*, my:type)[not(@my:value > 0 and @my:value < 100)]
-select [jcr:path], [jcr:score], * from [my:type] as a where not([my:value] > 0 and [my:value] < 100)
+select [jcr:path], [jcr:score], * from [my:type] as a where not([my:value] > 0 and [my:value] < 100) /* xpath: //element(*, my:type)[not(@my:value > 0 and @my:value < 100)] */
 
 xpath2sql //element(*, my:type) order by @jcr:lastModified
-select [jcr:path], [jcr:score], * from [my:type] as a order by [jcr:lastModified]
+select [jcr:path], [jcr:score], * from [my:type] as a order by [jcr:lastModified] /* xpath: //element(*, my:type) order by @jcr:lastModified */
 
 xpath2sql //element(*, my:type) order by @my:date descending, @my:title ascending
-select [jcr:path], [jcr:score], * from [my:type] as a order by [my:date] desc, [my:title]
+select [jcr:path], [jcr:score], * from [my:type] as a order by [my:date] desc, [my:title] /* xpath: //element(*, my:type) order by @my:date descending, @my:title ascending */
 
 xpath2sql //element(*, my:type)[jcr:contains(., 'jcr')] order by jcr:score() descending
-select [jcr:path], [jcr:score], * from [my:type] as a where contains(*, 'jcr') order by score(a) desc
+select [jcr:path], [jcr:score], * from [my:type] as a where contains(*, 'jcr') order by score(a) desc /* xpath: //element(*, my:type)[jcr:contains(., 'jcr')] order by jcr:score() descending */
 
 xpath2sql //element(*, my:type)[jcr:contains(@my:title, 'jcr')] order by jcr:score() descending
-select [jcr:path], [jcr:score], * from [my:type] as a where contains([my:title], 'jcr') order by score(a) desc
+select [jcr:path], [jcr:score], * from [my:type] as a where contains([my:title], 'jcr') order by score(a) desc /* xpath: //element(*, my:type)[jcr:contains(@my:title, 'jcr')] order by jcr:score() descending */
 
 xpath2sql [invalid/query
 invalid: Query: [(*)invalid/query; expected: /, *, text, element, @, (, .

Modified: jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java?rev=1478354&r1=1478353&r2=1478354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/main/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexUpdate.java Thu May  2 12:55:31 2013
@@ -118,13 +118,6 @@ class LuceneIndexUpdate implements Close
         remove.add(path.substring(this.path.length()));
     }
 
-    boolean getAndResetReindexFlag() {
-        PropertyState property = index.getProperty(REINDEX_PROPERTY_NAME);
-        boolean reindex = property != null && property.getValue(Type.BOOLEAN);
-        index.setProperty(REINDEX_PROPERTY_NAME, false);
-        return reindex;
-    }
-
     public void apply() throws CommitFailedException {
         if(remove.isEmpty() && insert.isEmpty()){
             return;

Modified: jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java?rev=1478354&r1=1478353&r2=1478354&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java (original)
+++ jackrabbit/oak/trunk/oak-lucene/src/test/java/org/apache/jackrabbit/oak/plugins/index/lucene/LuceneIndexQueryTest.java Thu May  2 12:55:31 2013
@@ -29,7 +29,6 @@ import org.apache.jackrabbit.oak.plugins
 import org.apache.jackrabbit.oak.query.AbstractQueryTest;
 import org.apache.jackrabbit.oak.query.JsopUtil;
 import org.apache.jackrabbit.oak.spi.security.OpenSecurityProvider;
-import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -48,10 +47,15 @@ public class LuceneIndexQueryTest extend
     @Override
     protected ContentRepository createRepository() {
         return new Oak().with(new InitialContent())
-            .with(new OpenSecurityProvider())
-            .with(new LowCostLuceneIndexProvider())
-            .with(new LuceneIndexEditorProvider())
-            .createContentRepository();
+                .with(new OpenSecurityProvider())
+                .with(new LowCostLuceneIndexProvider())
+                .with(new LuceneIndexEditorProvider())
+                .createContentRepository();
+    }
+
+    @Test
+    public void sql1() throws Exception {
+        test("sql1.txt");
     }
 
     @Test
@@ -60,9 +64,8 @@ public class LuceneIndexQueryTest extend
     }
 
     @Test
-    @Ignore("OAK-420")
-    public void sql2Measure() throws Exception {
-        test("sql2_measure.txt");
+    public void xpath() throws Exception {
+        test("xpath.txt");
     }
 
     @Test



Mime
View raw message