This is an automated email from the ASF dual-hosted git repository.

gates pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new 49c67a1  HIVE-21739 Make metastore DB backward compatible with 
pre-catalog versions of hive (Aditya Shah via Alan Gates)
49c67a1 is described below

commit 49c67a1d6ee330252f5459932d3e2b34548a2f59
Author: Alan Gates <ga...@hortonworks.com>
AuthorDate: Tue May 28 12:48:21 2019 -0700

    HIVE-21739 Make metastore DB backward compatible with pre-catalog versions 
of hive (Aditya Shah via Alan Gates)
---
 .../metastore-server/src/main/sql/derby/hive-schema-3.0.0.derby.sql  | 5 ++++-
 .../metastore-server/src/main/sql/derby/hive-schema-3.1.0.derby.sql  | 5 ++++-
 .../metastore-server/src/main/sql/derby/hive-schema-3.2.0.derby.sql  | 5 ++++-
 .../metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql  | 5 ++++-
 .../src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql              | 3 +++
 .../metastore-server/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql  | 5 ++++-
 .../metastore-server/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql  | 5 ++++-
 .../metastore-server/src/main/sql/mssql/hive-schema-3.2.0.mssql.sql  | 5 ++++-
 .../metastore-server/src/main/sql/mssql/hive-schema-4.0.0.mssql.sql  | 5 ++++-
 .../src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql              | 3 +++
 .../metastore-server/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql  | 4 +++-
 .../metastore-server/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql  | 4 +++-
 .../metastore-server/src/main/sql/mysql/hive-schema-3.2.0.mysql.sql  | 4 +++-
 .../metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql  | 4 +++-
 .../src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql              | 4 ++--
 .../src/main/sql/oracle/hive-schema-3.0.0.oracle.sql                 | 5 ++++-
 .../src/main/sql/oracle/hive-schema-3.1.0.oracle.sql                 | 5 ++++-
 .../src/main/sql/oracle/hive-schema-3.2.0.oracle.sql                 | 5 ++++-
 .../src/main/sql/oracle/hive-schema-4.0.0.oracle.sql                 | 5 ++++-
 .../src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql            | 2 +-
 .../src/main/sql/postgres/hive-schema-3.0.0.postgres.sql             | 5 ++++-
 .../src/main/sql/postgres/hive-schema-3.1.0.postgres.sql             | 5 ++++-
 .../src/main/sql/postgres/hive-schema-3.2.0.postgres.sql             | 5 ++++-
 .../src/main/sql/postgres/hive-schema-4.0.0.postgres.sql             | 5 ++++-
 .../src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql        | 3 +++
 .../hive/metastore/tools/schematool/TestSchemaToolForMetastore.java  | 2 +-
 26 files changed, 89 insertions(+), 24 deletions(-)

diff --git 
a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.0.0.derby.sql
 
b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.0.0.derby.sql
index e818e1b..4994763 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.0.0.derby.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.0.0.derby.sql
@@ -22,7 +22,7 @@ CREATE TABLE "APP"."DBS" (
   "NAME" VARCHAR(128),
   "OWNER_NAME" VARCHAR(128),
   "OWNER_TYPE" VARCHAR(10),
-  "CTLG_NAME" VARCHAR(256) NOT NULL
+  "CTLG_NAME" VARCHAR(256) NOT NULL DEFAULT 'hive'
 );
 
 CREATE TABLE "APP"."TBL_PRIVS" ("TBL_GRANT_ID" BIGINT NOT NULL, "CREATE_TIME" 
INTEGER NOT NULL, "GRANT_OPTION" SMALLINT NOT NULL, "GRANTOR" VARCHAR(128), 
"GRANTOR_TYPE" VARCHAR(128), "PRINCIPAL_NAME" VARCHAR(128), "PRINCIPAL_TYPE" 
VARCHAR(128), "TBL_PRIV" VARCHAR(128), "TBL_ID" BIGINT);
@@ -211,6 +211,9 @@ CREATE TABLE "APP"."CTLGS" (
     "DESC" VARCHAR(4000),
     "LOCATION_URI" VARCHAR(4000) NOT NULL);
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO "APP"."CTLGS" VALUES (1, 'hive', 'Default catalog for Hive', 
'TBD');
+
 -- ----------------------------------------------
 -- DML Statements
 -- ----------------------------------------------
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.1.0.derby.sql
 
