Return-Path: X-Original-To: apmail-hive-commits-archive@www.apache.org Delivered-To: apmail-hive-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C4F301034E for ; Mon, 17 Feb 2014 05:31:41 +0000 (UTC) Received: (qmail 10662 invoked by uid 500); 17 Feb 2014 05:31:41 -0000 Delivered-To: apmail-hive-commits-archive@hive.apache.org Received: (qmail 10452 invoked by uid 500); 17 Feb 2014 05:31:32 -0000 Mailing-List: contact commits-help@hive.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: hive-dev@hive.apache.org Delivered-To: mailing list commits@hive.apache.org Received: (qmail 10435 invoked by uid 99); 17 Feb 2014 05:31:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Feb 2014 05:31:29 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Feb 2014 05:31:26 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 705F723888E2; Mon, 17 Feb 2014 05:31:06 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1568880 [1/4] - in /hive/trunk: itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/ metastore/if/ metastore/scripts/upgrade/derby/ metastore/scripts/upgrade/mysql/ metastore/scripts/upgrade/oracle/ metastore/scripts/upgrade/po... Date: Mon, 17 Feb 2014 05:31:05 -0000 To: commits@hive.apache.org From: thejas@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140217053106.705F723888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: thejas Date: Mon Feb 17 05:31:04 2014 New Revision: 1568880 URL: http://svn.apache.org/r1568880 Log: HIVE-6386 : sql std auth - database should have an owner (Ashutosh Chauhan via Thejas Nair) Added: hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java hive/trunk/metastore/if/hive_metastore.thrift hive/trunk/metastore/src/gen/thrift/gen-cpp/ThriftHiveMetastore.cpp hive/trunk/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.cpp hive/trunk/metastore/src/gen/thrift/gen-cpp/hive_metastore_types.h hive/trunk/metastore/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/metastore/api/Database.java hive/trunk/metastore/src/gen/thrift/gen-php/metastore/Types.php hive/trunk/metastore/src/gen/thrift/gen-py/hive_metastore/ttypes.py hive/trunk/metastore/src/gen/thrift/gen-rb/hive_metastore_types.rb hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/HiveMetaStore.java hive/trunk/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java hive/trunk/metastore/src/model/org/apache/hadoop/hive/metastore/model/MDatabase.java hive/trunk/metastore/src/model/package.jdo hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/exec/DDLTask.java hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/JsonMetaDataFormatter.java hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/MetaDataFormatter.java hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/metadata/formatting/TextMetaDataFormatter.java hive/trunk/serde/src/gen/thrift/gen-cpp/serde_constants.cpp hive/trunk/serde/src/gen/thrift/gen-cpp/serde_constants.h hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde/test/ThriftTestObj.java hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/Complex.java hive/trunk/serde/src/gen/thrift/gen-javabean/org/apache/hadoop/hive/serde2/thrift/test/MegaStruct.java hive/trunk/serde/src/gen/thrift/gen-php/org/apache/hadoop/hive/serde/Types.php hive/trunk/serde/src/gen/thrift/gen-py/org_apache_hadoop_hive_serde/constants.py hive/trunk/serde/src/gen/thrift/gen-rb/serde_constants.rb Modified: hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java URL: http://svn.apache.org/viewvc/hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java?rev=1568880&r1=1568879&r2=1568880&view=diff ============================================================================== --- hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java (original) +++ hive/trunk/itests/hive-unit/src/test/java/org/apache/hadoop/hive/metastore/TestHiveMetaStore.java Mon Feb 17 05:31:04 2014 @@ -54,6 +54,7 @@ import org.apache.hadoop.hive.metastore. import org.apache.hadoop.hive.metastore.api.NoSuchObjectException; import org.apache.hadoop.hive.metastore.api.Order; import org.apache.hadoop.hive.metastore.api.Partition; +import org.apache.hadoop.hive.metastore.api.PrincipalType; import org.apache.hadoop.hive.metastore.api.SerDeInfo; import org.apache.hadoop.hive.metastore.api.SkewedInfo; import org.apache.hadoop.hive.metastore.api.StorageDescriptor; @@ -62,9 +63,11 @@ import org.apache.hadoop.hive.metastore. import org.apache.hadoop.hive.metastore.api.Type; import org.apache.hadoop.hive.metastore.api.UnknownDBException; import org.apache.hadoop.hive.ql.exec.Utilities; +import org.apache.hadoop.hive.ql.session.SessionState; import org.apache.hadoop.hive.serde.serdeConstants; import org.apache.hadoop.util.StringUtils; import org.apache.thrift.TException; +import org.junit.Test; import com.google.common.collect.Lists; @@ -923,6 +926,8 @@ public abstract class TestHiveMetaStore Database db = new Database(); db.setName(TEST_DB1_NAME); + db.setOwnerName(SessionState.getUserFromAuthenticator()); + db.setOwnerType(PrincipalType.USER); client.createDatabase(db); db = client.getDatabase(TEST_DB1_NAME); @@ -931,7 +936,8 @@ public abstract class TestHiveMetaStore TEST_DB1_NAME, db.getName()); assertEquals("location of the returned db is different from that of inserted db", warehouse.getDatabasePath(db).toString(), db.getLocationUri()); - + assertEquals(db.getOwnerName(), SessionState.getUserFromAuthenticator()); + assertEquals(db.getOwnerType(), PrincipalType.USER); Database db2 = new Database(); db2.setName(TEST_DB2_NAME); client.createDatabase(db2); @@ -2659,4 +2665,11 @@ public abstract class TestHiveMetaStore createPartitions(dbName, tbl, values); } + + @Test + public void testDBOwner() throws NoSuchObjectException, MetaException, TException { + Database db = client.getDatabase(MetaStoreUtils.DEFAULT_DATABASE_NAME); + assertEquals(db.getOwnerName(), HiveMetaStore.PUBLIC); + assertEquals(db.getOwnerType(), PrincipalType.ROLE); + } } Modified: hive/trunk/metastore/if/hive_metastore.thrift URL: http://svn.apache.org/viewvc/hive/trunk/metastore/if/hive_metastore.thrift?rev=1568880&r1=1568879&r2=1568880&view=diff ============================================================================== --- hive/trunk/metastore/if/hive_metastore.thrift (original) +++ hive/trunk/metastore/if/hive_metastore.thrift Mon Feb 17 05:31:04 2014 @@ -120,7 +120,9 @@ struct Database { 2: string description, 3: string locationUri, 4: map parameters, // properties associated with the database - 5: optional PrincipalPrivilegeSet privileges + 5: optional PrincipalPrivilegeSet privileges, + 6: optional string ownerName, + 7: optional PrincipalType ownerType } // This object holds the information needed by SerDes Added: hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql?rev=1568880&view=auto ============================================================================== --- hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql (added) +++ hive/trunk/metastore/scripts/upgrade/derby/016-HIVE-6386.derby.sql Mon Feb 17 05:31:04 2014 @@ -0,0 +1,2 @@ +ALTER TABLE "DBS" ADD "OWNER_NAME" CHAR(128); +ALTER TABLE "DBS" ADD "OWNER_TYPE" CHAR(10); Added: hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql?rev=1568880&view=auto ============================================================================== --- hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql (added) +++ hive/trunk/metastore/scripts/upgrade/mysql/016-HIVE-6386.mysql.sql Mon Feb 17 05:31:04 2014 @@ -0,0 +1,5 @@ +SELECT '< HIVE-6386: Add owner filed to database >' AS ' '; + +ALTER TABLE `DBS` ADD `OWNER_NAME` varchar(128); +ALTER TABLE `DBS` ADD `OWNER_TYPE` varchar(10); + Added: hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql?rev=1568880&view=auto ============================================================================== --- hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql (added) +++ hive/trunk/metastore/scripts/upgrade/oracle/016-HIVE-6386.oracle.sql Mon Feb 17 05:31:04 2014 @@ -0,0 +1,2 @@ +ALTER TABLE DBS ADD OWNER_NAME VARCHAR2(128); +ALTER TABLE DBS ADD OWNER_TYPE VARCHAR2(10); Added: hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql URL: http://svn.apache.org/viewvc/hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql?rev=1568880&view=auto ============================================================================== --- hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql (added) +++ hive/trunk/metastore/scripts/upgrade/postgres/016-HIVE-6386.postgres.sql Mon Feb 17 05:31:04 2014 @@ -0,0 +1,4 @@ +SELECT '< HIVE-6386 Database should have an owner >'; + +ALTER TABLE "DBS" ADD COLUMN "OWNER_NAME" character varying(128); +ALTER TABLE "DBS" ADD COLUMN "OWNER_TYPE" character varying(10);