drill-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From par...@apache.org
Subject [5/9] drill git commit: DRILL-2904: Fix wrong "before rows" message to "after rows" message
Date Wed, 06 May 2015 05:26:21 GMT
DRILL-2904: Fix wrong "before rows" message to "after rows" message

- Worked around Avatica isBeforeFirst()/next() bug.
- Fixed corresponding error in unit test.
- Also fixed other backwards test-failure message wording.


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

Branch: refs/heads/master
Commit: c492d4f88fa8ae2546205105c76ac48728cfecbe
Parents: 7b776e7
Author: dbarclay <dbarclay@maprtech.com>
Authored: Tue Apr 28 11:14:11 2015 -0700
Committer: Parth Chandra <pchandra@maprtech.com>
Committed: Tue May 5 19:29:17 2015 -0700

----------------------------------------------------------------------
 .../org/apache/drill/jdbc/AvaticaDrillSqlAccessor.java | 13 +++++++++----
 .../java/org/apache/drill/jdbc/DrillResultSetTest.java |  9 +++++----
 2 files changed, 14 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/c492d4f8/exec/jdbc/src/main/java/org/apache/drill/jdbc/AvaticaDrillSqlAccessor.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/AvaticaDrillSqlAccessor.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/AvaticaDrillSqlAccessor.java
index 2b20f23..f5aa3b7 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/AvaticaDrillSqlAccessor.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/AvaticaDrillSqlAccessor.java
@@ -58,13 +58,18 @@ public class AvaticaDrillSqlAccessor implements Accessor {
   }
 
   private int getCurrentRecordNumber() throws SQLException {
-    if ( cursor.getResultSet().isBeforeFirst() ) {
+    // WORKAROUND:  isBeforeFirst can't be called first here because AvaticaResultSet
+    // .next() doesn't increment its row field when cursor.next() returns false,
+    // so in that case row can be left at -1, so isBeforeFirst() returns true
+    // even though we're not longer before the empty set of rows--and it's all
+    // private, so we can't get to it to override any of several candidates.
+    if ( cursor.getResultSet().isAfterLast() ) {
       throw new InvalidCursorStateSqlException(
-          "Result set cursor is positioned before all rows.  Call next() first." );
+          "Result set cursor is already positioned past all rows." );
     }
-    else if ( cursor.getResultSet().isAfterLast() ) {
+    else if ( cursor.getResultSet().isBeforeFirst() ) {
       throw new InvalidCursorStateSqlException(
-          "Result set cursor is already positioned past all rows." );
+          "Result set cursor is positioned before all rows.  Call next() first." );
     }
     else {
       return cursor.getCurrentRecordNumber();

http://git-wip-us.apache.org/repos/asf/drill/blob/c492d4f8/exec/jdbc/src/test/java/org/apache/drill/jdbc/DrillResultSetTest.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DrillResultSetTest.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DrillResultSetTest.java
index 64be408..2df173e 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/DrillResultSetTest.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/DrillResultSetTest.java
@@ -106,7 +106,7 @@ public class DrillResultSetTest extends DrillTest {
     // Main check:  That row data access methods now throw SQLException.
     try {
       resultSet.getInt( 1 );
-      fail( "Did get expected SQLException." );
+      fail( "Didn't get expected SQLException." );
     }
     catch ( SQLException e ) {
       // Expect something like current InvalidCursorStateSqlException saying
@@ -139,13 +139,14 @@ public class DrillResultSetTest extends DrillTest {
     // Main check:  That row data access methods throw SQLException.
     try {
       resultSet.getString( 1 );
-      fail( "Did get expected SQLException." );
+      fail( "Didn't get expected SQLException." );
     }
     catch ( SQLException e ) {
       // Expect something like current InvalidRowSQLException saying
-      // "Result set cursor is still before all rows.  Call next() first."
+      // "Result set cursor is already positioned past all rows."
       assertThat( e, instanceOf( InvalidCursorStateSqlException.class ) );
-      assertThat( e.toString(), containsString( "before" ) );
+      assertThat( e.toString(), containsString( "past" ) );
+      assertThat( e.toString(), containsString( "rows" ) );
     }
     // (Any non-SQLException exception is unexpected result.)
 


Mime
View raw message