b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.1.0.derby.sql
index 043cf07..74582e1 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.1.0.derby.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.1.0.derby.sql
@@ -22,7 +22,7 @@ CREATE TABLE "APP"."DBS" (
   "NAME" VARCHAR(128),
   "OWNER_NAME" VARCHAR(128),
   "OWNER_TYPE" VARCHAR(10),
-  "CTLG_NAME" VARCHAR(256) NOT NULL
+  "CTLG_NAME" VARCHAR(256) NOT NULL DEFAULT 'hive'
 );
 
 CREATE TABLE "APP"."TBL_PRIVS" ("TBL_GRANT_ID" BIGINT NOT NULL, "CREATE_TIME" 
INTEGER NOT NULL, "GRANT_OPTION" SMALLINT NOT NULL, "GRANTOR" VARCHAR(128), 
"GRANTOR_TYPE" VARCHAR(128), "PRINCIPAL_NAME" VARCHAR(128), "PRINCIPAL_TYPE" 
VARCHAR(128), "TBL_PRIV" VARCHAR(128), "TBL_ID" BIGINT, "AUTHORIZER" 
VARCHAR(128));
@@ -212,6 +212,9 @@ CREATE TABLE "APP"."CTLGS" (
     "DESC" VARCHAR(4000),
     "LOCATION_URI" VARCHAR(4000) NOT NULL);
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO "APP"."CTLGS" VALUES (1, 'hive', 'Default catalog for Hive', 
'TBD');
+
 -- ----------------------------------------------
 -- DML Statements
 -- ----------------------------------------------
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.2.0.derby.sql
 
b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.2.0.derby.sql
index cff37c0..74ca44e 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.2.0.derby.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-3.2.0.derby.sql
@@ -22,7 +22,7 @@ CREATE TABLE "APP"."DBS" (
   "NAME" VARCHAR(128),
   "OWNER_NAME" VARCHAR(128),
   "OWNER_TYPE" VARCHAR(10),
-  "CTLG_NAME" VARCHAR(256) NOT NULL,
+  "CTLG_NAME" VARCHAR(256) NOT NULL DEFAULT 'hive',
   "CREATE_TIME" INTEGER
 );
 
@@ -214,6 +214,9 @@ CREATE TABLE "APP"."CTLGS" (
     "LOCATION_URI" VARCHAR(4000) NOT NULL,
     "CREATE_TIME" INTEGER);
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO "APP"."CTLGS" VALUES (1, 'hive', 'Default catalog for Hive', 
'TBD', NULL);
+
 -- ----------------------------------------------
 -- DML Statements
 -- ----------------------------------------------
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
 
b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
index 02ff4ae..cac59bc 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/derby/hive-schema-4.0.0.derby.sql
@@ -22,7 +22,7 @@ CREATE TABLE "APP"."DBS" (
   "NAME" VARCHAR(128),
   "OWNER_NAME" VARCHAR(128),
   "OWNER_TYPE" VARCHAR(10),
-  "CTLG_NAME" VARCHAR(256) NOT NULL,
+  "CTLG_NAME" VARCHAR(256) NOT NULL DEFAULT 'hive',
   "CREATE_TIME" INTEGER
 );
 
@@ -216,6 +216,9 @@ CREATE TABLE "APP"."CTLGS" (
     "LOCATION_URI" VARCHAR(4000) NOT NULL,
     "CREATE_TIME" INTEGER);
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO "APP"."CTLGS" VALUES (1, 'hive', 'Default catalog for Hive', 
'TBD', NULL);
+
 -- ----------------------------------------------
 -- DML Statements
 -- ----------------------------------------------
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql
 
b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql
index 10f1373..aded9ce 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/derby/upgrade-2.3.0-to-3.0.0.derby.sql
@@ -192,6 +192,9 @@ UPDATE "APP"."DBS"
 -- Add the not null constraint
 ALTER TABLE "APP"."DBS" ALTER COLUMN "CTLG_NAME" NOT NULL;
 
