You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by td...@apache.org on 2015/04/29 03:43:19 UTC

phoenix git commit: PHOENIX-1657 Encapsulate conn.getMetaDataCache().getTable() calls that look up tables without tenant id

Repository: phoenix
Updated Branches:
  refs/heads/txn 3822f8669 -> c89119576


PHOENIX-1657 Encapsulate conn.getMetaDataCache().getTable() calls that look up tables without tenant id


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

Branch: refs/heads/txn
Commit: c8911957613b30f7a65f524da3d8d119556d2121
Parents: 3822f86
Author: Thomas D'Silva <tw...@gmail.com>
Authored: Tue Apr 28 18:36:18 2015 -0700
Committer: Thomas D'Silva <tw...@gmail.com>
Committed: Tue Apr 28 18:39:06 2015 -0700

----------------------------------------------------------------------
 .../transactions/TxPointInTimeQueryIT.java      | 58 +++++++++++++++-----
 .../phoenix/exception/SQLExceptionCode.java     |  3 +-
 .../apache/phoenix/execute/MutationState.java   |  7 +++
 3 files changed, 52 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c8911957/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java b/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java
index 2a468b3..0f16696 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/transactions/TxPointInTimeQueryIT.java
@@ -18,16 +18,16 @@
 package org.apache.phoenix.transactions;
 
 import static org.apache.phoenix.util.TestUtil.TEST_PROPERTIES;
-import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 
 import java.sql.Connection;
 import java.sql.DriverManager;
-import java.sql.ResultSet;
+import java.sql.SQLException;
 import java.util.Properties;
 
 import org.apache.phoenix.end2end.BaseClientManagedTimeIT;
-import org.apache.phoenix.schema.ColumnNotFoundException;
+import org.apache.phoenix.exception.SQLExceptionCode;
 import org.apache.phoenix.util.PhoenixRuntime;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.junit.Before;
@@ -41,9 +41,9 @@ public class TxPointInTimeQueryIT extends BaseClientManagedTimeIT {
 	public void initTable() throws Exception {
 		ts = nextTimestamp();
 	}
-
+	
 	@Test
-	public void testDropColumn() throws Exception {
+	public void testQueryWithSCN() throws Exception {
 		Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
 		props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
 		Connection conn = DriverManager.getConnection(getUrl(), props);
@@ -54,25 +54,53 @@ public class TxPointInTimeQueryIT extends BaseClientManagedTimeIT {
 
 			props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
 			conn = DriverManager.getConnection(getUrl(), props);
-			// drop a column
-			conn.createStatement().execute("ALTER TABLE t DROP COLUMN v1");
 
-			props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 11));
-			conn = DriverManager.getConnection(getUrl(), props);
-			String selectQuery = "SELECT v1 FROM t";
+			String selectQuery = "SELECT k FROM t";
 			try {
 				conn.createStatement().executeQuery(selectQuery);
 				fail();
-			} catch (ColumnNotFoundException e) {
+			} catch (SQLException e) {
+				assertEquals("Unexpected Exception",
+						SQLExceptionCode.CANNOT_START_TRANSACTION_WITH_SCN_SET.getErrorCode(),
+						e.getErrorCode());
 			}
 
-			props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
-			conn = DriverManager.getConnection(getUrl(), props);
-			ResultSet rs = conn.createStatement().executeQuery(selectQuery);
-			assertFalse(rs.next());
 		} finally {
 			conn.close();
 		}
 	}
 
+//	@Test
+//	public void testDropColumn() throws Exception {
+//		Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+//		props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts));
+//		Connection conn = DriverManager.getConnection(getUrl(), props);
+//		try {
+//			conn.createStatement()
+//					.execute(
+//							"CREATE TABLE t (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR) TRANSACTIONAL=true");
+//
+//			props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 10));
+//			conn = DriverManager.getConnection(getUrl(), props);
+//			// drop a column
+//			conn.createStatement().execute("ALTER TABLE t DROP COLUMN v1");
+//
+//			props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 11));
+//			conn = DriverManager.getConnection(getUrl(), props);
+//			String selectQuery = "SELECT v1 FROM t";
+//			try {
+//				conn.createStatement().executeQuery(selectQuery);
+//				fail();
+//			} catch (ColumnNotFoundException e) {
+//			}
+//
+//			props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(ts + 5));
+//			conn = DriverManager.getConnection(getUrl(), props);
+//			ResultSet rs = conn.createStatement().executeQuery(selectQuery);
+//			assertFalse(rs.next());
+//		} finally {
+//			conn.close();
+//		}
+//	}
+
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c8911957/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 e3fbac8..d89e19a 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
@@ -250,7 +250,8 @@ public enum SQLExceptionCode {
     DEFAULT_COLUMN_FAMILY_ON_SHARED_TABLE(1056, "43A13", "Default column family not allowed on VIEW or shared INDEX"),
     ONLY_TABLE_MAY_BE_DECLARED_TRANSACTIONAL(1070, "44A01", "Only tables may be declared as transactional"),
     MAY_NOT_MAP_TO_EXISTING_TABLE_AS_TRANSACTIONAL(1071, "44A02", "An existing HBase table may not be mapped to as a transactional table"),
-    STORE_NULLS_MUST_BE_FALSE_FOR_TRANSACTIONAL(1072, "44A03", "Store nulls must be false when a table is transactional"),
+	STORE_NULLS_MUST_BE_FALSE_FOR_TRANSACTIONAL(1072, "44A03", "Store nulls must be true when a table is transactional"),
+    CANNOT_START_TRANSACTION_WITH_SCN_SET(1073, "44A04", "Cannot start a transaction on a connection with SCN set"),
 
     /** Sequence related */
     SEQUENCE_ALREADY_EXIST(1200, "42Z00", "Sequence already exists.", new Factory() {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c8911957/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
index 449e3cd..b7c7850 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/execute/MutationState.java
@@ -45,6 +45,7 @@ import org.apache.phoenix.cache.ServerCacheClient.ServerCache;
 import org.apache.phoenix.coprocessor.BaseScannerRegionObserver;
 import org.apache.phoenix.coprocessor.MetaDataProtocol.MetaDataMutationResult;
 import org.apache.phoenix.exception.SQLExceptionCode;
+import org.apache.phoenix.exception.SQLExceptionInfo;
 import org.apache.phoenix.hbase.index.util.ImmutableBytesPtr;
 import org.apache.phoenix.index.IndexMaintainer;
 import org.apache.phoenix.index.IndexMetaDataCacheClient;
@@ -160,6 +161,12 @@ public class MutationState implements SQLCloseable {
             throw new SQLException("No transaction context"); // TODO: error code
         }
         
+		if (connection.getSCN() != null) {
+			throw new SQLExceptionInfo.Builder(
+					SQLExceptionCode.CANNOT_START_TRANSACTION_WITH_SCN_SET)
+					.build().buildException();
+		}
+        
         try {
             if (!txStarted) {
                 txContext.start();