Incorporate code review feedback

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

Branch: refs/heads/txn
Commit: 97196e0d24529bebcdf4120543fd308bcd4cd83f
Parents: b198d6b
Author: Thomas D'Silva <[email protected]>
Authored: Tue Nov 17 13:49:45 2015 -0800
Committer: Thomas D'Silva <[email protected]>
Committed: Tue Nov 17 13:54:04 2015 -0800

----------------------------------------------------------------------
 .../end2end/index/txn/MutableRollbackIT.java    | 296 +++++++++----------
 .../phoenix/end2end/index/txn/RollbackIT.java   |  47 +--
 .../end2end/index/txn/TxWriteFailureIT.java     |   1 -
 .../org/apache/phoenix/tx/TransactionIT.java    | 102 ++++---
 .../apache/phoenix/compile/DeleteCompiler.java  |   7 +-
 .../phoenix/compile/StatementContext.java       |   3 +-
 .../apache/phoenix/compile/UpsertCompiler.java  |   7 +-
 .../phoenix/coprocessor/MetaDataProtocol.java   |   1 +
 .../phoenix/exception/SQLExceptionCode.java     |   1 +
 .../apache/phoenix/execute/MutationState.java   |  14 +-
 .../apache/phoenix/jdbc/PhoenixConnection.java  |   2 +-
 .../query/ConnectionQueryServicesImpl.java      |  50 ++--
 .../apache/phoenix/schema/MetaDataClient.java   |  31 +-
 .../org/apache/phoenix/schema/PTableImpl.java   |   2 +
 .../org/apache/phoenix/util/PhoenixRuntime.java |   2 +-
 .../covered/CoveredIndexCodecForTesting.java    |  22 +-
 .../java/org/apache/phoenix/query/BaseTest.java |   6 +-
 pom.xml                                         |   2 -
 18 files changed, 321 insertions(+), 275 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java
index 271997d..3f212cc 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/MutableRollbackIT.java
@@ -16,17 +16,14 @@ import java.util.Collection;
 import java.util.Map;
 import java.util.Properties;
 
-import org.apache.hadoop.hbase.client.HTableInterface;
-import org.apache.hadoop.hbase.client.Result;
-import org.apache.hadoop.hbase.client.ResultScanner;
-import org.apache.hadoop.hbase.client.Scan;
-import org.apache.hadoop.hbase.util.Bytes;
 import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
 import org.apache.phoenix.end2end.Shadower;
-import org.apache.phoenix.jdbc.PhoenixConnection;
+import org.apache.phoenix.query.BaseTest;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -36,9 +33,15 @@ import org.junit.runners.Parameterized.Parameters;
 import com.google.common.collect.Maps;
 
 @RunWith(Parameterized.class)
-public class MutableRollbackIT extends BaseHBaseManagedTimeIT {
+public class MutableRollbackIT extends BaseTest {
        
        private final boolean localIndex;
+       private String tableName1;
+    private String indexName1;
+    private String fullTableName1;
+    private String tableName2;
+    private String indexName2;
+    private String fullTableName2;
 
        public MutableRollbackIT(boolean localIndex) {
                this.localIndex = localIndex;
@@ -49,9 +52,6 @@ public class MutableRollbackIT extends BaseHBaseManagedTimeIT 
{
     public static void doSetup() throws Exception {
         Map<String,String> props = Maps.newHashMapWithExpectedSize(2);
         props.put(QueryServices.DEFAULT_TRANSACTIONAL_ATTRIB, 
Boolean.toString(true));
-        // We need this b/c we don't allow a transactional table to be created 
if the underlying
-        // HBase table already exists (since we don't know if it was 
transactional before).
-        props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true));
         setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
     }
        
@@ -62,50 +62,60 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
            });
     }
        
+       private void setTableNames() {
+               tableName1 = TestUtil.DEFAULT_DATA_TABLE_NAME + "_1_" + 
System.currentTimeMillis();
+        indexName1 = "IDX1"  + "_" + System.currentTimeMillis();
+        fullTableName1 = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, 
tableName1);
+        tableName2 = TestUtil.DEFAULT_DATA_TABLE_NAME + "_2_" + 
System.currentTimeMillis();
+        indexName2 = "IDX2"  + "_" + System.currentTimeMillis();
+        fullTableName2 = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, 
tableName2);
+       }
+       
        @Test
     public void testRollbackOfUncommittedExistingKeyValueIndexUpdate() throws 
Exception {
+               setTableNames();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
         try {
             Statement stmt = conn.createStatement();
-            stmt.execute("CREATE TABLE DEMO1(k VARCHAR PRIMARY KEY, v1 
VARCHAR, v2 VARCHAR)");
-            stmt.execute("CREATE TABLE DEMO2(k VARCHAR PRIMARY KEY, v1 
VARCHAR, v2 VARCHAR) IMMUTABLE_ROWS=true");
-            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX 
DEMO1_idx ON DEMO1 (v1) INCLUDE(v2)");
-            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX 
DEMO2_idx ON DEMO2 (v1) INCLUDE(v2)");
+            stmt.execute("CREATE TABLE " + fullTableName1 + "(k VARCHAR 
PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
+            stmt.execute("CREATE TABLE " + fullTableName2 + "(k VARCHAR 
PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) IMMUTABLE_ROWS=true");
+            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX " + 
indexName1 + " ON " + fullTableName1 + " (v1) INCLUDE(v2)");
+            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX " + 
indexName2 + " ON " + fullTableName2 + " (v1) INCLUDE(v2)");
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'y', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'y', 'a')");
             conn.commit();
             
-            //assert rows exists in DEMO1
-            ResultSet rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 
from DEMO1");
+            //assert rows exists in fullTableName1
+            ResultSet rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 
from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert rows exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1 ORDER BY v1");
+            //assert rows exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert no rows exists in DEMO2
-            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from 
DEMO2");
+            //assert no rows exists in fullTableName2
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName2);
             assertFalse(rs.next());
             
-            //assert no rows exists in DEMO2_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO2 ORDER BY v1");
+            //assert no rows exists in indexName2
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName2 + ")*/ k, 
v1 from " + fullTableName2);
             assertFalse(rs.next());
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'y', 'b')");
-            stmt.executeUpdate("upsert into DEMO2 values('a', 'b', 'c')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'y', 'b')");
+            stmt.executeUpdate("upsert into " + fullTableName2 + " values('a', 
'b', 'c')");
             
             //assert new covered column value 