+-- Add default value to ctlg name
+ALTER TABLE "APP"."DBS" ALTER COLUMN "CTLG_NAME" SET DEFAULT 'hive';
+
 -- Put back the unique index 
 CREATE UNIQUE INDEX "APP"."UNIQUE_DATABASE" ON "APP"."DBS" ("NAME", 
"CTLG_NAME");
 
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql
index c88fb18..7446036 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.0.0.mssql.sql
@@ -279,7 +279,7 @@ CREATE TABLE DBS
     "NAME" nvarchar(128) NULL,
     OWNER_NAME nvarchar(128) NULL,
     OWNER_TYPE nvarchar(10) NULL,
-    CTLG_NAME nvarchar(256)
+    CTLG_NAME nvarchar(256) DEFAULT 'hive'
 );
 
 ALTER TABLE DBS ADD CONSTRAINT DBS_PK PRIMARY KEY (DB_ID);
@@ -692,6 +692,9 @@ CREATE TABLE CTLGS (
       LOCATION_URI nvarchar(4000) not null
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO CTLGS VALUES (1, 'hive', 'Default catalog for Hive', 'TBD');
+
 CREATE UNIQUE INDEX UNIQUE_CTLG ON CTLGS ("NAME");
 
 -- Constraints for table MASTER_KEYS for class(es) 
[org.apache.hadoop.hive.metastore.model.MMasterKey]
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql
index fef6ab9..ca2729d 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.1.0.mssql.sql
@@ -285,7 +285,7 @@ CREATE TABLE DBS
     "NAME" nvarchar(128) NULL,
     OWNER_NAME nvarchar(128) NULL,
     OWNER_TYPE nvarchar(10) NULL,
-    CTLG_NAME nvarchar(256)
+    CTLG_NAME nvarchar(256) DEFAULT 'hive'
 );
 
 ALTER TABLE DBS ADD CONSTRAINT DBS_PK PRIMARY KEY (DB_ID);
@@ -700,6 +700,9 @@ CREATE TABLE CTLGS (
       LOCATION_URI nvarchar(4000) not null
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO CTLGS VALUES (1, 'hive', 'Default catalog for Hive', 'TBD');
+
 CREATE UNIQUE INDEX UNIQUE_CTLG ON CTLGS ("NAME");
 
 -- Constraints for table MASTER_KEYS for class(es) 
[org.apache.hadoop.hive.metastore.model.MMasterKey]
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.2.0.mssql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.2.0.mssql.sql
index cd04b4c..345c046 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.2.0.mssql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-3.2.0.mssql.sql
@@ -285,7 +285,7 @@ CREATE TABLE DBS
     "NAME" nvarchar(128) NULL,
     OWNER_NAME nvarchar(128) NULL,
     OWNER_TYPE nvarchar(10) NULL,
-    CTLG_NAME nvarchar(256),
+    CTLG_NAME nvarchar(256) DEFAULT 'hive',
     CREATE_TIME INT
 );
 
@@ -702,6 +702,9 @@ CREATE TABLE CTLGS (
       CREATE_TIME INT
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO CTLGS VALUES (1, 'hive', 'Default catalog for Hive', 'TBD', NULL);
+
 CREATE UNIQUE INDEX UNIQUE_CTLG ON CTLGS ("NAME");
 
 -- Constraints for table MASTER_KEYS for class(es) 
[org.apache.hadoop.hive.metastore.model.MMasterKey]
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-4.0.0.mssql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-4.0.0.mssql.sql
index cde23ed..c231368 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-4.0.0.mssql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mssql/hive-schema-4.0.0.mssql.sql
@@ -285,7 +285,7 @@ CREATE TABLE DBS
     "NAME" nvarchar(128) NULL,
     OWNER_NAME nvarchar(128) NULL,
     OWNER_TYPE nvarchar(10) NULL,
-    CTLG_NAME nvarchar(256),
+    CTLG_NAME nvarchar(256) DEFAULT 'hive',
     CREATE_TIME INT
 );
 
