GPDB compatibility fixes:

When connected to a Greenplum database server
- Hide items that not work with GPDB, such as Triggers, FDW, FTS_*, etc
- Tables/Views/Catalogs/Language node can expand correctly
- Views/Languages/Catalogs can show properties dialog with correct information
- Show a greenplum icon at the server node

Teng Zhang & Hao Wang
This commit is contained in:
Teng Zhang
2017-08-30 11:18:14 +01:00
committed by Dave Page
parent 048205ead5
commit 821442ed8f
54 changed files with 938 additions and 19 deletions

View File

@@ -223,7 +223,9 @@ class LanguageView(PGChildNodeView):
self.manager = self.driver.connection_manager(kwargs['sid'])
self.conn = self.manager.connection(did=kwargs['did'])
# Set the template path for the SQL scripts
self.template_path = "languages/sql/#{0}#".format(self.manager.version)
self.template_path = ("languages/sql/#gpdb#{0}#".format(self.manager.version)
if self.manager.server_type == 'gpdb'
else "languages/sql/#{0}#".format(self.manager.version))
return f(*args, **kwargs)

View File

@@ -0,0 +1,34 @@
SELECT 'lanacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor,
array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable
FROM
(SELECT
d.grantee, d.grantor, d.is_grantable,
CASE d.privilege_type
WHEN 'USAGE' THEN 'U'
ELSE 'UNKNOWN'
END AS privilege_type
FROM
(SELECT lanacl FROM pg_language lan
LEFT OUTER JOIN pg_shdescription descr ON (lan.oid=descr.objoid AND descr.classoid='pg_language'::regclass)
WHERE lan.oid = {{ lid|qtLiteral }}::OID
) acl,
(SELECT
u_grantor.oid AS grantor,
grantee.oid AS grantee,
pr.type AS privilege_type,
aclcontains(lan1.lanacl, makeaclitem(grantee.oid, u_grantor.oid, pr.type, true)) AS is_grantable
FROM pg_language lan1, pg_authid u_grantor, (
SELECT pg_authid.oid, pg_authid.rolname
FROM pg_authid
UNION ALL
SELECT 0::oid AS oid, 'PUBLIC') grantee(oid, rolname),
(SELECT 'USAGE') pr(type)
WHERE aclcontains(lan1.lanacl, makeaclitem(grantee.oid, u_grantor.oid, pr.type, false))
AND (pg_has_role(u_grantor.oid, 'USAGE'::text) OR pg_has_role(grantee.oid, 'USAGE'::text)
OR grantee.rolname = 'PUBLIC'::name)
AND lan1.oid = {{ lid|qtLiteral }}::OID
) d
) d
LEFT JOIN pg_catalog.pg_roles g ON (d.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (d.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname

View File

@@ -0,0 +1,22 @@
SELECT
lan.oid as oid, lanname as name, lanpltrusted as trusted,
array_to_string(lanacl::text[], ', ') as acl, hp.proname as lanproc,
vp.proname as lanval, description,
pg_get_userbyid(lan.lanowner) as lanowner, ip.proname as laninl
FROM
pg_language lan JOIN pg_proc hp ON hp.oid=lanplcallfoid
LEFT OUTER JOIN pg_proc ip ON ip.oid=laninline
LEFT OUTER JOIN pg_proc vp ON vp.oid=lanvalidator
LEFT OUTER JOIN pg_description des
ON (
des.objoid=lan.oid AND des.objsubid=0 AND
des.classoid='pg_language'::regclass
)
WHERE lanispl IS TRUE
{% if lid %} AND
lan.oid={{lid}}::oid
{% endif %}
{% if lanname %} AND
lanname={{ lanname|qtLiteral }}::text
{% endif %}
ORDER BY lanname