You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2016/05/06 05:38:53 UTC
phoenix git commit: PHOENIX-2875 Fix isolation level returned by
PhoenixDatabaseMetaData for transactional tables
Repository: phoenix
Updated Branches:
refs/heads/master 491fc54d9 -> a8a3616fe
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/a8a3616f
Tree: http://git-wip-us.apache.org/repos/asf/phoenix/tree/a8a3616f
Diff: http://git-wip-us.apache.org/repos/asf/phoenix/diff/a8a3616f
Branch: refs/heads/master
Commit: a8a3616febaa51508e0c433c44e5b1a049a97925
Parents: 491fc54
Author: James Taylor <ja...@apache.org>
Authored: Thu May 5 22:40:54 2016 -0700
Committer: James Taylor <ja...@apache.org>
Committed: Thu May 5 22:40:54 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/a8a3616f/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/a8a3616f/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/a8a3616f/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