@@ -705,6 +705,9 @@ CREATE TABLE CTLGS (
       CREATE_TIME INT
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO CTLGS VALUES (1, 'hive', 'Default catalog for Hive', 'TBD', NULL);
+
 CREATE UNIQUE INDEX UNIQUE_CTLG ON CTLGS ("NAME");
 
 -- Constraints for table MASTER_KEYS for class(es) 
[org.apache.hadoop.hive.metastore.model.MMasterKey]
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql
index 7f307ed..ac473af 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mssql/upgrade-2.3.0-to-3.0.0.mssql.sql
@@ -271,6 +271,9 @@ UPDATE DBS
 -- Add the not null constraint
 ALTER TABLE DBS ALTER COLUMN CTLG_NAME nvarchar(256) NOT NULL;
 
+-- Add the default as 'hive'
+ALTER TABLE DBS ADD DEFAULT 'hive' FOR CTLG_NAME;
+
 -- Put back the unique index
 CREATE UNIQUE INDEX UNIQUEDATABASE ON DBS ("NAME", "CTLG_NAME");
 
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql
index c65af1e..c793102 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.0.0.mysql.sql
@@ -85,6 +85,8 @@ CREATE TABLE `CTLGS` (
     UNIQUE KEY `UNIQUE_CATALOG` (`NAME`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO `CTLGS` VALUES (1, 'hive', 'Default catalog for Hive', 'TBD');
 
 --
 -- Table structure for table `DBS`
@@ -99,7 +101,7 @@ CREATE TABLE IF NOT EXISTS `DBS` (
   `NAME` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
   `OWNER_NAME` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 
NULL,
   `OWNER_TYPE` varchar(10) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 
NULL,
-  `CTLG_NAME` varchar(256) NOT NULL,
+  `CTLG_NAME` varchar(256) NOT NULL DEFAULT 'hive',
   PRIMARY KEY (`DB_ID`),
   UNIQUE KEY `UNIQUE_DATABASE` (`NAME`, `CTLG_NAME`),
   CONSTRAINT `CTLG_FK1` FOREIGN KEY (`CTLG_NAME`) REFERENCES `CTLGS` (`NAME`)
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql
index 8510ceb..048162c 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.1.0.mysql.sql
@@ -85,6 +85,8 @@ CREATE TABLE `CTLGS` (
     UNIQUE KEY `UNIQUE_CATALOG` (`NAME`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO `CTLGS` VALUES (1, 'hive', 'Default catalog for Hive', 'TBD');
 
 --
 -- Table structure for table `DBS`
@@ -99,7 +101,7 @@ CREATE TABLE IF NOT EXISTS `DBS` (
   `NAME` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
   `OWNER_NAME` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 
NULL,
   `OWNER_TYPE` varchar(10) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 
NULL,
-  `CTLG_NAME` varchar(256) NOT NULL,
+  `CTLG_NAME` varchar(256) NOT NULL DEFAULT 'hive',
   PRIMARY KEY (`DB_ID`),
   UNIQUE KEY `UNIQUE_DATABASE` (`NAME`, `CTLG_NAME`),
   CONSTRAINT `CTLG_FK1` FOREIGN KEY (`CTLG_NAME`) REFERENCES `CTLGS` (`NAME`)
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.2.0.mysql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.2.0.mysql.sql
index bd0447e..d791dd9 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.2.0.mysql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-3.2.0.mysql.sql
@@ -86,6 +86,8 @@ CREATE TABLE `CTLGS` (
     UNIQUE KEY `UNIQUE_CATALOG` (`NAME`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO `CTLGS` VALUES (1, 'hive', 'Default catalog for Hive', 'TBD', 
NULL);
 
 --
 -- Table structure for table `DBS`
@@ -100,7 +102,7 @@ CREATE TABLE IF NOT EXISTS `DBS` (
   `NAME` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
   `OWNER_NAME` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 
NULL,
   `OWNER_TYPE` varchar(10) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 
NULL,
-  `CTLG_NAME` varchar(256) NOT NULL,
+  `CTLG_NAME` varchar(256) NOT NULL DEFAULT 'hive',
   `CREATE_TIME` INT(11),
   PRIMARY KEY (`DB_ID`),
   UNIQUE KEY `UNIQUE_DATABASE` (`NAME`, `CTLG_NAME`),
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
index cd03ba7..e8af9a1 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mysql/hive-schema-4.0.0.mysql.sql
@@ -86,6 +86,8 @@ CREATE TABLE `CTLGS` (
     UNIQUE KEY `UNIQUE_CATALOG` (`NAME`)
 ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO `CTLGS` VALUES (1, 'hive', 'Default catalog for Hive', 'TBD', 
NULL);
 
 --
 -- Table structure for table `DBS`
@@ -100,7 +102,7 @@ CREATE TABLE IF NOT EXISTS `DBS` (
   `NAME` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT NULL,
   `OWNER_NAME` varchar(128) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 
NULL,
   `OWNER_TYPE` varchar(10) CHARACTER SET latin1 COLLATE latin1_bin DEFAULT 
NULL,
-  `CTLG_NAME` varchar(256) NOT NULL,
+  `CTLG_NAME` varchar(256) NOT NULL DEFAULT 'hive',
   `CREATE_TIME` INT(11),
   PRIMARY KEY (`DB_ID`),
   UNIQUE KEY `UNIQUE_DATABASE` (`NAME`, `CTLG_NAME`),
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql
 
b/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql
index 786e38a..8e11ee8 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/mysql/upgrade-2.3.0-to-3.0.0.mysql.sql
@@ -235,8 +235,8 @@ ALTER TABLE `DBS` ADD COLUMN `CTLG_NAME` VARCHAR(256);
 UPDATE `DBS` 
   SET `CTLG_NAME` = 'hive';
 
--- Add the not null constraint
-ALTER TABLE `DBS` CHANGE COLUMN `CTLG_NAME` `CTLG_NAME` varchar(256) NOT NULL;
+-- Add the not null constraint and default value
+ALTER TABLE `DBS` CHANGE COLUMN `CTLG_NAME` `CTLG_NAME` varchar(256) NOT NULL 
DEFAULT 'hive';
 
 -- Put back the unique index 
 ALTER TABLE `DBS` ADD UNIQUE KEY `UNIQUE_DATABASE` (`NAME`, `CTLG_NAME`);
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql
 
b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql
index 93e032f..be4c7c3 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.0.0.oracle.sql
@@ -86,6 +86,9 @@ CREATE TABLE CTLGS (
     UNIQUE ("NAME")
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO CTLGS VALUES (1, 'hive', 'Default catalog for Hive', 'TBD');
+
 -- Table DBS for classes [org.apache.hadoop.hive.metastore.model.MDatabase]
 CREATE TABLE DBS
 (
@@ -95,7 +98,7 @@ CREATE TABLE DBS
     "NAME" VARCHAR2(128) NULL,
     OWNER_NAME VARCHAR2(128) NULL,
     OWNER_TYPE VARCHAR2(10) NULL,
-    CTLG_NAME VARCHAR2(256)
+    CTLG_NAME VARCHAR2(256) DEFAULT 'hive'
 );
 
 ALTER TABLE DBS ADD CONSTRAINT DBS_PK PRIMARY KEY (DB_ID);
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.1.0.oracle.sql
 
b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.1.0.oracle.sql
index 895ee48..958e62a 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.1.0.oracle.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.1.0.oracle.sql
@@ -87,6 +87,9 @@ CREATE TABLE CTLGS (
     UNIQUE ("NAME")
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO CTLGS VALUES (1, 'hive', 'Default catalog for Hive', 'TBD');
+
 -- Table DBS for classes [org.apache.hadoop.hive.metastore.model.MDatabase]
 CREATE TABLE DBS
 (
@@ -96,7 +99,7 @@ CREATE TABLE DBS
     "NAME" VARCHAR2(128) NULL,
     OWNER_NAME VARCHAR2(128) NULL,
     OWNER_TYPE VARCHAR2(10) NULL,
-    CTLG_NAME VARCHAR2(256)
+    CTLG_NAME VARCHAR2(256) DEFAULT 'hive'
 );
 
 ALTER TABLE DBS ADD CONSTRAINT DBS_PK PRIMARY KEY (DB_ID);
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.2.0.oracle.sql
 
b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.2.0.oracle.sql
index 8b91146..c62ad6a 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.2.0.oracle.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-3.2.0.oracle.sql
@@ -88,6 +88,9 @@ CREATE TABLE CTLGS (
     UNIQUE ("NAME")
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO CTLGS VALUES (1, 'hive', 'Default catalog for Hive', 'TBD', NULL);
+
 -- Table DBS for classes [org.apache.hadoop.hive.metastore.model.MDatabase]
 CREATE TABLE DBS
 (
@@ -97,7 +100,7 @@ CREATE TABLE DBS
     "NAME" VARCHAR2(128) NULL,
     OWNER_NAME VARCHAR2(128) NULL,
     OWNER_TYPE VARCHAR2(10) NULL,
-    CTLG_NAME VARCHAR2(256),
+    CTLG_NAME VARCHAR2(256) DEFAULT 'hive',
     CREATE_TIME NUMBER (10)
 );
 
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql
 
b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql
index 16140d1..b3c2f79 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/oracle/hive-schema-4.0.0.oracle.sql
@@ -88,6 +88,9 @@ CREATE TABLE CTLGS (
     UNIQUE ("NAME")
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO CTLGS VALUES (1, 'hive', 'Default catalog for Hive', 'TBD', NULL);
+
 -- Table DBS for classes [org.apache.hadoop.hive.metastore.model.MDatabase]
 CREATE TABLE DBS
 (
@@ -97,7 +100,7 @@ CREATE TABLE DBS
     "NAME" VARCHAR2(128) NULL,
     OWNER_NAME VARCHAR2(128) NULL,
     OWNER_TYPE VARCHAR2(10) NULL,
-    CTLG_NAME VARCHAR2(256),
+    CTLG_NAME VARCHAR2(256) DEFAULT 'hive',
     CREATE_TIME NUMBER (10)
 );
 
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql
 
b/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql
index b548665..a75ee5d 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/oracle/upgrade-2.3.0-to-3.0.0.oracle.sql
@@ -250,7 +250,7 @@ UPDATE DBS
   SET "CTLG_NAME" = 'hive';
 
 -- Add the not null constraint
-ALTER TABLE DBS MODIFY CTLG_NAME NOT NULL;
+ALTER TABLE DBS MODIFY CTLG_NAME DEFAULT 'hive' NOT NULL;
 
 -- Put back the unique index 
 CREATE UNIQUE INDEX UNIQUE_DATABASE ON DBS ("NAME", CTLG_NAME);
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql
 
b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql
index b89c87f..3f94f5b 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.0.0.postgres.sql
@@ -66,6 +66,9 @@ CREATE TABLE "CTLGS" (
     "LOCATION_URI" VARCHAR(4000) NOT NULL
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO "CTLGS" VALUES (1, 'hive', 'Default catalog for Hive', 'TBD');
+
 --
 -- Name: DBS; Type: TABLE; Schema: public; Owner: hiveuser; Tablespace:
 --
@@ -77,7 +80,7 @@ CREATE TABLE "DBS" (
     "NAME" character varying(128) DEFAULT NULL::character varying,
     "OWNER_NAME" character varying(128) DEFAULT NULL::character varying,
     "OWNER_TYPE" character varying(10) DEFAULT NULL::character varying,
-    "CTLG_NAME" varchar(256)
+    "CTLG_NAME" varchar(256) DEFAULT 'hive'
 );
 
 
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.1.0.postgres.sql
 
b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.1.0.postgres.sql
index 3281c1f..4d1ae84 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.1.0.postgres.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.1.0.postgres.sql
@@ -66,6 +66,9 @@ CREATE TABLE "CTLGS" (
     "LOCATION_URI" VARCHAR(4000) NOT NULL
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO "CTLGS" VALUES (1, 'hive', 'Default catalog for Hive', 'TBD');
+
 --
 -- Name: DBS; Type: TABLE; Schema: public; Owner: hiveuser; Tablespace:
 --
@@ -77,7 +80,7 @@ CREATE TABLE "DBS" (
     "NAME" character varying(128) DEFAULT NULL::character varying,
     "OWNER_NAME" character varying(128) DEFAULT NULL::character varying,
     "OWNER_TYPE" character varying(10) DEFAULT NULL::character varying,
-    "CTLG_NAME" varchar(256)
+    "CTLG_NAME" varchar(256) DEFAULT 'hive'
 );
 
 
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.2.0.postgres.sql
 
b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.2.0.postgres.sql
index 3854905..337b026 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.2.0.postgres.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-3.2.0.postgres.sql
@@ -67,6 +67,9 @@ CREATE TABLE "CTLGS" (
     "CREATE_TIME" bigint
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO "CTLGS" VALUES (1, 'hive', 'Default catalog for Hive', 'TBD', 
NULL);
+
 --
 -- Name: DBS; Type: TABLE; Schema: public; Owner: hiveuser; Tablespace:
 --
@@ -78,7 +81,7 @@ CREATE TABLE "DBS" (
     "NAME" character varying(128) DEFAULT NULL::character varying,
     "OWNER_NAME" character varying(128) DEFAULT NULL::character varying,
     "OWNER_TYPE" character varying(10) DEFAULT NULL::character varying,
-    "CTLG_NAME" varchar(256),
+    "CTLG_NAME" varchar(256) DEFAULT 'hive',
     "CREATE_TIME" bigint
 );
 
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
 
b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
index 2aff1e4..db52599 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/postgres/hive-schema-4.0.0.postgres.sql
@@ -67,6 +67,9 @@ CREATE TABLE "CTLGS" (
     "CREATE_TIME" bigint
 );
 
+-- Insert a default value.  The location is TBD.  Hive will fix this when it 
starts
+INSERT INTO "CTLGS" VALUES (1, 'hive', 'Default catalog for Hive', 'TBD', 
NULL);
+
 --
 -- Name: DBS; Type: TABLE; Schema: public; Owner: hiveuser; Tablespace:
 --
@@ -78,7 +81,7 @@ CREATE TABLE "DBS" (
     "NAME" character varying(128) DEFAULT NULL::character varying,
     "OWNER_NAME" character varying(128) DEFAULT NULL::character varying,
     "OWNER_TYPE" character varying(10) DEFAULT NULL::character varying,
-    "CTLG_NAME" varchar(256),
+    "CTLG_NAME" varchar(256) DEFAULT 'hive',
     "CREATE_TIME" bigint
 );
 
diff --git 
a/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
 
b/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
index f2571d8..06e758c 100644
--- 
a/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
+++ 
b/standalone-metastore/metastore-server/src/main/sql/postgres/upgrade-2.3.0-to-3.0.0.postgres.sql
@@ -268,6 +268,9 @@ UPDATE "DBS"
 -- Add the not null constraint
 ALTER TABLE "DBS" ALTER COLUMN "CTLG_NAME" SET NOT NULL;
 
+-- Add the default catalog name
+ALTER TABLE "DBS" ALTER COLUMN "CTLG_NAME" SET DEFAULT 'hive';
+
 -- Put back the unique index 
 ALTER TABLE "DBS" ADD CONSTRAINT "UNIQUE_DATABASE" UNIQUE ("NAME", 
"CTLG_NAME");
 
diff --git 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestSchemaToolForMetastore.java
 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestSchemaToolForMetastore.java
index 528d7b2..1f7d17f 100644
--- 
a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestSchemaToolForMetastore.java
+++ 
b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/tools/schematool/TestSchemaToolForMetastore.java
@@ -518,7 +518,7 @@ public class TestSchemaToolForMetastore {
   private void createTestHiveTableSchemas() throws IOException {
     String time = String.valueOf(System.currentTimeMillis()/1000);
      String[] scripts = new String[] {
-          "insert into CTLGS values (1, 'mycat', 'my description', 
'hdfs://myhost.com:8020/user/hive/warehouse', " + time + ");",
+          "insert into CTLGS values (2, 'mycat', 'my description', 
'hdfs://myhost.com:8020/user/hive/warehouse', " + time + ");",
           "insert into DBS values(2, 'my db', 
'hdfs://myhost.com:8020/user/hive/warehouse/mydb', 'mydb', 'public', 'role', 
'mycat', " + time + ");",
           "insert into 
SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID)
 values 
(1,null,'org.apache.hadoop.mapred.TextInputFormat','N','N','hdfs://myhost.com:8020/user/hive/warehouse/mydb',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",
           "insert into 
SDS(SD_ID,CD_ID,INPUT_FORMAT,IS_COMPRESSED,IS_STOREDASSUBDIRECTORIES,LOCATION,NUM_BUCKETS,OUTPUT_FORMAT,SERDE_ID)
 values 
(2,null,'org.apache.hadoop.mapred.TextInputFormat','N','N','hdfs://myhost.com:8020/user/admin/2015_11_18',-1,'org.apache.hadoop.hive.ql.io.HiveIgnoreKeyTextOutputFormat',null);",

Reply via email to