-            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from 
DEMO1");
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
@@ -113,23 +123,23 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
             assertFalse(rs.next());
             
             //assert new covered column value 
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1 ORDER BY v1");
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertEquals("b", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert rows exists in DEMO2
-            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from 
DEMO2");
+            //assert rows exists in fullTableName2
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName2);
             assertTrue(rs.next());
             assertEquals("a", rs.getString(1));
             assertEquals("b", rs.getString(2));
             assertEquals("c", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert rows exists in DEMO2 index table
-            rs = stmt.executeQuery("select k, v1 from DEMO2 ORDER BY v1");
+            //assert rows exists in " + fullTableName2 + " index table
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName2 + ")*/ k, 
v1 from " + fullTableName2);
             assertTrue(rs.next());
             assertEquals("a", rs.getString(1));
             assertEquals("b", rs.getString(2));
@@ -137,50 +147,50 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
             
             conn.rollback();
             
-            //assert original row exists in DEMO1
-            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from 
DEMO1");
+            //assert original row exists in fullTableName1
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert original row exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1 ORDER BY v1");
+            //assert original row exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert no rows exists in DEMO2
-            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from 
DEMO2");
+            //assert no rows exists in fullTableName2
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName2);
             assertFalse(rs.next());
             
-            //assert no rows exists in DEMO2_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO2 ORDER BY v1");
+            //assert no rows exists in indexName2
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName2 + ")*/ k, 
v1 from " + fullTableName2);
             assertFalse(rs.next());
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'z', 'a')");
-            stmt.executeUpdate("upsert into DEMO2 values('a', 'b', 'c')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'z', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName2 + " values('a', 
'b', 'c')");
             conn.commit();
 
             assertDataAndIndexRows(stmt);
-            stmt.executeUpdate("delete from DEMO1 where  k='x'");
-            stmt.executeUpdate("delete from DEMO2 where  v1='b'");
+            stmt.executeUpdate("delete from " + fullTableName1 + " where  
k='x'");
+            stmt.executeUpdate("delete from " + fullTableName2 + " where  
v1='b'");
             
-            //assert no rows exists in DEMO1
-            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from 
DEMO1");
+            //assert no rows exists in fullTableName1
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName1);
             assertFalse(rs.next());
-            //assert no rows exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert no rows exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertFalse(rs.next());
 
-            //assert no rows exists in DEMO2
-            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from 
DEMO2");
+            //assert no rows exists in fullTableName2
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName2);
             assertFalse(rs.next());
-            //assert no rows exists in DEMO2_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO2 ORDER BY v1");
+            //assert no rows exists in indexName2
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName2 + ")*/ k, 
v1 from " + fullTableName2);
             assertFalse(rs.next());
             
             conn.rollback();
@@ -192,93 +202,94 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
 
        @Test
     public void testRollbackOfUncommittedExistingRowKeyIndexUpdate() throws 
Exception {
+               setTableNames();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
         try {
             Statement stmt = conn.createStatement();
-            stmt.execute("CREATE TABLE DEMO1(k VARCHAR PRIMARY KEY, v1 
VARCHAR, v2 VARCHAR)");
-            stmt.execute("CREATE TABLE DEMO2(k VARCHAR PRIMARY KEY, v1 
VARCHAR, v2 VARCHAR) IMMUTABLE_ROWS=true");
-            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX 
DEMO1_idx ON DEMO1 (v1, k)");
-            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX 
DEMO2_idx ON DEMO2 (v1, k)");
+            stmt.execute("CREATE TABLE " + fullTableName1 + "(k VARCHAR 
PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
+            stmt.execute("CREATE TABLE " + fullTableName2 + "(k VARCHAR 
PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) IMMUTABLE_ROWS=true");
+            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX " + 
indexName1 + " ON " + fullTableName1 + " (v1, k)");
+            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX " + 
indexName2 + " ON " + fullTableName2 + " (v1, k)");
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'y', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'y', 'a')");
             conn.commit();
             
-            //assert rows exists in DEMO1 
-            ResultSet rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert rows exists in " + fullTableName1 + " 
+            ResultSet rs = stmt.executeQuery("select k, v1, v2 from " + 
fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert rows exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert rows exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertFalse(rs.next());
             
-            //assert no rows exists in DEMO2
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO2");
+            //assert no rows exists in fullTableName2
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName2);
             assertFalse(rs.next());
             
-            //assert no rows exists in DEMO2_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO2 ORDER BY v1");
+            //assert no rows exists in indexName2
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName2 + ")*/ k, 
v1 from " + fullTableName2);
             assertFalse(rs.next());
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'z', 'a')");
-            stmt.executeUpdate("upsert into DEMO2 values('a', 'b', 'c')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'z', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName2 + " values('a', 
'b', 'c')");
             
             assertDataAndIndexRows(stmt);
             
             conn.rollback();
             
-            //assert original row exists in DEMO1
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert original row exists in fullTableName1
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert original row exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1 ORDER BY v1");
+            //assert original row exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert no rows exists in DEMO2
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO2");
+            //assert no rows exists in fullTableName2
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName2);
             assertFalse(rs.next());
             
-            //assert no rows exists in DEMO2_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO2 ORDER BY v1");
+            //assert no rows exists in indexName2
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName2);
             assertFalse(rs.next());
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'z', 'a')");
-            stmt.executeUpdate("upsert into DEMO2 values('a', 'b', 'c')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'z', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName2 + " values('a', 
'b', 'c')");
             conn.commit();
 
             assertDataAndIndexRows(stmt);
-            stmt.executeUpdate("delete from DEMO1 where  k='x'");
-            stmt.executeUpdate("delete from DEMO2 where  v1='b'");
+            stmt.executeUpdate("delete from " + fullTableName1 + " where  
k='x'");
+            stmt.executeUpdate("delete from " + fullTableName2 + " where  
v1='b'");
             
-            //assert no rows exists in DEMO1
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert no rows exists in fullTableName1
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName1);
             assertFalse(rs.next());
-            //assert no rows exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert no rows exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1);
             assertFalse(rs.next());
 
-            //assert no rows exists in DEMO2
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO2");
+            //assert no rows exists in fullTableName2
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName2);
             assertFalse(rs.next());
-            //assert no rows exists in DEMO2_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO2 ORDER BY v1");
+            //assert no rows exists in indexName2
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName2 + ")*/ k, 
v1 from " + fullTableName2);
             assertFalse(rs.next());
             
             conn.rollback();
@@ -288,48 +299,35 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
             conn.close();
         }
     }
-
-       protected static void printRawTable(Connection conn, String tableName) 
throws SQLException, IOException {
-           HTableInterface htable = 
conn.unwrap(PhoenixConnection.class).getQueryServices().getTable(Bytes.toBytes(tableName));
-           Scan scan = new Scan();
-           scan.setRaw(true);;
-           scan.setMaxVersions();
-           ResultScanner scanner = htable.getScanner(scan);
-           Result r = null;
-           System.out.println("**************** " + tableName);
-           while ((r = scanner.next()) != null) {
-               System.out.println("    **********" + r);
-           }
-       }
        
