[1/2] phoenix git commit: PHOENIX-1753 Query with RVC that doesn't lead with the row key can return incorrect results

2015-03-22 Thread jamestaylor
Repository: phoenix
Updated Branches:
  refs/heads/3.0 5b453e39b - 7ccd2542c


PHOENIX-1753 Query with RVC that doesn't lead with the row key can return 
incorrect results


Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo
Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/decb89d3
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/decb89d3
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/decb89d3

Branch: refs/heads/3.0
Commit: decb89d3241349e9c11c516dc985a5430a6206ad
Parents: 5b453e3
Author: James Taylor jtay...@salesforce.com
Authored: Thu Mar 19 18:54:57 2015 -0700
Committer: James Taylor jtay...@salesforce.com
Committed: Sat Mar 21 23:02:04 2015 -0700

--
 .../phoenix/end2end/RowValueConstructorIT.java  | 33 +++-
 .../apache/phoenix/compile/WhereOptimizer.java  |  4 +++
 .../phoenix/compile/WhereOptimizerTest.java | 16 ++
 3 files changed, 52 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/decb89d3/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
index 8d67fa4..3859785 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/RowValueConstructorIT.java
@@ -1362,6 +1362,37 @@ public class RowValueConstructorIT extends 
BaseClientManagedTimeIT {
 conn.close();
 }
 
-
+@Test
+public void testRVCWithRowKeyNotLeading() throws Exception {
+String ddl = CREATE TABLE sorttest4 (rownum BIGINT primary key, name 
varchar(16), age integer);
+Connection conn = nextConnection(getUrl());
+conn.createStatement().execute(ddl);
+conn.close();
+conn = nextConnection(getUrl());
+String dml = UPSERT INTO sorttest4 (rownum, name, age) values (?, ?, 
?);
+PreparedStatement stmt = conn.prepareStatement(dml);
+stmt.setInt(1, 1);
+stmt.setString(2, A);
+stmt.setInt(3, 1);
+stmt.executeUpdate();
+stmt.setInt(1, 2);
+stmt.setString(2, B);
+stmt.setInt(3, 2);
+stmt.executeUpdate();
+conn.commit();
+conn.close();
+// the below query should only return one record - (1, A, 1)
+String query = SELECT rownum, name, age FROM sorttest4 where (age, 
rownum)  (2, 2);
+conn = nextConnection(getUrl());
+ResultSet rs = conn.createStatement().executeQuery(query);
+int numRecords = 0;
+while (rs.next()) {
+assertEquals(1, rs.getInt(1));
+assertEquals(A, rs.getString(2));
+assertEquals(1, rs.getInt(3));
+numRecords++;
+}
+assertEquals(1, numRecords);
+}
 
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/decb89d3/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
index bc9e8e8..ea08721 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/WhereOptimizer.java
@@ -541,6 +541,10 @@ public class WhereOptimizer {
 int span = position - initialPosition;
 return new SingleKeySlot(new 
RowValueConstructorKeyPart(table.getPKColumns().get(initialPosition), rvc, 
span, childSlots), initialPosition, span, EVERYTHING_RANGES);
 }
+// If we don't clear the child list, we end up passing some of
+// the child expressions of previous matches up the tree, causing
+// those expressions to form the scan start/stop key. PHOENIX-1753
+childSlots.clear();
 return null;
 }
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/decb89d3/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
--
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
index b334013..0d0903e 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/compile/WhereOptimizerTest.java
@@ -1248,6 +1248,22 @@ public class WhereOptimizerTest extends 
BaseConnectionlessQueryTest {
  

Apache-Phoenix | 3.0 | Hadoop1 | Build Successful

2015-03-22 Thread Apache Jenkins Server
3.0 branch build status Successful
Source repository https://git-wip-us.apache.org/repos/asf/phoenix.git

Last Successful Compiled Artifacts https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastSuccessfulBuild/artifact/

Last Complete Test Report https://builds.apache.org/job/Phoenix-3.0-hadoop1/lastCompletedBuild/testReport/

Changes
[jtaylor] PHOENIX-1753 Query with RVC that doesn't lead with the row key can return incorrect results

[jtaylor] PHOENIX-1703 Fail connection when server minor version is less than client minor version



Build times for last couple of runsLatest build time is the right most | Legend blue: normal, red: test failure, gray: timeout