hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hashut...@apache.org
Subject svn commit: r1582137 - in /hive/branches/branch-0.13: metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java ql/src/test/queries/clientpositive/authorization_9.q ql/src/test/results/clientpositive/authorization_9.q.out
Date Thu, 27 Mar 2014 00:12:42 GMT
Author: hashutosh
Date: Thu Mar 27 00:12:41 2014
New Revision: 1582137

URL: http://svn.apache.org/r1582137
Log:
HIVE-6674 : show grant on all throws NPE (Navis via Ashutosh Chauhan)

Modified:
    hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
    hive/branches/branch-0.13/ql/src/test/queries/clientpositive/authorization_9.q
    hive/branches/branch-0.13/ql/src/test/results/clientpositive/authorization_9.q.out

Modified: hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java?rev=1582137&r1=1582136&r2=1582137&view=diff
==============================================================================
--- hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
(original)
+++ hive/branches/branch-0.13/metastore/src/java/org/apache/hadoop/hive/metastore/ObjectStore.java
Thu Mar 27 00:12:41 2014
@@ -4146,11 +4146,11 @@ public class ObjectStore implements RawS
     try {
       openTransaction();
       LOG.debug("Executing listPrincipalDBGrants");
-      Query query = pm.newQuery(MDBPrivilege.class,
-          "principalName == t1 && principalType == t2 && database.name ==
t3");
-      query
-          .declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String
t3");
-      mSecurityDBList = (List<MDBPrivilege>) query.executeWithArray(principalName,
principalType.toString(), dbName);
+        Query query = pm.newQuery(MDBPrivilege.class,
+            "principalName == t1 && principalType == t2 && database.name
== t3");
+        query
+            .declareParameters("java.lang.String t1, java.lang.String t2, java.lang.String
t3");
+        mSecurityDBList = (List<MDBPrivilege>) query.executeWithArray(principalName,
principalType.toString(), dbName);
       LOG.debug("Done executing query for listPrincipalDBGrants");
       pm.retrieveAll(mSecurityDBList);
       success = commitTransaction();
@@ -4199,11 +4199,16 @@ public class ObjectStore implements RawS
     try {
       openTransaction();
       LOG.debug("Executing listPrincipalAllDBGrant");
-      Query query = pm.newQuery(MDBPrivilege.class,
-          "principalName == t1 && principalType == t2");
-      query
-          .declareParameters("java.lang.String t1, java.lang.String t2");
-      mSecurityDBList = (List<MDBPrivilege>) query.execute(principalName, principalType.toString());
+      if (principalName != null && principalType != null) {
+        Query query = pm.newQuery(MDBPrivilege.class,
+            "principalName == t1 && principalType == t2");
+        query
+            .declareParameters("java.lang.String t1, java.lang.String t2");
+        mSecurityDBList = (List<MDBPrivilege>) query.execute(principalName, principalType.toString());
+      } else {
+        Query query = pm.newQuery(MDBPrivilege.class);
+        mSecurityDBList = (List<MDBPrivilege>) query.execute();
+      }
       LOG.debug("Done executing query for listPrincipalAllDBGrant");
       pm.retrieveAll(mSecurityDBList);
       success = commitTransaction();
@@ -4604,11 +4609,17 @@ public class ObjectStore implements RawS
     try {
       openTransaction();
       LOG.debug("Executing listPrincipalPartitionColumnGrantsAll");
-      Query query = pm.newQuery(MPartitionColumnPrivilege.class,
-          "principalName == t1 && principalType == t2");
-      query.declareParameters("java.lang.String t1, java.lang.String t2");
-      List<MPartitionColumnPrivilege> mSecurityTabPartList = (List<MPartitionColumnPrivilege>)
-          query.executeWithArray(principalName, principalType.toString());
+      List<MPartitionColumnPrivilege> mSecurityTabPartList;
+      if (principalName != null && principalType != null) {
+        Query query = pm.newQuery(MPartitionColumnPrivilege.class,
+            "principalName == t1 && principalType == t2");
+        query.declareParameters("java.lang.String t1, java.lang.String t2");
+        mSecurityTabPartList = (List<MPartitionColumnPrivilege>)
+            query.executeWithArray(principalName, principalType.toString());
+      } else {
+        Query query = pm.newQuery(MPartitionColumnPrivilege.class);
+        mSecurityTabPartList = (List<MPartitionColumnPrivilege>) query.execute();
+      }
       LOG.debug("Done executing query for listPrincipalPartitionColumnGrantsAll");
       pm.retrieveAll(mSecurityTabPartList);
       List<HiveObjectPrivilege> result = convertPartCols(mSecurityTabPartList);
@@ -4703,11 +4714,17 @@ public class ObjectStore implements RawS
     try {
       openTransaction();
       LOG.debug("Executing listPrincipalAllTableGrants");
-      Query query = pm.newQuery(MTablePrivilege.class,
-          "principalName == t1 && principalType == t2");
-      query.declareParameters("java.lang.String t1, java.lang.String t2");
-      List<MTablePrivilege> mSecurityTabPartList = (List<MTablePrivilege>) query.execute(
-          principalName, principalType.toString());
+      List<MTablePrivilege> mSecurityTabPartList;
+      if (principalName != null && principalType != null) {
+        Query query = pm.newQuery(MTablePrivilege.class,
+            "principalName == t1 && principalType == t2");
+        query.declareParameters("java.lang.String t1, java.lang.String t2");
+        mSecurityTabPartList = (List<MTablePrivilege>) query.execute(
+            principalName, principalType.toString());
+      } else {
+        Query query = pm.newQuery(MTablePrivilege.class);
+        mSecurityTabPartList = (List<MTablePrivilege>) query.execute();
+      }
       LOG.debug("Done executing query for listPrincipalAllTableGrants");
       pm.retrieveAll(mSecurityTabPartList);
       List<HiveObjectPrivilege> result = convertTable(mSecurityTabPartList);
@@ -4798,11 +4815,17 @@ public class ObjectStore implements RawS
     try {
       openTransaction();
       LOG.debug("Executing listPrincipalPartitionGrantsAll");
-      Query query = pm.newQuery(MPartitionPrivilege.class,
-          "principalName == t1 && principalType == t2");
-      query.declareParameters("java.lang.String t1, java.lang.String t2");
-      List<MPartitionPrivilege> mSecurityTabPartList = (List<MPartitionPrivilege>)
-          query.execute(principalName, principalType.toString());
+      List<MPartitionPrivilege> mSecurityTabPartList;
+      if (principalName != null && principalType != null) {
+        Query query = pm.newQuery(MPartitionPrivilege.class,
+            "principalName == t1 && principalType == t2");
+        query.declareParameters("java.lang.String t1, java.lang.String t2");
+        mSecurityTabPartList = (List<MPartitionPrivilege>)
+            query.execute(principalName, principalType.toString());
+      } else {
+        Query query = pm.newQuery(MPartitionPrivilege.class);
+        mSecurityTabPartList = (List<MPartitionPrivilege>) query.execute();
+      }
       LOG.debug("Done executing query for listPrincipalPartitionGrantsAll");
       pm.retrieveAll(mSecurityTabPartList);
       List<HiveObjectPrivilege> result = convertPartition(mSecurityTabPartList);
@@ -4895,11 +4918,18 @@ public class ObjectStore implements RawS
     try {
       openTransaction();
       LOG.debug("Executing listPrincipalTableColumnGrantsAll");
-      Query query = pm.newQuery(MTableColumnPrivilege.class,
-          "principalName == t1 && principalType == t2");
-      query.declareParameters("java.lang.String t1, java.lang.String t2");
-      List<MTableColumnPrivilege> mSecurityTabPartList = (List<MTableColumnPrivilege>)
-          query.execute(principalName, principalType.toString());
+
+      List<MTableColumnPrivilege> mSecurityTabPartList;
+      if (principalName != null && principalType != null) {
+        Query query = pm.newQuery(MTableColumnPrivilege.class,
+            "principalName == t1 && principalType == t2");
+        query.declareParameters("java.lang.String t1, java.lang.String t2");
+        mSecurityTabPartList = (List<MTableColumnPrivilege>)
+            query.execute(principalName, principalType.toString());
+      } else {
+        Query query = pm.newQuery(MTableColumnPrivilege.class);
+        mSecurityTabPartList = (List<MTableColumnPrivilege>) query.execute();
+      }
       LOG.debug("Done executing query for listPrincipalTableColumnGrantsAll");
       pm.retrieveAll(mSecurityTabPartList);
       List<HiveObjectPrivilege> result = convertTableCols(mSecurityTabPartList);

Modified: hive/branches/branch-0.13/ql/src/test/queries/clientpositive/authorization_9.q
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/test/queries/clientpositive/authorization_9.q?rev=1582137&r1=1582136&r2=1582137&view=diff
==============================================================================
--- hive/branches/branch-0.13/ql/src/test/queries/clientpositive/authorization_9.q (original)
+++ hive/branches/branch-0.13/ql/src/test/queries/clientpositive/authorization_9.q Thu Mar
27 00:12:41 2014
@@ -9,3 +9,9 @@ grant select (key, value) on table dummy
 show grant user hive_test_user on database default;
 show grant user hive_test_user on table dummy;
 show grant user hive_test_user on all;
+
+grant select on database default to user hive_test_user2;
+grant select on table dummy to user hive_test_user2;
+grant select (key, value) on table dummy to user hive_test_user2;
+
+show grant on all;

Modified: hive/branches/branch-0.13/ql/src/test/results/clientpositive/authorization_9.q.out
URL: http://svn.apache.org/viewvc/hive/branches/branch-0.13/ql/src/test/results/clientpositive/authorization_9.q.out?rev=1582137&r1=1582136&r2=1582137&view=diff
==============================================================================
--- hive/branches/branch-0.13/ql/src/test/results/clientpositive/authorization_9.q.out (original)
+++ hive/branches/branch-0.13/ql/src/test/results/clientpositive/authorization_9.q.out Thu
Mar 27 00:12:41 2014
@@ -43,3 +43,31 @@ default				hive_test_user	USER	Select	fa
 default	dummy			hive_test_user	USER	Select	false	-1	hive_test_user
 default	dummy		key	hive_test_user	USER	Select	false	-1	hive_test_user
 default	dummy		value	hive_test_user	USER	Select	false	-1	hive_test_user
+PREHOOK: query: grant select on database default to user hive_test_user2
+PREHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: query: grant select on database default to user hive_test_user2
+POSTHOOK: type: GRANT_PRIVILEGE
+PREHOOK: query: grant select on table dummy to user hive_test_user2
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@dummy
+POSTHOOK: query: grant select on table dummy to user hive_test_user2
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@dummy
+PREHOOK: query: grant select (key, value) on table dummy to user hive_test_user2
+PREHOOK: type: GRANT_PRIVILEGE
+PREHOOK: Output: default@dummy
+POSTHOOK: query: grant select (key, value) on table dummy to user hive_test_user2
+POSTHOOK: type: GRANT_PRIVILEGE
+POSTHOOK: Output: default@dummy
+PREHOOK: query: show grant on all
+PREHOOK: type: SHOW_GRANT
+POSTHOOK: query: show grant on all
+POSTHOOK: type: SHOW_GRANT
+default				hive_test_user	USER	Select	false	-1	hive_test_user
+default				hive_test_user2	USER	Select	false	-1	hive_test_user
+default	dummy			hive_test_user	USER	Select	false	-1	hive_test_user
+default	dummy			hive_test_user2	USER	Select	false	-1	hive_test_user
+default	dummy		key	hive_test_user	USER	Select	false	-1	hive_test_user
+default	dummy		key	hive_test_user2	USER	Select	false	-1	hive_test_user
+default	dummy		value	hive_test_user	USER	Select	false	-1	hive_test_user
+default	dummy		value	hive_test_user2	USER	Select	false	-1	hive_test_user



Mime
View raw message