Repository: hive
Updated Branches:
  refs/heads/master 446cb5da7 -> d977a9d77


HIVE-18864: ValidWriteIdList snapshot seems incorrect if obtained after 
allocating writeId by current transaction (Sankar Hariappan, reviewed by Eugene 
Koifman)


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

Branch: refs/heads/master
Commit: d977a9d77750d506377c83309fe5df50562acc11
Parents: 446cb5d
Author: Sankar Hariappan <sank...@apache.org>
Authored: Wed Mar 14 01:53:17 2018 +0530
Committer: Sankar Hariappan <sank...@apache.org>
Committed: Wed Mar 14 01:53:17 2018 +0530

----------------------------------------------------------------------
 .../upgrade/derby/050-HIVE-18192.derby.sql      |  3 +-
 .../derby/hive-txn-schema-3.0.0.derby.sql       |  3 +-
 .../hive/ql/lockmgr/TestDbTxnManager2.java      | 83 ++++++++++++++++++++
 .../hadoop/hive/metastore/txn/TxnHandler.java   | 64 +++++++++------
 .../main/sql/derby/hive-schema-3.0.0.derby.sql  |  3 +-
 .../sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql  |  3 +-
 .../main/sql/mssql/hive-schema-3.0.0.mssql.sql  |  3 +-
 .../sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql  |  3 +-
 .../main/sql/mysql/hive-schema-3.0.0.mysql.sql  |  3 +-
 .../sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql  |  3 +-
 .../sql/oracle/hive-schema-3.0.0.oracle.sql     |  3 +-
 .../oracle/upgrade-2.3.0-to-3.0.0.oracle.sql    |  3 +-
 .../sql/postgres/hive-schema-3.0.0.postgres.sql |  3 +-
 .../upgrade-2.3.0-to-3.0.0.postgres.sql         |  3 +-
 14 files changed, 146 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql 
b/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql
index b0bc5b1..3c20d1e 100644
--- a/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql
+++ b/metastore/scripts/upgrade/derby/050-HIVE-18192.derby.sql
@@ -6,7 +6,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql 
b/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql
index 6001262..99838b4 100644
--- a/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql
+++ b/metastore/scripts/upgrade/derby/hive-txn-schema-3.0.0.derby.sql
@@ -62,7 +62,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
----------------------------------------------------------------------
diff --git 
a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java 
b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
index d9a5feb..efc0cfe 100644
--- a/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
+++ b/ql/src/test/org/apache/hadoop/hive/ql/lockmgr/TestDbTxnManager2.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.hive.ql.lockmgr;
 
 import org.apache.commons.lang3.StringUtils;
 import org.apache.hadoop.hive.common.JavaUtils;
+import org.apache.hadoop.hive.common.ValidWriteIdList;
 import org.apache.hadoop.hive.metastore.MetastoreTaskThread;
 import org.apache.hadoop.hive.metastore.api.AddDynamicPartitions;
 import org.apache.hadoop.hive.metastore.api.AllocateTableWriteIdsRequest;
@@ -2335,4 +2336,86 @@ public class TestDbTxnManager2 {
     checkLock(LockType.SHARED_READ, LockState.ACQUIRED, "default", "T7", 
"p=2", locks);
 
   }
