You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by se...@apache.org on 2016/02/09 23:37:35 UTC

[5/5] hive git commit: HIVE-12892 : Add global change versioning to permanent functions in metastore (Sergey Shelukhin, reviewed by Alan Gates)

HIVE-12892 : Add global change versioning to permanent functions in metastore (Sergey Shelukhin, reviewed by Alan Gates)


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

Branch: refs/heads/master
Commit: 5be9c92fbd2d39f7265b5a493fa098b4ebdb72b9
Parents: a285de0
Author: Sergey Shelukhin <se...@apache.org>
Authored: Tue Feb 9 14:37:07 2016 -0800
Committer: Sergey Shelukhin <se...@apache.org>
Committed: Tue Feb 9 14:37:07 2016 -0800

----------------------------------------------------------------------
 metastore/if/hive_metastore.thrift              |   13 +-
 .../upgrade/derby/033-HIVE-12892.derby.sql      |    3 +
 .../upgrade/derby/hive-schema-2.1.0.derby.sql   |    7 +
 .../derby/upgrade-2.0.0-to-2.1.0.derby.sql      |    1 +
 .../upgrade/mssql/018-HIVE-12892.mssql.sql      |    9 +
 .../upgrade/mssql/hive-schema-2.1.0.mssql.sql   |   13 +
 .../mssql/upgrade-2.0.0-to-2.1.0.mssql.sql      |    2 +
 .../upgrade/mysql/033-HIVE-12892.mysql.sql      |   10 +
 .../upgrade/mysql/hive-schema-2.1.0.mysql.sql   |   11 +
 .../mysql/upgrade-2.0.0-to-2.1.0.mysql.sql      |    2 +
 .../upgrade/oracle/033-HIVE-12892.oracle.sql    |    8 +
 .../upgrade/oracle/hive-schema-2.1.0.oracle.sql |   11 +-
 .../oracle/upgrade-2.0.0-to-2.1.0.oracle.sql    |    2 +
 .../postgres/032-HIVE-12892.postgres.sql        |   10 +
 .../postgres/hive-schema-2.1.0.postgres.sql     |   14 +
 .../upgrade-2.0.0-to-2.1.0.postgres.sql         |    2 +
 .../gen/thrift/gen-cpp/ThriftHiveMetastore.cpp  | 2257 ++++++++++--------
 .../gen/thrift/gen-cpp/ThriftHiveMetastore.h    |  126 +
 .../ThriftHiveMetastore_server.skeleton.cpp     |    5 +
 .../gen/thrift/gen-cpp/hive_metastore_types.cpp |  736 +++---
 .../gen/thrift/gen-cpp/hive_metastore_types.h   |   84 +
 .../metastore/api/GetChangeVersionRequest.java  |  388 +++
 .../metastore/api/GetChangeVersionResult.java   |  386 +++
 .../hive/metastore/api/ThriftHiveMetastore.java | 1622 ++++++++++---
 .../gen-php/metastore/ThriftHiveMetastore.php   |  215 ++
 .../src/gen/thrift/gen-php/metastore/Types.php  |  150 ++
 .../hive_metastore/ThriftHiveMetastore-remote   |    7 +
 .../hive_metastore/ThriftHiveMetastore.py       |  189 ++
 .../gen/thrift/gen-py/hive_metastore/ttypes.py  |  134 ++
 .../gen/thrift/gen-rb/hive_metastore_types.rb   |   34 +
 .../gen/thrift/gen-rb/thrift_hive_metastore.rb  |   54 +
 .../hadoop/hive/metastore/HiveMetaStore.java    |  111 +-
 .../hive/metastore/HiveMetaStoreClient.java     |    6 +
 .../hadoop/hive/metastore/IMetaStoreClient.java |    3 +
 .../hadoop/hive/metastore/ObjectStore.java      |  102 +-
 .../apache/hadoop/hive/metastore/RawStore.java  |    3 +
 .../hive/metastore/hbase/HBaseReadWrite.java    |   31 +-
 .../hadoop/hive/metastore/hbase/HBaseStore.java |   28 +-
 .../hive/metastore/model/MChangeVersion.java    |   48 +
 metastore/src/model/package.jdo                 |   13 +-
 .../DummyRawStoreControlledCommit.java          |    5 +
 .../DummyRawStoreForJdoConnection.java          |    5 +
 .../apache/hadoop/hive/ql/metadata/Hive.java    |    8 +
 43 files changed, 5131 insertions(+), 1737 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/if/hive_metastore.thrift
