Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C9F0A2009F3 for ; Fri, 6 May 2016 07:41:00 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C897C160A05; Fri, 6 May 2016 05:41:00 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E788C160A04 for ; Fri, 6 May 2016 07:40:59 +0200 (CEST) Received: (qmail 86413 invoked by uid 500); 6 May 2016 05:40:59 -0000 Mailing-List: contact commits-help@phoenix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@phoenix.apache.org Delivered-To: mailing list commits@phoenix.apache.org Received: (qmail 86404 invoked by uid 99); 6 May 2016 05:40:59 -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; Fri, 06 May 2016 05:40:58 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id CE11BDFBDE; Fri, 6 May 2016 05:40:58 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jamestaylor@apache.org To: commits@phoenix.apache.org Message-Id: <39fc6cc3a96c4ec8ae30c13e2197703f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: phoenix git commit: PHOENIX-2875 Fix isolation level returned by PhoenixDatabaseMetaData for transactional tables Date: Fri, 6 May 2016 05:40:58 +0000 (UTC) archived-at: Fri, 06 May 2016 05:41:01 -0000 Repository: phoenix Updated Branches: refs/heads/4.x-HBase-1.1 588a9ae18 -> 13a6b5c97 PHOENIX-2875 Fix isolation level returned by PhoenixDatabaseMetaData for transactional tables Project: http://git-wip-us.apache.org/repos/asf/phoenix/repo Commit: http://git-wip-us.apache.org/repos/asf/phoenix/commit/13a6b5c9 Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/13a6b5c9 Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/13a6b5c9 Branch: refs/heads/4.x-HBase-1.1 Commit: 13a6b5c9703f5906dd04272cfa3e212caf3c764e Parents: 588a9ae Author: James Taylor Authored: Thu May 5 22:40:54 2016 -0700 Committer: James Taylor Committed: Thu May 5 22:42:58 2016 -0700 ---------------------------------------------------------------------- .../org/apache/phoenix/exception/SQLExceptionCode.java | 2 +- .../java/org/apache/phoenix/jdbc/PhoenixConnection.java | 11 +++++++---- .../java/org/apache/phoenix/jdbc/PhoenixDriverTest.java | 10 +++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/phoenix/blob/13a6b5c9/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java index 4d18cbb..5661098 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/exception/SQLExceptionCode.java @@ -282,7 +282,7 @@ public enum SQLExceptionCode { CANNOT_ALTER_TO_BE_TXN_WITH_ROW_TIMESTAMP(1081, "44A12", "Cannot alter table to be transactional table if transactions are disabled."), TX_MUST_BE_ENABLED_TO_SET_TX_CONTEXT(1082, "44A13", "Cannot set transaction context if transactions are disabled."), TX_MUST_BE_ENABLED_TO_SET_AUTO_FLUSH(1083, "44A14", "Cannot set auto flush if transactions are disabled."), - TX_MUST_BE_ENABLED_TO_SET_ISOLATION_LEVEL(1084, "44A15", "Cannot set isolation level to TRANSACTION_READ_COMMITTED or TRANSACTION_SERIALIZABLE if transactions are disabled."), + TX_MUST_BE_ENABLED_TO_SET_ISOLATION_LEVEL(1084, "44A15", "Cannot set isolation level to TRANSACTION_REPEATABLE_READ if transactions are disabled."), TX_UNABLE_TO_GET_WRITE_FENCE(1085, "44A16", "Unable to obtain write fence for DDL operation."), SEQUENCE_NOT_CASTABLE_TO_AUTO_PARTITION_ID_COLUMN(1086, "44A17", "Sequence Value not castable to auto-partition id column"), http://git-wip-us.apache.org/repos/asf/phoenix/blob/13a6b5c9/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java index 0e69bb5..160b99c 100644 --- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java +++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixConnection.java @@ -58,8 +58,6 @@ import java.util.concurrent.LinkedBlockingQueue; import javax.annotation.Nonnull; import javax.annotation.Nullable; -import co.cask.tephra.TransactionContext; - import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.client.Consistency; import org.apache.htrace.Sampler; @@ -115,6 +113,8 @@ import org.apache.phoenix.util.SQLCloseable; import org.apache.phoenix.util.SQLCloseables; import org.apache.phoenix.util.SchemaUtil; +import co.cask.tephra.TransactionContext; + import com.google.common.annotations.VisibleForTesting; import com.google.common.base.Objects; import com.google.common.base.Strings; @@ -669,7 +669,7 @@ public class PhoenixConnection implements Connection, MetaDataMutated, SQLClosea boolean transactionsEnabled = getQueryServices().getProps().getBoolean(QueryServices.TRANSACTIONS_ENABLED, QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED); return transactionsEnabled ? - Connection.TRANSACTION_SERIALIZABLE : Connection.TRANSACTION_READ_COMMITTED; + Connection.TRANSACTION_REPEATABLE_READ : Connection.TRANSACTION_READ_COMMITTED; } @Override @@ -835,7 +835,10 @@ public class PhoenixConnection implements Connection, MetaDataMutated, SQLClosea public void setTransactionIsolation(int level) throws SQLException { boolean transactionsEnabled = getQueryServices().getProps().getBoolean(QueryServices.TRANSACTIONS_ENABLED, QueryServicesOptions.DEFAULT_TRANSACTIONS_ENABLED); - if (!transactionsEnabled && (level == Connection.TRANSACTION_REPEATABLE_READ || level == Connection.TRANSACTION_SERIALIZABLE)) { + if (level == Connection.TRANSACTION_SERIALIZABLE) { + throw new SQLFeatureNotSupportedException(); + } + if (!transactionsEnabled && level == Connection.TRANSACTION_REPEATABLE_READ) { throw new SQLExceptionInfo.Builder(SQLExceptionCode.TX_MUST_BE_ENABLED_TO_SET_ISOLATION_LEVEL) .build().buildException(); } http://git-wip-us.apache.org/repos/asf/phoenix/blob/13a6b5c9/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java ---------------------------------------------------------------------- diff --git a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java index bc9ed3b..fde70d0 100644 --- a/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java +++ b/phoenix-core/src/test/java/org/apache/phoenix/jdbc/PhoenixDriverTest.java @@ -25,6 +25,7 @@ import java.sql.Driver; import java.sql.DriverManager; import java.sql.PreparedStatement; import java.sql.SQLException; +import java.sql.SQLFeatureNotSupportedException; import java.util.Properties; import org.apache.phoenix.exception.SQLExceptionCode; @@ -105,14 +106,17 @@ public class PhoenixDriverTest extends BaseConnectionlessQueryTest { conn = DriverManager.getConnection(getUrl()); conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); fail(); - } catch(SQLException e) { - assertEquals(SQLExceptionCode.TX_MUST_BE_ENABLED_TO_SET_ISOLATION_LEVEL.getErrorCode(), e.getErrorCode()); + } catch(SQLFeatureNotSupportedException e) { } Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES); props.setProperty(QueryServices.TRANSACTIONS_ENABLED, Boolean.toString(true)); conn = DriverManager.getConnection(getUrl(), props); conn.setTransactionIsolation(Connection.TRANSACTION_REPEATABLE_READ); - conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); + try { + conn.setTransactionIsolation(Connection.TRANSACTION_SERIALIZABLE); + fail(); + } catch(SQLFeatureNotSupportedException e) { + } } @Test