phoenix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jamestay...@apache.org
Subject phoenix git commit: PHOENIX-2875 Fix isolation level returned by PhoenixDatabaseMetaData for transactional tables
Date Fri, 06 May 2016 05:42:55 GMT
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.0 4900b0b3c -> 96b026a2d


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/96b026a2
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/96b026a2
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/96b026a2

Branch: refs/heads/4.x-HBase-1.0
Commit: 96b026a2dedca56118f7edc297fa3c5cbb235598
Parents: 4900b0b
Author: James Taylor <jamestaylor@apache.org>
Authored: Thu May 5 22:40:54 2016 -0700
Committer: James Taylor <jamestaylor@apache.org>
Committed: Thu May 5 22:43:31 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/96b026a2/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/96b026a2/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 bef3bae..4ab0866 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;
@@ -670,7 +670,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
@@ -836,7 +836,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/96b026a2/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


Mime
View raw message