----------------------------------------------------------------------
diff --git a/metastore/if/hive_metastore.thrift b/metastore/if/hive_metastore.thrift
index 9d8c092..1abcfe5 100755
--- a/metastore/if/hive_metastore.thrift
+++ b/metastore/if/hive_metastore.thrift
@@ -740,7 +740,17 @@ struct FireEventRequest {
 struct FireEventResponse {
     // NOP for now, this is just a place holder for future responses
 }
-    
+
+
+struct GetChangeVersionRequest {
+  1: required string topic
+}
+
+struct GetChangeVersionResult {
+  1: required i64 version
+}
+
+
 struct MetadataPpdResult {
   1: optional binary metadata,
   2: optional binary includeBitset
@@ -1314,6 +1324,7 @@ service ThriftHiveMetastore extends fb303.FacebookService
   ClearFileMetadataResult clear_file_metadata(1:ClearFileMetadataRequest req)
   CacheFileMetadataResult cache_file_metadata(1:CacheFileMetadataRequest req)
 
+  GetChangeVersionResult get_change_version(1:GetChangeVersionRequest req)
 }
 
 // * Note about the DDL_TIME: When creating or altering a table or a partition,

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/derby/033-HIVE-12892.derby.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/derby/033-HIVE-12892.derby.sql b/metastore/scripts/upgrade/derby/033-HIVE-12892.derby.sql
new file mode 100644
index 0000000..ab004d9
--- /dev/null
+++ b/metastore/scripts/upgrade/derby/033-HIVE-12892.derby.sql
@@ -0,0 +1,3 @@
+CREATE TABLE "APP"."CHANGE_VERSION" ("CHANGE_VERSION_ID" BIGINT NOT NULL, "VERSION" BIGINT NOT NULL, "TOPIC" VARCHAR(255));
+ALTER TABLE "APP"."CHANGE_VERSION" ADD CONSTRAINT "CHANGE_VERSION_PK" PRIMARY KEY ("CHANGE_VERSION_ID");
+CREATE UNIQUE INDEX "APP"."UNIQUECHANGEVERSION" ON "APP"."CHANGE_VERSION" ("TOPIC");

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/derby/hive-schema-2.1.0.derby.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/derby/hive-schema-2.1.0.derby.sql b/metastore/scripts/upgrade/derby/hive-schema-2.1.0.derby.sql
index 660a85a..42f4eb6 100644
--- a/metastore/scripts/upgrade/derby/hive-schema-2.1.0.derby.sql
+++ b/metastore/scripts/upgrade/derby/hive-schema-2.1.0.derby.sql
@@ -98,6 +98,8 @@ CREATE TABLE "APP"."PART_COL_STATS"("DB_NAME" VARCHAR(128) NOT NULL,"TABLE_NAME"
 
 CREATE TABLE "APP"."VERSION" ("VER_ID" BIGINT NOT NULL, "SCHEMA_VERSION" VARCHAR(127) NOT NULL, "VERSION_COMMENT" VARCHAR(255));
 
+CREATE TABLE "APP"."CHANGE_VERSION" ("CHANGE_VERSION_ID" BIGINT NOT NULL, "VERSION" BIGINT NOT NULL, "TOPIC" VARCHAR(255));
+
 CREATE TABLE "APP"."FUNCS" ("FUNC_ID" BIGINT NOT NULL, "CLASS_NAME" VARCHAR(4000), "CREATE_TIME" INTEGER NOT NULL, "DB_ID" BIGINT, "FUNC_NAME" VARCHAR(128), "FUNC_TYPE" INTEGER NOT NULL, "OWNER_NAME" VARCHAR(128), "OWNER_TYPE" VARCHAR(10));
 
 CREATE TABLE "APP"."FUNC_RU" ("FUNC_ID" BIGINT NOT NULL, "RESOURCE_TYPE" INTEGER NOT NULL, "RESOURCE_URI" VARCHAR(4000), "INTEGER_IDX" INTEGER NOT NULL);
@@ -310,6 +312,11 @@ ALTER TABLE "APP"."PART_COL_STATS" ADD CONSTRAINT "PART_COL_STATS_FK" FOREIGN KE
 
 ALTER TABLE "APP"."VERSION" ADD CONSTRAINT "VERSION_PK" PRIMARY KEY ("VER_ID");
 
+ALTER TABLE "APP"."CHANGE_VERSION" ADD CONSTRAINT "CHANGE_VERSION_PK" PRIMARY KEY ("CHANGE_VERSION_ID");
+
+CREATE UNIQUE INDEX "APP"."UNIQUECHANGEVERSION" ON "APP"."CHANGE_VERSION" ("TOPIC");
+
+
 ALTER TABLE "APP"."FUNCS" ADD CONSTRAINT "FUNCS_FK1" FOREIGN KEY ("DB_ID") REFERENCES "APP"."DBS" ("DB_ID") ON DELETE NO ACTION ON UPDATE NO ACTION;
 
 ALTER TABLE "APP"."FUNC_RU" ADD CONSTRAINT "FUNC_RU_FK1" FOREIGN KEY ("FUNC_ID") REFERENCES "APP"."FUNCS" ("FUNC_ID") ON DELETE NO ACTION ON UPDATE NO ACTION;

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/derby/upgrade-2.0.0-to-2.1.0.derby.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/derby/upgrade-2.0.0-to-2.1.0.derby.sql b/metastore/scripts/upgrade/derby/upgrade-2.0.0-to-2.1.0.derby.sql
index 30de00b..a0bac3c 100644
--- a/metastore/scripts/upgrade/derby/upgrade-2.0.0-to-2.1.0.derby.sql
+++ b/metastore/scripts/upgrade/derby/upgrade-2.0.0-to-2.1.0.derby.sql
@@ -1,3 +1,4 @@
 -- Upgrade MetaStore schema from 2.0.0 to 2.1.0
+RUN '033-HIVE-12892.derby.sql';
 
 UPDATE "APP".VERSION SET SCHEMA_VERSION='2.1.0', VERSION_COMMENT='Hive release version 2.1.0' where VER_ID=1;

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/mssql/018-HIVE-12892.mssql.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/mssql/018-HIVE-12892.mssql.sql b/metastore/scripts/upgrade/mssql/018-HIVE-12892.mssql.sql
new file mode 100644
index 0000000..a13591d
--- /dev/null
+++ b/metastore/scripts/upgrade/mssql/018-HIVE-12892.mssql.sql
@@ -0,0 +1,9 @@
+-- Table CHANGE_VERSION
+CREATE TABLE CHANGE_VERSION
+(
+    CHANGE_VERSION_ID bigint NOT NULL,
+    VERSION bigint NOT NULL,
+    TOPIC nvarchar(255) NOT NULL
+);
+ALTER TABLE CHANGE_VERSION ADD CONSTRAINT CHANGE_VERSION_PK PRIMARY KEY (CHANGE_VERSION_ID);
+CREATE UNIQUE INDEX UNIQUECHANGEVERSION ON CHANGE_VERSION (TOPIC);

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/mssql/hive-schema-2.1.0.mssql.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/mssql/hive-schema-2.1.0.mssql.sql b/metastore/scripts/upgrade/mssql/hive-schema-2.1.0.mssql.sql
index 085c17d..cf5a662 100644
--- a/metastore/scripts/upgrade/mssql/hive-schema-2.1.0.mssql.sql
+++ b/metastore/scripts/upgrade/mssql/hive-schema-2.1.0.mssql.sql
@@ -165,6 +165,19 @@ CREATE TABLE VERSION
 
 ALTER TABLE VERSION ADD CONSTRAINT VERSION_PK PRIMARY KEY (VER_ID);
 
+-- Table CHANGE_VERSION
+CREATE TABLE CHANGE_VERSION
+(
+    CHANGE_VERSION_ID bigint NOT NULL,
+    VERSION bigint NOT NULL,
+    TOPIC nvarchar(255) NOT NULL
+);
+
+ALTER TABLE CHANGE_VERSION ADD CONSTRAINT CHANGE_VERSION_PK PRIMARY KEY (CHANGE_VERSION_ID);
+
+CREATE UNIQUE INDEX UNIQUECHANGEVERSION ON CHANGE_VERSION (TOPIC);
+
+
 -- Table GLOBAL_PRIVS for classes [org.apache.hadoop.hive.metastore.model.MGlobalPrivilege]
 CREATE TABLE GLOBAL_PRIVS
 (

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql b/metastore/scripts/upgrade/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql
index 0b806eb..f25daf2 100644
--- a/metastore/scripts/upgrade/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql
+++ b/metastore/scripts/upgrade/mssql/upgrade-2.0.0-to-2.1.0.mssql.sql
@@ -1,4 +1,6 @@
 SELECT 'Upgrading MetaStore schema from 2.0.0 to 2.1.0' AS MESSAGE;
 
+:r 018-HIVE-12892.mssql.sql;
+
 UPDATE VERSION SET SCHEMA_VERSION='2.1.0', VERSION_COMMENT='Hive release version 2.1.0' where VER_ID=1;
 SELECT 'Finished upgrading MetaStore schema from 2.0.0 to 2.1.0' AS MESSAGE;

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/mysql/033-HIVE-12892.mysql.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/mysql/033-HIVE-12892.mysql.sql b/metastore/scripts/upgrade/mysql/033-HIVE-12892.mysql.sql
new file mode 100644
index 0000000..783afe8
--- /dev/null
+++ b/metastore/scripts/upgrade/mysql/033-HIVE-12892.mysql.sql
@@ -0,0 +1,10 @@
+-- Table structure for CHANGE_VERSION
+--
+CREATE TABLE IF NOT EXISTS `CHANGE_VERSION` (
+  `CHANGE_VERSION_ID` BIGINT NOT NULL,
+  `VERSION` BIGINT NOT NULL,
+  `TOPIC` VARCHAR(255) NOT NULL,
+  PRIMARY KEY (`CHANGE_VERSION_ID`),
+  UNIQUE KEY `UNIQUECHANGEVERSION` (`TOPIC`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+--

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/mysql/hive-schema-2.1.0.mysql.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/mysql/hive-schema-2.1.0.mysql.sql b/metastore/scripts/upgrade/mysql/hive-schema-2.1.0.mysql.sql
index 06c3d90..6fd3209 100644
--- a/metastore/scripts/upgrade/mysql/hive-schema-2.1.0.mysql.sql
+++ b/metastore/scripts/upgrade/mysql/hive-schema-2.1.0.mysql.sql
@@ -760,6 +760,17 @@ CREATE TABLE IF NOT EXISTS `VERSION` (
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
 --
+-- Table structure for CHANGE_VERSION
+--
+CREATE TABLE IF NOT EXISTS `CHANGE_VERSION` (
+  `CHANGE_VERSION_ID` BIGINT NOT NULL,
+  `VERSION` BIGINT NOT NULL,
+  `TOPIC` VARCHAR(255) NOT NULL,
+  PRIMARY KEY (`CHANGE_VERSION_ID`),
+  UNIQUE KEY `UNIQUECHANGEVERSION` (`TOPIC`)
+) ENGINE=InnoDB DEFAULT CHARSET=latin1;
+
+--
 -- Table structure for table FUNCS
 --
 CREATE TABLE IF NOT EXISTS `FUNCS` (

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql b/metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql
index 2a2bb6d..e790636 100644
--- a/metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql
+++ b/metastore/scripts/upgrade/mysql/upgrade-2.0.0-to-2.1.0.mysql.sql
@@ -1,5 +1,7 @@
 SELECT 'Upgrading MetaStore schema from 2.0.0 to 2.1.0' AS ' ';
 
+SOURCE 033-HIVE-12892.mysql.sql;
+
 UPDATE VERSION SET SCHEMA_VERSION='2.1.0', VERSION_COMMENT='Hive release version 2.1.0' where VER_ID=1;
 SELECT 'Finished upgrading MetaStore schema from 2.0.0 to 2.1.0' AS ' ';
 

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/oracle/033-HIVE-12892.oracle.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/oracle/033-HIVE-12892.oracle.sql b/metastore/scripts/upgrade/oracle/033-HIVE-12892.oracle.sql
new file mode 100644
index 0000000..d6a2977
--- /dev/null
+++ b/metastore/scripts/upgrade/oracle/033-HIVE-12892.oracle.sql
@@ -0,0 +1,8 @@
+  VERSION_COMMENT VARCHAR(255) NOT NULL
+CREATE TABLE CHANGE_VERSION (
+  CHANGE_VERSION_ID NUMBER NOT NULL,
+  VERSION NUMBER NOT NULL,
+  TOPIC VARCHAR(255) NOT NULL
+);
+ALTER TABLE CHANGE_VERSION ADD CONSTRAINT CHANGE_VERSION_PK PRIMARY KEY (CHANGE_VERSION_ID);
+CREATE UNIQUE INDEX UNIQUE_CHANGE_VERSION ON CHANGE_VERSION (TOPIC);

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/oracle/hive-schema-2.1.0.oracle.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/oracle/hive-schema-2.1.0.oracle.sql b/metastore/scripts/upgrade/oracle/hive-schema-2.1.0.oracle.sql
index 644463d..774f6be 100644
--- a/metastore/scripts/upgrade/oracle/hive-schema-2.1.0.oracle.sql
+++ b/metastore/scripts/upgrade/oracle/hive-schema-2.1.0.oracle.sql
@@ -488,10 +488,19 @@ CREATE TABLE TAB_COL_STATS (
 CREATE TABLE VERSION (
   VER_ID NUMBER NOT NULL,
   SCHEMA_VERSION VARCHAR(127) NOT NULL,
-  VERSION_COMMENT VARCHAR(255)
+  VERSION_COMMENT VARCHAR(255) NOT NULL
 );
 ALTER TABLE VERSION ADD CONSTRAINT VERSION_PK PRIMARY KEY (VER_ID);
 
+CREATE TABLE CHANGE_VERSION (
+  CHANGE_VERSION_ID NUMBER NOT NULL,
+  VERSION NUMBER NOT NULL,
+  TOPIC VARCHAR(255) NOT NULL
+);
+ALTER TABLE CHANGE_VERSION ADD CONSTRAINT CHANGE_VERSION_PK PRIMARY KEY (CHANGE_VERSION_ID);
+
+CREATE UNIQUE INDEX UNIQUE_CHANGE_VERSION ON CHANGE_VERSION (TOPIC);
+
 ALTER TABLE TAB_COL_STATS ADD CONSTRAINT TAB_COL_STATS_PKEY PRIMARY KEY (CS_ID);
 
 ALTER TABLE TAB_COL_STATS ADD CONSTRAINT TAB_COL_STATS_FK FOREIGN KEY (TBL_ID) REFERENCES TBLS (TBL_ID) INITIALLY DEFERRED ;

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql b/metastore/scripts/upgrade/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql
index 9cf5fa3..8368d08 100644
--- a/metastore/scripts/upgrade/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql
+++ b/metastore/scripts/upgrade/oracle/upgrade-2.0.0-to-2.1.0.oracle.sql
@@ -1,4 +1,6 @@
 SELECT 'Upgrading MetaStore schema from 2.0.0 to 2.1.0' AS Status from dual;
 
+@033-HIVE-12892.oracle.sql;
+
 UPDATE VERSION SET SCHEMA_VERSION='2.1.0', VERSION_COMMENT='Hive release version 2.1.0' where VER_ID=1;
 SELECT 'Finished upgrading MetaStore schema from 2.0.0 to 2.1.0' AS Status from dual;

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/postgres/032-HIVE-12892.postgres.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/postgres/032-HIVE-12892.postgres.sql b/metastore/scripts/upgrade/postgres/032-HIVE-12892.postgres.sql
new file mode 100644
index 0000000..302c51a
--- /dev/null
+++ b/metastore/scripts/upgrade/postgres/032-HIVE-12892.postgres.sql
@@ -0,0 +1,10 @@
+-- Table structure for CHANGE_VERSION
+--
+CREATE TABLE "CHANGE_VERSION" (
+  "CHANGE_VERSION_ID" bigint,
+  "VERSION" bigint NOT NULL,
+  "TOPIC" character varying(255) NOT NULL
+);
+--
+ALTER TABLE ONLY "CHANGE_VERSION" ADD CONSTRAINT "CHANGE_VERSION_pkey" PRIMARY KEY ("CHANGE_VERSION_ID");
+ALTER TABLE ONLY "CHANGE_VERSION" ADD CONSTRAINT "CHANGE_VERSION_UNIQUE" UNIQUE ("TOPIC");

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/postgres/hive-schema-2.1.0.postgres.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/postgres/hive-schema-2.1.0.postgres.sql b/metastore/scripts/upgrade/postgres/hive-schema-2.1.0.postgres.sql
index 1db9993..7463a37 100644
--- a/metastore/scripts/upgrade/postgres/hive-schema-2.1.0.postgres.sql
+++ b/metastore/scripts/upgrade/postgres/hive-schema-2.1.0.postgres.sql
@@ -514,6 +514,15 @@ CREATE TABLE "VERSION" (
 );
 
 --
+-- Table structure for CHANGE_VERSION
+--
+CREATE TABLE "CHANGE_VERSION" (
+  "CHANGE_VERSION_ID" bigint,
+  "VERSION" bigint NOT NULL,
+  "TOPIC" character varying(255) NOT NULL
+);
+
+--
 -- Name: PART_COL_STATS Type: TABLE; Schema: public; Owner: hiveuser; Tablespace:
 --
 
@@ -1427,6 +1436,11 @@ ALTER TABLE ONLY "PART_COL_STATS" ADD CONSTRAINT "PART_COL_STATS_fkey" FOREIGN K
 
 ALTER TABLE ONLY "VERSION" ADD CONSTRAINT "VERSION_pkey" PRIMARY KEY ("VER_ID");
 
+ALTER TABLE ONLY "CHANGE_VERSION" ADD CONSTRAINT "CHANGE_VERSION_pkey" PRIMARY KEY ("CHANGE_VERSION_ID");
+
+ALTER TABLE ONLY "CHANGE_VERSION" ADD CONSTRAINT "CHANGE_VERSION_UNIQUE" UNIQUE ("TOPIC");
+
+
 -- Name: FUNCS_FK1; Type: FK CONSTRAINT; Schema: public; Owner: hiveuser
 ALTER TABLE ONLY "FUNCS"
     ADD CONSTRAINT "FUNCS_FK1" FOREIGN KEY ("DB_ID") REFERENCES "DBS" ("DB_ID") DEFERRABLE;

http://git-wip-us.apache.org/repos/asf/hive/blob/5be9c92f/metastore/scripts/upgrade/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql
----------------------------------------------------------------------
diff --git a/metastore/scripts/upgrade/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql b/metastore/scripts/upgrade/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql
index 316d44a..6172407 100644
--- a/metastore/scripts/upgrade/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql
+++ b/metastore/scripts/upgrade/postgres/upgrade-2.0.0-to-2.1.0.postgres.sql
@@ -1,5 +1,7 @@
 SELECT 'Upgrading MetaStore schema from 2.0.0 to 2.1.0';
 
+\i 032-HIVE-12892.postgres.sql;
+
 UPDATE "VERSION" SET "SCHEMA_VERSION"='2.1.0', "VERSION_COMMENT"='Hive release version 2.1.0' where "VER_ID"=1;
 SELECT 'Finished upgrading MetaStore schema from 2.0.0 to 2.1.0';