+
+  @Test
+  public void testValidWriteIdListSnapshot() throws Exception {
+    // Create a transactional table
+    dropTable(new String[] {"temp.T7"});
+    CommandProcessorResponse cpr = driver.run("create database if not exists 
temp");
+    checkCmdOnDriver(cpr);
+    cpr = driver.run("create table if not exists temp.T7(a int, b int) 
clustered by(b) into 2 buckets stored as orc "
+            + "TBLPROPERTIES ('transactional'='true')");
+    checkCmdOnDriver(cpr);
+
+    // Open a base txn which allocates write ID and then committed.
+    long baseTxnId = txnMgr.openTxn(ctx, "u0");
+    long baseWriteId = txnMgr.getTableWriteId("temp", "T7");
+    Assert.assertEquals(1, baseWriteId);
+    txnMgr.commitTxn(); // committed baseTxnId
+
+    // Open a txn with no writes.
+    HiveTxnManager txnMgr1 = 
TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
+    long underHwmOpenTxnId = txnMgr1.openTxn(ctx, "u1");
+    Assert.assertTrue("Invalid txn ID", underHwmOpenTxnId > baseTxnId);
+
+    // Open a txn to be tested for ValidWriteIdList. Get the ValidTxnList 
during open itself.
+    // Verify the ValidWriteIdList with no open/aborted write txns on this 
table.
+    // Write ID of committed txn should be valid.
+    HiveTxnManager txnMgr2 = 
TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
+    long testTxnId = txnMgr2.openTxn(ctx, "u2");
+    Assert.assertTrue("Invalid txn ID", testTxnId > underHwmOpenTxnId);
+    String testValidTxns = txnMgr2.getValidTxns().toString();
+    ValidWriteIdList testValidWriteIds = 
txnMgr2.getValidWriteIds(Collections.singletonList("temp.t7"), testValidTxns)
+            .getTableValidWriteIdList("temp.t7");
+    Assert.assertEquals(baseWriteId, testValidWriteIds.getHighWatermark());
+    Assert.assertTrue("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(baseWriteId));
+
+    // Open a txn which allocate write ID and remain open state.
+    HiveTxnManager txnMgr3 = 
TxnManagerFactory.getTxnManagerFactory().getTxnManager(conf);
+    long aboveHwmOpenTxnId = txnMgr3.openTxn(ctx, "u3");
+    Assert.assertTrue("Invalid txn ID", aboveHwmOpenTxnId > testTxnId);
+    long aboveHwmOpenWriteId = txnMgr3.getTableWriteId("temp", "T7");
+    Assert.assertEquals(2, aboveHwmOpenWriteId);
+
+    // Allocate writeId to txn under HWM. This will get Id greater than a txn 
> HWM.
+    long underHwmOpenWriteId = txnMgr1.getTableWriteId("temp", "T7");
+    Assert.assertEquals(3, underHwmOpenWriteId);
+
+    // Verify the ValidWriteIdList with one open txn on this table. Write ID 
of open txn should be invalid.
+    testValidWriteIds = 
txnMgr2.getValidWriteIds(Collections.singletonList("temp.t7"), testValidTxns)
+            .getTableValidWriteIdList("temp.t7");
+    Assert.assertEquals(underHwmOpenWriteId, 
testValidWriteIds.getHighWatermark());
+    Assert.assertTrue("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(baseWriteId));
+    Assert.assertFalse("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(underHwmOpenWriteId));
+    Assert.assertFalse("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(aboveHwmOpenWriteId));
+
+    // Commit the txn under HWM.
+    // Verify the writeId of this committed txn should be invalid for test txn.
+    txnMgr1.commitTxn();
+    testValidWriteIds = 
txnMgr2.getValidWriteIds(Collections.singletonList("temp.t7"), testValidTxns)
+            .getTableValidWriteIdList("temp.t7");
+    Assert.assertEquals(underHwmOpenWriteId, 
testValidWriteIds.getHighWatermark());
+    Assert.assertTrue("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(baseWriteId));
+    Assert.assertFalse("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(underHwmOpenWriteId));
+    Assert.assertFalse("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(aboveHwmOpenWriteId));
+
+    // Allocate writeId from test txn and then verify ValidWriteIdList.
+    // Write Ids of committed and self test txn should be valid but writeId of 
open txn should be invalid.
+    // WriteId of recently committed txn which was open when get ValidTxnList 
snapshot should be invalid as well.
+    long testWriteId = txnMgr2.getTableWriteId("temp", "T7");
+    Assert.assertEquals(4, testWriteId);
+
+    testValidWriteIds = 
txnMgr2.getValidWriteIds(Collections.singletonList("temp.t7"), testValidTxns)
+            .getTableValidWriteIdList("temp.t7");
+    Assert.assertEquals(testWriteId, testValidWriteIds.getHighWatermark());
+    Assert.assertTrue("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(baseWriteId));
+    Assert.assertTrue("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(testWriteId));
+    Assert.assertFalse("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(underHwmOpenWriteId));
+    Assert.assertFalse("Invalid write ID list", 
testValidWriteIds.isWriteIdValid(aboveHwmOpenWriteId));
+    txnMgr2.commitTxn();
+    txnMgr3.commitTxn();
+
+    cpr = driver.run("drop database if exists temp cascade");
+    checkCmdOnDriver(cpr);
+  }
 }

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
 
b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
index 6a74594..cb5b853 100644
--- 
a/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
+++ 
b/standalone-metastore/src/main/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
@@ -932,40 +932,54 @@ abstract class TxnHandler implements TxnStore, 
TxnStore.MutexAPI {
     String[] names = TxnUtils.getDbTableName(fullTableName);
     try {
       // Need to initialize to 0 to make sure if nobody modified this table, 
then current txn
-      // shouldn't read any data
+      // shouldn't read any data.
+      // If there is a conversion from non-acid to acid table, then by default 
0 would be assigned as
+      // writeId for data from non-acid table and so writeIdHwm=0 would ensure 
those data are readable by any txns.
       long writeIdHwm = 0;
       List<Long> invalidWriteIdList = new ArrayList<>();
+      long minOpenWriteId = Long.MAX_VALUE;
+      BitSet abortedBits = new BitSet();
       long txnHwm = validTxnList.getHighWatermark();
 
-      // The output includes all the txns which are under the high water mark. 
It includes
-      // the committed transactions as well. The results should be sorted in 
ascending order based
-      // on write id. The sorting is needed as exceptions list in 
ValidWriteIdList would be looked-up
-      // using binary search.
-      String s = "select t2w_txnid, t2w_writeid from TXN_TO_WRITE_ID where 
t2w_txnid <= " + txnHwm
+      // Find the writeId high water mark based upon txnId high water mark. If 
found, then, need to
+      // traverse through all write Ids less than writeId HWM to make 
exceptions list.
+      String s = "select max(t2w_writeid) from TXN_TO_WRITE_ID where t2w_txnid 
<= " + txnHwm
               + " and t2w_database = " + quoteString(names[0])
-              + " and t2w_table = " + quoteString(names[1])
-              + " order by t2w_writeid asc";
+              + " and t2w_table = " + quoteString(names[1]);
       LOG.debug("Going to execute query<" + s + ">");
       rs = stmt.executeQuery(s);
-      long minOpenWriteId = Long.MAX_VALUE;
-      BitSet abortedBits = new BitSet();
-      while (rs.next()) {
-        long txnId = rs.getLong(1);
-        long writeId = rs.getLong(2);
-        writeIdHwm = Math.max(writeIdHwm, writeId);
-        if (validTxnList.isTxnValid(txnId)) {
-          // Skip if the transaction under evaluation is already committed.
-          continue;
-        }
+      if (rs.next()) {
+        writeIdHwm = rs.getLong(1);
+
+        // As writeIdHwm is known, query all writeIds under the writeId HWM.
+        // If any writeId under HWM is allocated by txn > txnId HWM, then will 
be added to invalid list.
+        // The output of this query includes all the txns which are under the 
high water mark. It includes
+        // the committed transactions as well. The results should be sorted in 
ascending order based
+        // on write id. The sorting is needed as exceptions list in 
ValidWriteIdList would be looked-up
+        // using binary search.
+        s = "select t2w_txnid, t2w_writeid from TXN_TO_WRITE_ID where 
t2w_writeid <= " + writeIdHwm
+                + " and t2w_database = " + quoteString(names[0])
+                + " and t2w_table = " + quoteString(names[1])
+                + " order by t2w_writeid asc";
 
-        // The current txn is either in open or aborted state.
-        // Mark the write ids state as per the txn state.
-        if (validTxnList.isTxnAborted(txnId)) {
-          invalidWriteIdList.add(writeId);
-          abortedBits.set(invalidWriteIdList.size() - 1);
-        } else {
+        LOG.debug("Going to execute query<" + s + ">");
+        rs = stmt.executeQuery(s);
+        while (rs.next()) {
+          long txnId = rs.getLong(1);
+          long writeId = rs.getLong(2);
+          if (validTxnList.isTxnValid(txnId)) {
+            // Skip if the transaction under evaluation is already committed.
+            continue;
+          }
+
+          // The current txn is either in open or aborted state.
+          // Mark the write ids state as per the txn state.
           invalidWriteIdList.add(writeId);
-          minOpenWriteId = Math.min(minOpenWriteId, writeId);
+          if (validTxnList.isTxnAborted(txnId)) {
+            abortedBits.set(invalidWriteIdList.size() - 1);
+          } else {
+            minOpenWriteId = Math.min(minOpenWriteId, writeId);
+          }
         }
       }
 

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql 
b/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql
index 31d175e..de9688d 100644
--- a/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql
+++ b/standalone-metastore/src/main/sql/derby/hive-schema-3.0.0.derby.sql
@@ -534,7 +534,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql 
b/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql
index 7ad5147..9f187f9 100644
--- a/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql
+++ b/standalone-metastore/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql
@@ -137,7 +137,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql 
b/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql
index eb71d82..68237ec 100644
--- a/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql
+++ b/standalone-metastore/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql
@@ -1143,7 +1143,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE nvarchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql 
b/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql
index 2dc0e9b..0b5f8a4 100644
--- a/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql
+++ b/standalone-metastore/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql
@@ -190,7 +190,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE nvarchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql 
b/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql
index 40680a4..3e2db2a 100644
--- a/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql
+++ b/standalone-metastore/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql
@@ -1078,7 +1078,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql 
b/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql
index 29b7635..d7c49e4 100644
--- a/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql
+++ b/standalone-metastore/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql
@@ -180,7 +180,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql 
b/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql
index e3410c8..09c40ad 100644
--- a/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql
+++ b/standalone-metastore/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql
@@ -1051,7 +1051,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID number(19) NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql 
b/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql
index 3320012..51eff3e 100644
--- a/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql
+++ b/standalone-metastore/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql
@@ -200,7 +200,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID number(19) NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql 
b/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql
index 61dce6f..69317b0 100644
--- a/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql
+++ b/standalone-metastore/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql
@@ -1743,7 +1743,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

http://git-wip-us.apache.org/repos/asf/hive/blob/d977a9d7/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
----------------------------------------------------------------------
diff --git 
a/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
 
b/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
index 89f43b7..2766568 100644
--- 
a/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
+++ 
b/standalone-metastore/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
@@ -215,7 +215,8 @@ CREATE TABLE TXN_TO_WRITE_ID (
   T2W_WRITEID bigint NOT NULL
 );
 
-CREATE UNIQUE INDEX TXN_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_TXN_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_TXNID);
+CREATE UNIQUE INDEX TBL_TO_WRITE_ID_IDX ON TXN_TO_WRITE_ID (T2W_DATABASE, 
T2W_TABLE, T2W_WRITEID);
 
 CREATE TABLE NEXT_WRITE_ID (
   NWI_DATABASE varchar(128) NOT NULL,

Reply via email to