-    private static void assertDataAndIndexRows(Statement stmt) throws 
SQLException, IOException {
+    private void assertDataAndIndexRows(Statement stmt) throws SQLException, 
IOException {
         ResultSet rs;
-        //assert new covered row key value exists in DEMO1
-        rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from DEMO1");
+        //assert new covered row key value exists in fullTableName1
+        rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName1);
         assertTrue(rs.next());
         assertEquals("x", rs.getString(1));
         assertEquals("z", rs.getString(2));
         assertEquals("a", rs.getString(3));
         assertFalse(rs.next());
         
-        //assert new covered row key value exists in DEMO1_idx
-        rs = stmt.executeQuery("select k, v1, v2 from DEMO1 ORDER BY v1");
+        //assert new covered row key value exists in indexName1
+        rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, v1, 
v2 from " + fullTableName1);
         assertTrue(rs.next());
         assertEquals("x", rs.getString(1));
         assertEquals("z", rs.getString(2));
         assertEquals("a", rs.getString(3));
         assertFalse(rs.next());
         
-        //assert rows exists in DEMO2
-        rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from DEMO2");
+        //assert rows exists in fullTableName2
+        rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName2);
         assertTrue(rs.next());
         assertEquals("a", rs.getString(1));
         assertEquals("b", rs.getString(2));
         assertEquals("c", rs.getString(3));
         assertFalse(rs.next());
         
-        //assert rows exists in DEMO2 index table
-        rs = stmt.executeQuery("select k, v1 from DEMO2 ORDER BY v1");
+        //assert rows exists in " + fullTableName2 + " index table
+        rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, v1 
from " + fullTableName2);
         assertTrue(rs.next());
         assertEquals("a", rs.getString(1));
         assertEquals("b", rs.getString(2));
@@ -338,44 +336,45 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
     
     @Test
     public void testMultiRollbackOfUncommittedExistingRowKeyIndexUpdate() 
