Return-Path: X-Original-To: apmail-drill-commits-archive@www.apache.org Delivered-To: apmail-drill-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4B4B717C65 for ; Thu, 26 Feb 2015 01:25:22 +0000 (UTC) Received: (qmail 52836 invoked by uid 500); 26 Feb 2015 01:25:22 -0000 Delivered-To: apmail-drill-commits-archive@drill.apache.org Received: (qmail 52807 invoked by uid 500); 26 Feb 2015 01:25:22 -0000 Mailing-List: contact commits-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: commits@drill.apache.org Delivered-To: mailing list commits@drill.apache.org Received: (qmail 52798 invoked by uid 99); 26 Feb 2015 01:25:22 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 26 Feb 2015 01:25:22 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CE0DCE084F; Thu, 26 Feb 2015 01:25:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: parthc@apache.org To: commits@drill.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: drill git commit: DRILL-1378: Ctrl-C to cancel a query that has not returned with the first result set. Date: Thu, 26 Feb 2015 01:25:21 +0000 (UTC) Repository: drill Updated Branches: refs/heads/master f7ef5ec78 -> 471013836 DRILL-1378: Ctrl-C to cancel a query that has not returned with the first result set. Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/47101383 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/47101383 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/47101383 Branch: refs/heads/master Commit: 471013836419185d51a2d57bf5b89c4087053255 Parents: f7ef5ec Author: Parth Chandra Authored: Wed Feb 25 09:56:12 2015 -0800 Committer: Parth Chandra Committed: Wed Feb 25 17:24:54 2015 -0800 ---------------------------------------------------------------------- .../java/org/apache/drill/jdbc/DrillResultSet.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/47101383/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java ---------------------------------------------------------------------- diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java index 88a6c6d..77b2c37 100644 --- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java +++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java @@ -76,6 +76,20 @@ public class DrillResultSet extends AvaticaResultSet { listener.close(); } + @Override + public boolean next() throws SQLException { + // Next may be called after close has been called (for example after a user cancel) which in turn + // sets the cursor to null. So we must check before we call next. + // TODO: handle next() after close is called in the Avatica code. + if(super.cursor!=null){ + return super.next(); + }else{ + return false; + } + + } + + @Override protected DrillResultSet execute() throws SQLException{ // Call driver's callback. It is permitted to throw a RuntimeException. DrillConnectionImpl connection = (DrillConnectionImpl) statement.getConnection(); @@ -200,6 +214,9 @@ public class DrillResultSet extends AvaticaResultSet { qrb.getData().release(); } } + // close may be called before the first result is received and the main thread is blocked waiting + // for the result. In that case we want to unblock the main thread. + latch.countDown(); completed = true; }