hawq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hubertzh...@apache.org
Subject incubator-hawq git commit: HAWQ-1356. Add waring when user does not have usage privilege of namespace.
Date Thu, 23 Feb 2017 08:41:27 GMT
Repository: incubator-hawq
Updated Branches:
  refs/heads/master b37f18768 -> fada5f0b2


HAWQ-1356. Add waring when user does not have usage privilege of namespace.

Signed-off-by: Hubert Zhang <hubertzhang@apache.org>


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

Branch: refs/heads/master
Commit: fada5f0b28029af783dffddaa45a5cceb647584a
Parents: b37f187
Author: Chuling Wang <wangchunling14@126.com>
Authored: Thu Feb 23 16:40:33 2017 +0800
Committer: Hubert Zhang <hubertzhang@apache.org>
Committed: Thu Feb 23 16:40:33 2017 +0800

----------------------------------------------------------------------
 src/backend/catalog/namespace.c | 36 ++++++++++++++++++++++++++++--------
 1 file changed, 28 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/fada5f0b/src/backend/catalog/namespace.c
----------------------------------------------------------------------
diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c
index e67570e..3a90054 100644
--- a/src/backend/catalog/namespace.c
+++ b/src/backend/catalog/namespace.c
@@ -167,6 +167,7 @@ char	   *namespace_search_path = NULL;
 
 /* Local functions */
 static void recomputeNamespacePath(void);
+static void checkNamespaceInternal(List **oidlist, Oid namespaceId, Oid roleid);
 static void InitTempTableNamespace(void);
 static void RemoveTempRelations(Oid tempNamespaceId);
 static void RemoveTempRelationsCallback(int code, Datum arg);
@@ -1925,6 +1926,25 @@ FindDefaultConversionProc(int4 for_encoding, int4 to_encoding)
 	return InvalidOid;
 }
 
+
+
+/*
+ *
+ */
+static void checkNamespaceInternal(List **oidlist, Oid namespaceId, Oid roleid)
+{
+	if (pg_namespace_aclcheck(namespaceId, roleid,
+			ACL_USAGE) == ACLCHECK_OK)
+	{
+		*oidlist = lappend_oid(*oidlist, namespaceId);
+	}
+	else {
+		if (OidIsValid(namespaceId)) {
+			elog(WARNING, "usage privilege of namespace %s is required.",
+					getNamespaceNameByOid(namespaceId));
+		}
+	}
+}
 /*
  * recomputeNamespacePath - recompute path derived variables if needed.
  */
@@ -2006,10 +2026,10 @@ recomputeNamespacePath(void)
 				namespaceId = LookupInternalNamespaceId(rname);
 
 				if (OidIsValid(namespaceId) &&
-					!list_member_oid(oidlist, namespaceId) &&
-					pg_namespace_aclcheck(namespaceId, roleid,
-										  ACL_USAGE) == ACLCHECK_OK)
-					oidlist = lappend_oid(oidlist, namespaceId);
+						!list_member_oid(oidlist, namespaceId))
+				{
+					checkNamespaceInternal(&oidlist, namespaceId, roleid);
+				}
 			}
 		}
 		else if (strcmp(curname, "pg_temp") == 0)
@@ -2034,10 +2054,10 @@ recomputeNamespacePath(void)
 			namespaceId = LookupInternalNamespaceId(curname);
 
 			if (OidIsValid(namespaceId) &&
-				!list_member_oid(oidlist, namespaceId) &&
-				pg_namespace_aclcheck(namespaceId, roleid,
-									  ACL_USAGE) == ACLCHECK_OK)
-				oidlist = lappend_oid(oidlist, namespaceId);
+				!list_member_oid(oidlist, namespaceId))
+			{
+				checkNamespaceInternal(&oidlist, namespaceId, roleid);
+			}
 		}
 	}
 


Mime
View raw message