throws Exception {
+       setTableNames();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
         try {
             Statement stmt = conn.createStatement();
-            stmt.execute("CREATE TABLE DEMO1(k VARCHAR PRIMARY KEY, v1 
VARCHAR, v2 VARCHAR)");
-            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX 
DEMO1_idx ON DEMO1 (v1, k)");
+            stmt.execute("CREATE TABLE " + fullTableName1 + "(k VARCHAR 
PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
+            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX " + 
indexName1 + " ON " + fullTableName1 + " (v1, k)");
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'yyyy', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'yyyy', 'a')");
             conn.commit();
             
-            //assert rows exists in DEMO1 
-            ResultSet rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert rows exists in " + fullTableName1 + " 
+            ResultSet rs = stmt.executeQuery("select k, v1, v2 from " + 
fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("yyyy", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert rows exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert rows exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("yyyy", rs.getString(2));
             assertFalse(rs.next());
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'zzz', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'zzz', 'a')");
             
-            //assert new covered row key value exists in DEMO1
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert new covered row key value exists in fullTableName1
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("zzz", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert new covered row key value exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert new covered row key value exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("zzz", rs.getString(2));
@@ -383,33 +382,33 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
             
             conn.rollback();
             
-            //assert original row exists in DEMO1
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert original row exists in fullTableName1
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("yyyy", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert original row exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert original row exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("yyyy", rs.getString(2));
             assertFalse(rs.next());
             
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'zz', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'zz', 'a')");
             
-            //assert new covered row key value exists in DEMO1
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert new covered row key value exists in fullTableName1
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("zz", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert new covered row key value exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert new covered row key value exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("zz", rs.getString(2));
@@ -417,16 +416,16 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
             
             conn.rollback();
             
-            //assert original row exists in DEMO1
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert original row exists in fullTableName1
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("yyyy", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert original row exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert original row exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("yyyy", rs.getString(2));
@@ -439,44 +438,41 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
     
     @Test
     public void testCheckpointAndRollback() throws Exception {
+       setTableNames();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
         try {
             Statement stmt = conn.createStatement();
-            stmt.execute("CREATE TABLE DEMO1(k VARCHAR PRIMARY KEY, v1 
VARCHAR, v2 VARCHAR)");
-            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX 
DEMO1_idx ON DEMO1 (v1)");
-            
-            stmt.executeUpdate("upsert into DEMO1 values('x', 'a', 'a')");
+            stmt.execute("CREATE TABLE " + fullTableName1 + "(k VARCHAR 
PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
+            stmt.execute("CREATE "+(localIndex? " LOCAL " : "")+"INDEX " + 
indexName1 + " ON " + fullTableName1 + " (v1)");
+            stmt.executeUpdate("upsert into " + fullTableName1 + " values('x', 
'a', 'a')");
             conn.commit();
             
-            ResultSet rs;
-            
-            stmt.executeUpdate("upsert into DEMO1(k,v1) SELECT k,v1||'a' FROM 
DEMO1");
-            
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            stmt.executeUpdate("upsert into " + fullTableName1 + "(k,v1) 
SELECT k,v1||'a' FROM " + fullTableName1);
+            ResultSet rs = stmt.executeQuery("select k, v1, v2 from " + 
fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("aa", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("aa", rs.getString(2));
             assertFalse(rs.next());
             
-            stmt.executeUpdate("upsert into DEMO1(k,v1) SELECT k,v1||'a' FROM 
DEMO1");
+            stmt.executeUpdate("upsert into " + fullTableName1 + "(k,v1) 
SELECT k,v1||'a' FROM " + fullTableName1);
             
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("aaa", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("aaa", rs.getString(2));
@@ -484,16 +480,16 @@ public class MutableRollbackIT extends 
BaseHBaseManagedTimeIT {
             
             conn.rollback();
             
-            //assert original row exists in DEMO1
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO1");
+            //assert original row exists in fullTableName1
+            rs = stmt.executeQuery("select k, v1, v2 from " + fullTableName1);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("a", rs.getString(2));
             assertEquals("a", rs.getString(3));
             assertFalse(rs.next());
             
-            //assert original row exists in DEMO1_idx
-            rs = stmt.executeQuery("select k, v1 from DEMO1 ORDER BY v1");
+            //assert original row exists in indexName1
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName1 + ")*/ k, 
v1 from " + fullTableName1 + " ORDER BY v1");
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("a", rs.getString(2));

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java
index 91efd45..0fac1eb 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/RollbackIT.java
@@ -16,9 +16,12 @@ import java.util.Properties;
 
 import org.apache.phoenix.end2end.BaseHBaseManagedTimeIT;
 import org.apache.phoenix.end2end.Shadower;
+import org.apache.phoenix.query.BaseTest;
 import org.apache.phoenix.query.QueryServices;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.ReadOnlyProps;
+import org.apache.phoenix.util.SchemaUtil;
+import org.apache.phoenix.util.TestUtil;
 import org.junit.BeforeClass;
 import org.junit.Test;
 import org.junit.runner.RunWith;
@@ -28,10 +31,13 @@ import org.junit.runners.Parameterized.Parameters;
 import com.google.common.collect.Maps;
 
 @RunWith(Parameterized.class)
-public class RollbackIT extends BaseHBaseManagedTimeIT {
+public class RollbackIT extends BaseTest {
        
        private final boolean localIndex;
        private final boolean mutable;
+       private String tableName;
+    private String indexName;
+    private String fullTableName;
 
        public RollbackIT(boolean localIndex, boolean mutable) {
                this.localIndex = localIndex;
@@ -43,9 +49,6 @@ public class RollbackIT extends BaseHBaseManagedTimeIT {
     public static void doSetup() throws Exception {
         Map<String,String> props = Maps.newHashMapWithExpectedSize(2);
         props.put(QueryServices.DEFAULT_TRANSACTIONAL_ATTRIB, 
Boolean.toString(true));
-        // We need this b/c we don't allow a transactional table to be created 
if the underlying
-        // HBase table already exists (since we don't know if it was 
transactional before).
-        props.put(QueryServices.DROP_METADATA_ATTRIB, Boolean.toString(true));
         setUpTestDriver(new ReadOnlyProps(props.entrySet().iterator()));
     }
        
@@ -57,20 +60,27 @@ public class RollbackIT extends BaseHBaseManagedTimeIT {
            });
     }
     
+    private void setTableNames() {
+               tableName = TestUtil.DEFAULT_DATA_TABLE_NAME + "_1_" + 
System.currentTimeMillis();
+        indexName = "IDX1"  + "_" + System.currentTimeMillis();
+        fullTableName = SchemaUtil.getTableName(TestUtil.DEFAULT_SCHEMA_NAME, 
tableName);
+       }
+    
     @Test
     public void testRollbackOfUncommittedKeyValueIndexInsert() throws 
Exception {
+       setTableNames();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
         try {
             Statement stmt = conn.createStatement();
-            stmt.execute("CREATE TABLE DEMO(k VARCHAR PRIMARY KEY, v1 VARCHAR, 
v2 VARCHAR)"+(!mutable? " IMMUTABLE_ROWS=true" : ""));
-            stmt.execute("CREATE "+(localIndex? "LOCAL " : "")+"INDEX DEMO_idx 
ON DEMO (v1) INCLUDE(v2)");
+            stmt.execute("CREATE TABLE " + fullTableName + "(k VARCHAR PRIMARY 
KEY, v1 VARCHAR, v2 VARCHAR)"+(!mutable? " IMMUTABLE_ROWS=true" : ""));
+            stmt.execute("CREATE "+(localIndex? "LOCAL " : "")+"INDEX " + 
indexName + " ON " + fullTableName + " (v1) INCLUDE(v2)");
             
-            stmt.executeUpdate("upsert into DEMO values('x', 'y', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName + " values('x', 
'y', 'a')");
             
             //assert values in data table
-            ResultSet rs = stmt.executeQuery("select k, v1, v2 from DEMO ORDER 
BY k");
+            ResultSet rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 
from " + fullTableName);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
@@ -78,7 +88,7 @@ public class RollbackIT extends BaseHBaseManagedTimeIT {
             assertFalse(rs.next());
             
             //assert values in index table
-            rs = stmt.executeQuery("select k, v1, v2  from DEMO ORDER BY v1");
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName + ")*/ k, 
v1, v2  from " + fullTableName);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
@@ -88,11 +98,11 @@ public class RollbackIT extends BaseHBaseManagedTimeIT {
             conn.rollback();
             
             //assert values in data table
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO ORDER BY k");
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName);
             assertFalse(rs.next());
             
             //assert values in index table
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO ORDER BY v1");
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName + ")*/ k, 
v1, v2 from " + fullTableName);
             assertFalse(rs.next());
         } finally {
             conn.close();
@@ -101,17 +111,18 @@ public class RollbackIT extends BaseHBaseManagedTimeIT {
     
     @Test
     public void testRollbackOfUncommittedRowKeyIndexInsert() throws Exception {
+       setTableNames();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         Connection conn = DriverManager.getConnection(getUrl(), props);
         conn.setAutoCommit(false);
         try {
             Statement stmt = conn.createStatement();
-            stmt.execute("CREATE TABLE DEMO(k VARCHAR, v1 VARCHAR, v2 VARCHAR, 
CONSTRAINT pk PRIMARY KEY (v1, v2))"+(!mutable? " IMMUTABLE_ROWS=true" : ""));
-            stmt.execute("CREATE "+(localIndex? "LOCAL " : "")+"INDEX DEMO_idx 
ON DEMO (v1, k)");
+            stmt.execute("CREATE TABLE " + fullTableName + "(k VARCHAR, v1 
VARCHAR, v2 VARCHAR, CONSTRAINT pk PRIMARY KEY (v1, v2))"+(!mutable? " 
IMMUTABLE_ROWS=true" : ""));
+            stmt.execute("CREATE "+(localIndex? "LOCAL " : "")+"INDEX " + 
indexName + " ON " + fullTableName + "(v1, k)");
             
-            stmt.executeUpdate("upsert into DEMO values('x', 'y', 'a')");
+            stmt.executeUpdate("upsert into " + fullTableName + " values('x', 
'y', 'a')");
 
-            ResultSet rs = stmt.executeQuery("select k, v1, v2 from DEMO ORDER 
BY v1");
+            ResultSet rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 
from " + fullTableName);
             
             //assert values in data table
             assertTrue(rs.next());
@@ -121,7 +132,7 @@ public class RollbackIT extends BaseHBaseManagedTimeIT {
             assertFalse(rs.next());
             
             //assert values in index table
-            rs = stmt.executeQuery("select k, v1 from DEMO ORDER BY v2");
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName + ")*/ k, 
v1 from " + fullTableName);
             assertTrue(rs.next());
             assertEquals("x", rs.getString(1));
             assertEquals("y", rs.getString(2));
@@ -130,11 +141,11 @@ public class RollbackIT extends BaseHBaseManagedTimeIT {
             conn.rollback();
             
             //assert values in data table
-            rs = stmt.executeQuery("select k, v1, v2 from DEMO");
+            rs = stmt.executeQuery("select /*+ NO_INDEX */ k, v1, v2 from " + 
fullTableName);
             assertFalse(rs.next());
             
             //assert values in index table
-            rs = stmt.executeQuery("select k, v1 from DEMO ORDER BY v2");
+            rs = stmt.executeQuery("select /*+ INDEX(" + indexName + ")*/ k, 
v1 from " + fullTableName);
             assertFalse(rs.next());
         } finally {
             conn.close();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/TxWriteFailureIT.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/TxWriteFailureIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/TxWriteFailureIT.java
index 205056b..122b81b 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/TxWriteFailureIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/txn/TxWriteFailureIT.java
@@ -85,7 +85,6 @@ public class TxWriteFailureIT extends BaseTest {
 
                Map<String, String> props = Maps.newHashMapWithExpectedSize(1);
                // Must update config before starting server
-               props.put(QueryServices.DROP_METADATA_ATTRIB, 
Boolean.toString(true));
                props.put(QueryServices.DEFAULT_TRANSACTIONAL_ATTRIB, 
Boolean.toString(true));
                driver = initAndRegisterDriver(url, new 
ReadOnlyProps(props.entrySet().iterator()));
                clusterInitialized = true;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
index a01935d..1482701 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
@@ -18,6 +18,7 @@ import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
 import java.sql.Connection;
+import java.sql.Date;
 import java.sql.DriverManager;
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -64,8 +65,7 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
        @Test
        public void testReadOwnWrites() throws Exception {
                String selectSql = "SELECT * FROM "+FULL_TABLE_NAME;
-               Connection conn = DriverManager.getConnection(getUrl());
-               try {
+               try (Connection conn = DriverManager.getConnection(getUrl())) {
                        conn.setAutoCommit(false);
                        ResultSet rs = 
conn.createStatement().executeQuery(selectSql);
                assertFalse(rs.next());
@@ -92,17 +92,42 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
                TestUtil.validateRowKeyColumns(rs, 2);
                assertFalse(rs.next());
                }
-        finally {
-               conn.close();
-        }
+       }
+       
+       @Test
+       public void testTxnClosedCorrecty() throws Exception {
+               String selectSql = "SELECT * FROM "+FULL_TABLE_NAME;
+               try (Connection conn = DriverManager.getConnection(getUrl())) {
+                       conn.setAutoCommit(false);
+                       ResultSet rs = 
conn.createStatement().executeQuery(selectSql);
+               assertFalse(rs.next());
+               
+               String upsert = "UPSERT INTO " + FULL_TABLE_NAME + 
"(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, 
?, ?)";
+               PreparedStatement stmt = conn.prepareStatement(upsert);
+                       // upsert two rows
+                       TestUtil.setRowKeyColumns(stmt, 1);
+                       stmt.execute();
+                       TestUtil.setRowKeyColumns(stmt, 2);
+                       stmt.execute();
+               
+               // verify rows can be read even though commit has not been 
called
+                       rs = conn.createStatement().executeQuery(selectSql);
+                       TestUtil.validateRowKeyColumns(rs, 1);
+                       TestUtil.validateRowKeyColumns(rs, 2);
+               assertFalse(rs.next());
+               
+               conn.close();
+               // wait for any open txns to time out
+               Thread.sleep(DEFAULT_TXN_TIMEOUT_SECONDS*1000+10000);
+               assertTrue("There should be no invalid transactions", 
txManager.getInvalidSize()==0);
+               }
        }
        
     @Test
     public void testDelete() throws Exception {
         String selectSQL = "SELECT * FROM " + FULL_TABLE_NAME;
-        Connection conn1 = DriverManager.getConnection(getUrl());
-        Connection conn2 = DriverManager.getConnection(getUrl());
-        try {
+        try (Connection conn1 = DriverManager.getConnection(getUrl()); 
+                       Connection conn2 = 
DriverManager.getConnection(getUrl())) {
             conn1.setAutoCommit(false);
             ResultSet rs = conn1.createStatement().executeQuery(selectSQL);
             assertFalse(rs.next());
@@ -132,42 +157,32 @@ public class TransactionIT extends BaseHBaseManagedTimeIT 
{
             rs = conn1.createStatement().executeQuery(selectSQL);
             assertFalse(rs.next());
         }
-        finally {
-            conn1.close();
-        }
     }
     
        @Test
        public void testAutoCommitQuerySingleTable() throws Exception {
-               Connection conn = DriverManager.getConnection(getUrl());
-               try {
+               try (Connection conn = DriverManager.getConnection(getUrl())) {
                        conn.setAutoCommit(true);
                        // verify no rows returned
                        ResultSet rs = 
conn.createStatement().executeQuery("SELECT * FROM " + FULL_TABLE_NAME);
                        assertFalse(rs.next());
-               } finally {
-                       conn.close();
                }
        }
        
     @Test
     public void testAutoCommitQueryMultiTables() throws Exception {
-        Connection conn = DriverManager.getConnection(getUrl());
-        try {
+       try (Connection conn = DriverManager.getConnection(getUrl())) {
             conn.setAutoCommit(true);
             // verify no rows returned
             ResultSet rs = conn.createStatement().executeQuery("SELECT * FROM 
" + FULL_TABLE_NAME + " a JOIN " + FULL_TABLE_NAME + " b ON (a.long_pk = 
b.int_pk)");
             assertFalse(rs.next());
-        } finally {
-            conn.close();
-        }
+        } 
     }
     
        @Test
        public void testColConflicts() throws Exception {
-               Connection conn1 = DriverManager.getConnection(getUrl());
-               Connection conn2 = DriverManager.getConnection(getUrl());
-               try {
+               try (Connection conn1 = DriverManager.getConnection(getUrl()); 
+                       Connection conn2 = 
DriverManager.getConnection(getUrl())) {
                        conn1.setAutoCommit(false);
                        conn2.setAutoCommit(false);
                        String selectSql = "SELECT * FROM "+FULL_TABLE_NAME;
@@ -196,15 +211,11 @@ public class TransactionIT extends BaseHBaseManagedTimeIT 
{
                        assertEquals(e.getErrorCode(), 
SQLExceptionCode.TRANSACTION_CONFLICT_EXCEPTION.getErrorCode());
                }
                }
-        finally {
-               conn1.close();
-        }
        }
        
        private void testRowConflicts() throws Exception {
-               Connection conn1 = DriverManager.getConnection(getUrl());
-               Connection conn2 = DriverManager.getConnection(getUrl());
-               try {
+               try (Connection conn1 = DriverManager.getConnection(getUrl()); 
+                       Connection conn2 = 
DriverManager.getConnection(getUrl())) {
                        conn1.setAutoCommit(false);
                        conn2.setAutoCommit(false);
                        String selectSql = "SELECT * FROM "+FULL_TABLE_NAME;
@@ -236,10 +247,6 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
                        assertEquals(e.getErrorCode(), 
SQLExceptionCode.TRANSACTION_CONFLICT_EXCEPTION.getErrorCode());
                }
                }
-        finally {
-               conn1.close();
-               conn2.close();
-        }
        }
        
        @Test
@@ -475,4 +482,33 @@ public class TransactionIT extends BaseHBaseManagedTimeIT {
         assertTrue(table.isTransactional());
         
assertTrue(htable.getTableDescriptor().getCoprocessors().contains(TransactionProcessor.class.getName()));
     }
+
+    public void testCurrentDate() throws Exception {
+               String selectSql = "SELECT current_date() FROM 
"+FULL_TABLE_NAME;
+               try (Connection conn = DriverManager.getConnection(getUrl())) {
+                       conn.setAutoCommit(false);
+                       ResultSet rs = 
conn.createStatement().executeQuery(selectSql);
+               assertFalse(rs.next());
+               
+               String upsert = "UPSERT INTO " + FULL_TABLE_NAME + 
"(varchar_pk, char_pk, int_pk, long_pk, decimal_pk, date_pk) VALUES(?, ?, ?, ?, 
?, ?)";
+               PreparedStatement stmt = conn.prepareStatement(upsert);
+                       // upsert two rows
+                       TestUtil.setRowKeyColumns(stmt, 1);
+                       stmt.execute();
+                       conn.commit();
+                       
+                       rs = conn.createStatement().executeQuery(selectSql);
+                       assertTrue(rs.next());
+                       Date date1 = rs.getDate(1);
+               assertFalse(rs.next());
+               
+               Thread.sleep(1000);
+               
+               rs = conn.createStatement().executeQuery(selectSql);
+                       assertTrue(rs.next());
+                       Date date2 = rs.getDate(1);
+               assertFalse(rs.next());
+               assertTrue("current_date() should change while executing 
multiple statements", date2.getTime() > date1.getTime());
+               }
+       }
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
index bbc16b2..a02ba99 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/DeleteCompiler.java
@@ -324,10 +324,13 @@ public class DeleteCompiler {
                 // - read-only VIEW 
                 // - transactional table with a connection having an SCN
                 // TODO: SchemaUtil.isReadOnly(PTable, connection)?
-                if ( ( table.getType() == PTableType.VIEW && 
table.getViewType().isReadOnly() ) 
-                     || ( table.isTransactional() && connection.getSCN() != 
null ) ) {
+                if (table.getType() == PTableType.VIEW && 
table.getViewType().isReadOnly()) {
                     throw new ReadOnlyTableException(schemaName,tableName);
                 }
+                else if (table.isTransactional() && connection.getSCN() != 
null) {
+                   throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_SPECIFY_SCN_FOR_TXN_TABLE).setSchemaName(schemaName)
+                   .setTableName(tableName).build().buildException();
+                }
                 
                 immutableIndex = getNonDisabledImmutableIndexes(tableRefToBe);
                 boolean mayHaveImmutableIndexes = !immutableIndex.isEmpty();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
index 312de45..80c4b89 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
@@ -252,7 +252,8 @@ public class StatementContext {
 
     public long getCurrentTime() throws SQLException {
         long ts = this.getCurrentTable().getTimeStamp();
-        if (ts != QueryConstants.UNSET_TIMESTAMP) {
+        // if the table is transactional then it is only resolved once per 
query, so we can't use the table timestamp
+        if (!this.getCurrentTable().getTable().isTransactional() && ts != 
QueryConstants.UNSET_TIMESTAMP) {
             return ts;
         }
         if (currentTime != QueryConstants.UNSET_TIMESTAMP) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java 
b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
index c2e8bd5..96a15a3 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/UpsertCompiler.java
@@ -292,10 +292,13 @@ public class UpsertCompiler {
                 // Cannot update:
                 // - read-only VIEW 
                 // - transactional table with a connection having an SCN 
-                if ( ( table.getType() == PTableType.VIEW && 
table.getViewType().isReadOnly() ) 
-                     || ( table.isTransactional() && connection.getSCN() != 
null )) {
+                if (table.getType() == PTableType.VIEW && 
table.getViewType().isReadOnly()) {
                     throw new ReadOnlyTableException(schemaName,tableName);
                 }
+                else if (table.isTransactional() && connection.getSCN() != 
null) {
+                    throw new 
SQLExceptionInfo.Builder(SQLExceptionCode.CANNOT_SPECIFY_SCN_FOR_TXN_TABLE).setSchemaName(schemaName)
+                    .setTableName(tableName).build().buildException();
+                }
                 boolean isSalted = table.getBucketNum() != null;
                 isTenantSpecific = table.isMultiTenant() && 
connection.getTenantId() != null;
                 isSharedViewIndex = table.getViewIndexId() != null;

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
index 7cc4123..22a10a4 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataProtocol.java
@@ -73,6 +73,7 @@ public abstract class MetaDataProtocol extends 
MetaDataService {
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_3_0 = 
MIN_TABLE_TIMESTAMP + 7;
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_5_0 = 
MIN_TABLE_TIMESTAMP + 8;
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0 = 
MIN_TABLE_TIMESTAMP + 9;
+    public static final long MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0 = 
MIN_TABLE_TIMESTAMP + 10;
     public static final long MIN_SYSTEM_TABLE_TIMESTAMP = 
MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0;
     // TODO: pare this down to minimum, as we don't need duplicates for both 
table and column errors, nor should we need
     // a different code for every type of error.

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/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 e25918a..7f40ed2 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
@@ -272,6 +272,7 @@ public enum SQLExceptionCode {
        STORE_NULLS_MUST_BE_TRUE_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"),
     TX_MAX_VERSIONS_MUST_BE_GREATER_THAN_ONE(1074, "44A05", "A transactional 
table must define VERSION of greater than one"),
+    CANNOT_SPECIFY_SCN_FOR_TXN_TABLE(1075, "44A06", "Cannot use a connection 
with SCN set for a transactional table"),
 
     /** Sequence related */
     SEQUENCE_ALREADY_EXIST(1200, "42Z00", "Sequence already exists.", new 
Factory() {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/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 8836249..029f73f 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
@@ -177,7 +177,7 @@ public class MutationState implements SQLCloseable {
     
     public boolean checkpoint(MutationPlan plan) throws SQLException {
         Transaction currentTx = getTransaction();
-        if (currentTx == null || plan.getTargetRef() == null || 
plan.getTargetRef().getTable() == null || 
!plan.getTargetRef().getTable().isTransactional()) {
+        if (getTransaction() == null || plan.getTargetRef() == null || 
plan.getTargetRef().getTable() == null || 
!plan.getTargetRef().getTable().isTransactional()) {
             return false;
         }
         Set<TableRef> sources = plan.getSourceRefs();
@@ -215,10 +215,10 @@ public class MutationState implements SQLCloseable {
             if (hasUncommittedData) {
                 try {
                        if (txContext == null) {
-                               tx = currentTx = 
connection.getQueryServices().getTransactionSystemClient().checkpoint(currentTx);
+                               currentTx = tx = 
connection.getQueryServices().getTransactionSystemClient().checkpoint(currentTx);
                        }  else {
                                txContext.checkpoint();
-                               tx = currentTx = 
txContext.getCurrentTransaction();
+                               currentTx = tx = 
txContext.getCurrentTransaction();
                        }
                     // Since we've checkpointed, we can clear out uncommitted 
set, since a statement run afterwards
                     // should see all this data.
@@ -529,6 +529,14 @@ public class MutationState implements SQLCloseable {
         return toMutations(false, timestamp);
     }
     
+    public Iterator<Pair<byte[],List<Mutation>>> toMutations() {
+        return toMutations(false, null);
+    }
+    
+    public Iterator<Pair<byte[],List<Mutation>>> toMutations(final boolean 
includeMutableIndexes) {
+        return toMutations(includeMutableIndexes, null);
+    }
+    
     public Iterator<Pair<byte[],List<Mutation>>> toMutations(final boolean 
includeMutableIndexes, final Long tableTimestamp) {
         final Iterator<Map.Entry<TableRef, 
Map<ImmutableBytesPtr,RowMutationState>>> iterator = 
this.mutations.entrySet().iterator();
         if (!iterator.hasNext()) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/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 f781400..63156d6 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
@@ -463,7 +463,7 @@ public class PhoenixConnection implements Connection, 
org.apache.phoenix.jdbc.Jd
         // from modifying this list.
         this.statements = Lists.newArrayList();
         try {
-            mutationState.clear();
+            mutationState.rollback();
         } finally {
             try {
                 SQLCloseables.closeAll(statements);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index fdea6f8..77cf3bf 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -2278,32 +2278,29 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
                                 long currentServerSideTableTimeStamp = 
e.getTable().getTimeStamp();
 
                                 String columnsToAdd = "";
-                                if(currentServerSideTableTimeStamp < 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0) {
-                                    columnsToAdd = 
PhoenixDatabaseMetaData.TRANSACTIONAL + " " + 
PBoolean.INSTANCE.getSqlTypeName();
-                                    if(currentServerSideTableTimeStamp < 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_3_0) {
-                                        // We know that we always need to add 
the STORE_NULLS column for 4.3 release
-                                        columnsToAdd += "," + 
PhoenixDatabaseMetaData.STORE_NULLS + " " + PBoolean.INSTANCE.getSqlTypeName();
-                                        HBaseAdmin admin = null;
-                                        try {
-                                            admin = getAdmin();
-                                            HTableDescriptor[] 
localIndexTables = admin.listTables(MetaDataUtil.LOCAL_INDEX_TABLE_PREFIX+".*");
-                                            for (HTableDescriptor table : 
localIndexTables) {
-                                                if 
(table.getValue(MetaDataUtil.PARENT_TABLE_KEY) == null
-                                                        && 
table.getValue(MetaDataUtil.IS_LOCAL_INDEX_TABLE_PROP_NAME) != null) {
-                                                    
table.setValue(MetaDataUtil.PARENT_TABLE_KEY,
-                                                        
MetaDataUtil.getUserTableName(table
-                                                            
.getNameAsString()));
-                                                    // Explicitly disable, 
modify and enable the table to ensure co-location of data
-                                                    // and index regions. If 
we just modify the table descriptor when online schema
-                                                    // change enabled may 
reopen the region in same region server instead of following data region.
-                                                    
admin.disableTable(table.getTableName());
-                                                    
admin.modifyTable(table.getTableName(), table);
-                                                    
admin.enableTable(table.getTableName());
-                                                }
+                                if(currentServerSideTableTimeStamp < 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_3_0) {
+                                    // We know that we always need to add the 
STORE_NULLS column for 4.3 release
+                                    columnsToAdd += "," + 
PhoenixDatabaseMetaData.STORE_NULLS + " " + PBoolean.INSTANCE.getSqlTypeName();
+                                    HBaseAdmin admin = null;
+                                    try {
+                                        admin = getAdmin();
+                                        HTableDescriptor[] localIndexTables = 
admin.listTables(MetaDataUtil.LOCAL_INDEX_TABLE_PREFIX+".*");
+                                        for (HTableDescriptor table : 
localIndexTables) {
+                                            if 
(table.getValue(MetaDataUtil.PARENT_TABLE_KEY) == null
+                                                    && 
table.getValue(MetaDataUtil.IS_LOCAL_INDEX_TABLE_PROP_NAME) != null) {
+                                                
table.setValue(MetaDataUtil.PARENT_TABLE_KEY,
+                                                    
MetaDataUtil.getUserTableName(table
+                                                        .getNameAsString()));
+                                                // Explicitly disable, modify 
and enable the table to ensure co-location of data
+                                                // and index regions. If we 
just modify the table descriptor when online schema
+                                                // change enabled may reopen 
the region in same region server instead of following data region.
+                                                
admin.disableTable(table.getTableName());
+                                                
admin.modifyTable(table.getTableName(), table);
+                                                
admin.enableTable(table.getTableName());
                                             }
-                                        } finally {
-                                            if (admin != null) admin.close();
                                         }
+                                    } finally {
+                                        if (admin != null) admin.close();
                                     }
                                 }
 
@@ -2365,6 +2362,11 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
                                     metaConnection = addColumn(metaConnection, 
PhoenixDatabaseMetaData.SYSTEM_CATALOG,
                                             
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_6_0, columnsToAdd, false);
                                 }
+                                if(currentServerSideTableTimeStamp < 
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0) {
+                                    columnsToAdd = 
PhoenixDatabaseMetaData.TRANSACTIONAL + " " + 
PBoolean.INSTANCE.getSqlTypeName();
+                                    metaConnection = addColumn(metaConnection, 
PhoenixDatabaseMetaData.SYSTEM_CATALOG,
+                                            
MetaDataProtocol.MIN_SYSTEM_TABLE_TIMESTAMP_4_7_0, columnsToAdd, false);
+                                }
                                 
                             }
                             int nSaltBuckets = 
ConnectionQueryServicesImpl.this.props.getInt(QueryServices.SEQUENCE_SALT_BUCKETS_ATTRIB,

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index fc64a1b..412e050 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -1430,7 +1430,7 @@ public class MetaDataClient {
                 FunctionArgument arg = args.get(i);
                 addFunctionArgMutation(function.getFunctionName(), arg, 
argUpsert, i);
             }
-            
functionData.addAll(connection.getMutationState().toMutations(null).next().getSecond());
+            
functionData.addAll(connection.getMutationState().toMutations().next().getSecond());
             connection.rollback();
 
             PreparedStatement functionUpsert = 
connection.prepareStatement(CREATE_FUNCTION);
@@ -1549,7 +1549,7 @@ public class MetaDataClient {
             List<PName> physicalNames = Collections.emptyList();
             boolean addSaltColumn = false;
             boolean rowKeyOrderOptimizable = true;
-                       Long timestamp = null;
+            Long timestamp = null;
             if (parent != null && tableType == PTableType.INDEX) {
                transactional = parent.isTransactional();
                 timestamp = TransactionUtil.getTableTimestamp(connection, 
transactional);
@@ -1560,7 +1560,7 @@ public class MetaDataClient {
                        // table instead of only a view? We don't have anywhere 
to put the link
                        // from the table to the index, though.
                        if (indexType == IndexType.LOCAL || (parent.getType() 
== PTableType.VIEW && parent.getViewType() != ViewType.MAPPED)) {
-                           PName physicalName = parent.getPhysicalName();
+                               PName physicalName = parent.getPhysicalName();
                            saltBucketNum = parent.getBucketNum();
                            addSaltColumn = (saltBucketNum != null && indexType 
!= IndexType.LOCAL);
                            defaultFamilyName = parent.getDefaultFamilyName() 
== null ? null : parent.getDefaultFamilyName().getString();
@@ -1573,30 +1573,6 @@ public class MetaDataClient {
                                physicalNames = 
Collections.singletonList(PNameFactory.newName(MetaDataUtil.getViewIndexPhysicalName(physicalName.getBytes())));
                            }
                     }
-    
-                    multiTenant = parent.isMultiTenant();
-                    parentTableName = parent.getTableName().getString();
-                    // Pass through data table sequence number so we can check 
it hasn't changed
-                    PreparedStatement incrementStatement = 
connection.prepareStatement(INCREMENT_SEQ_NUM);
-                    incrementStatement.setString(1, connection.getTenantId() 
== null ? null : connection.getTenantId().getString());
-                    incrementStatement.setString(2, schemaName);
-                    incrementStatement.setString(3, parentTableName);
-                    incrementStatement.setLong(4, parent.getSequenceNumber());
-                    incrementStatement.execute();
-                    // Get list of mutations and add to table meta data that 
will be passed to server
-                    // to guarantee order. This row will always end up last
-                    
tableMetaData.addAll(connection.getMutationState().toMutations(timestamp).next().getSecond());
-                    connection.rollback();
-    
-                    // Add row linking from data table row to index table row
-                    PreparedStatement linkStatement = 
connection.prepareStatement(CREATE_LINK);
-                    linkStatement.setString(1, connection.getTenantId() == 
null ? null : connection.getTenantId().getString());
-                    linkStatement.setString(2, schemaName);
-                    linkStatement.setString(3, parentTableName);
-                    linkStatement.setString(4, tableName);
-                    linkStatement.setByte(5, 
LinkType.INDEX_TABLE.getSerializedValue());
-                    linkStatement.setLong(6, parent.getSequenceNumber());
-                    linkStatement.execute();
                 }
 
                 multiTenant = parent.isMultiTenant();
@@ -2754,7 +2730,6 @@ public class MetaDataClient {
                 }
                 long seqNum = table.getSequenceNumber();
                 if (changingPhoenixTableProperty || columnDefs.size() > 0) { 
-                    // TODO: verify master has fix for multiple data columns 
added and unit test
                     seqNum = incrementTableSeqNum(table, 
statement.getTableType(), columnDefs.size(), isTransactional, isImmutableRows, 
disableWAL, multiTenant, storeNulls);
                     
tableMetaData.addAll(connection.getMutationState().toMutations(timeStamp).next().getSecond());
                     connection.rollback();

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
index 0cef1a0..e20a4dd 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTableImpl.java
@@ -784,6 +784,8 @@ public class PTableImpl implements PTable {
         @Override
         public void delete() {
             newMutations();
+            // we're using the Tephra column family delete marker here to 
prevent the translation 
+            // of deletes to puts by the Tephra's TransactionProcessor
             if (PTableImpl.this.isTransactional()) {
                 Put delete = new Put(key);
                 for (PColumnFamily colFamily : families) {

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java 
b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
index 682e2b2..d4a45f6 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixRuntime.java
@@ -313,7 +313,7 @@ public class PhoenixRuntime {
      */
     public static Iterator<Pair<byte[],List<KeyValue>>> 
getUncommittedDataIterator(Connection conn, boolean includeMutableIndexes) 
throws SQLException {
         final PhoenixConnection pconn = conn.unwrap(PhoenixConnection.class);
-        final Iterator<Pair<byte[],List<Mutation>>> iterator = 
pconn.getMutationState().toMutations(includeMutableIndexes, null);
+        final Iterator<Pair<byte[],List<Mutation>>> iterator = 
pconn.getMutationState().toMutations(includeMutableIndexes);
         return new Iterator<Pair<byte[],List<KeyValue>>>() {
 
             @Override

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/CoveredIndexCodecForTesting.java
----------------------------------------------------------------------
diff --git 
a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/CoveredIndexCodecForTesting.java
 
b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/CoveredIndexCodecForTesting.java
index 0575b3f..7d31516 100644
--- 
a/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/CoveredIndexCodecForTesting.java
+++ 
b/phoenix-core/src/test/java/org/apache/phoenix/hbase/index/covered/CoveredIndexCodecForTesting.java
@@ -1,11 +1,19 @@
 /*
- * Licensed to the Apache Software Foundation (ASF) under one or more 
contributor license agreements. See the NOTICE
- * file distributed with this work for additional information regarding 
copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the "License"); you may not 
use this file except in compliance with the
- * License. You may obtain a copy of the License at 
http://www.apache.org/licenses/LICENSE-2.0 Unless required by
- * applicable law or agreed to in writing, software distributed under the 
License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
See the License for the specific language
- * governing permissions and limitations under the License.
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
 package org.apache.phoenix.hbase.index.covered;
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java 
b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
index 9c86c6d..5c9d58b 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/query/BaseTest.java
@@ -207,8 +207,10 @@ public abstract class BaseTest {
             "   CONSTRAINT pk PRIMARY KEY (varchar_pk, char_pk, int_pk, 
long_pk DESC, decimal_pk, date_pk)) ";
     private static final Map<String,String> tableDDLMap;
     private static final Logger logger = 
LoggerFactory.getLogger(BaseTest.class);
+    protected static final int DEFAULT_TXN_TIMEOUT_SECONDS = 30;
     private static ZKClientService zkClient;
     private static TransactionService txService;
+    protected static TransactionManager txManager;
     @ClassRule
     public static TemporaryFolder tmpFolder = new TemporaryFolder();
     
@@ -517,7 +519,7 @@ public abstract class BaseTest {
         config.setInt(TxConstants.Service.CFG_DATA_TX_CLIENT_ATTEMPTS, 1);
         config.setInt(TxConstants.Service.CFG_DATA_TX_BIND_PORT, 
Networks.getRandomPort());
         config.set(TxConstants.Manager.CFG_TX_SNAPSHOT_DIR, 
tmpFolder.newFolder().getAbsolutePath());
-        config.setInt(TxConstants.Manager.CFG_TX_TIMEOUT, 600);
+        config.setInt(TxConstants.Manager.CFG_TX_TIMEOUT, 
DEFAULT_TXN_TIMEOUT_SECONDS);
 
         ConnectionInfo connInfo = ConnectionInfo.create(getUrl());
         zkClient = ZKClientServices.delegate(
@@ -534,7 +536,7 @@ public abstract class BaseTest {
         zkClient.startAndWait();
 
         DiscoveryService discovery = new ZKDiscoveryService(zkClient);
-        TransactionManager txManager = new TransactionManager(config, new 
InMemoryTransactionStateStorage(), new TxMetricsCollector());
+        txManager = new TransactionManager(config, new 
InMemoryTransactionStateStorage(), new TxMetricsCollector());
         txService = new TransactionService(config, zkClient, discovery, 
Providers.of(txManager));
         txService.startAndWait();
     }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/97196e0d/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index a3647b0..c8e891d 100644
--- a/pom.xml
+++ b/pom.xml
@@ -108,7 +108,6 @@
     <commons-codec.version>1.7</commons-codec.version>
     <htrace.version>3.1.0-incubating</htrace.version>
     <collections.version>3.2.1</collections.version>
-    <jodatime.version>2.3</jodatime.version>
     <jodatime.version>2.7</jodatime.version>
     <joni.version>2.1.2</joni.version>
     <calcite.version>1.3.0-incubating</calcite.version>
@@ -350,7 +349,6 @@
               
<headerLocation>${top.dir}/src/main/config/checkstyle/header.txt</headerLocation>
               <failOnViolation><!--true-->false</failOnViolation>
               
<includeTestSourceDirectory><!--true-->false</includeTestSourceDirectory>
-              <skip>true</skip>
             </configuration>
             <goals>
               <goal>check</goal>

Reply via email to