Disable ACLs for the database objects for the Greenplum due to

performance issue.

Reviewed By: Ashesh
Fixes #3415
This commit is contained in:
Joao De Almeida Pereira
2018-06-12 10:07:18 +05:30
committed by Ashesh Vashi
parent e2b0cf6727
commit e5048b4d0b
13 changed files with 86 additions and 217 deletions

View File

@@ -0,0 +1,7 @@
SELECT
'datacl' AS deftype,
'PUBLIC' AS grantee,
NULL AS grantor,
NULL AS privileges,
NULL AS grantable
LIMIT 0;

View File

@@ -0,0 +1,7 @@
SELECT
'datacl' AS deftype,
'PUBLIC' AS grantee,
NULL AS grantor,
NULL AS privileges,
NULL AS grantable
LIMIT 0;

View File

@@ -1,34 +1,7 @@
SELECT 'lanacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, SELECT
array_agg(privilege_type) as privileges, array_agg(is_grantable) as grantable 'lanacl' AS deftype,
FROM 'PUBLIC' AS grantee,
(SELECT NULL AS grantor,
d.grantee, d.grantor, d.is_grantable, NULL AS privileges,
CASE d.privilege_type NULL AS grantable
WHEN 'USAGE' THEN 'U' LIMIT 0;
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,7 @@
SELECT
'datacl' AS deftype,
'PUBLIC' AS grantee,
NULL AS grantor,
NULL AS privileges,
NULL AS grantable
LIMIT 0;

View File

@@ -1,38 +1,6 @@
SELECT SELECT
COALESCE(gt.rolname, 'PUBLIC') AS grantee, 'PUBLIC' AS grantee,
g.rolname AS grantor, array_agg(privilege_type) AS privileges, NULL AS grantor,
array_agg(is_grantable) AS grantable NULL AS privileges,
FROM NULL AS grantable
(SELECT LIMIT 0;
(d).grantee AS grantee,
(d).grantor AS grantor,
(d).is_grantable AS is_grantable,
CASE (d).privilege_type
WHEN 'EXECUTE' THEN 'X'
ELSE 'UNKNOWN' END AS privilege_type
FROM
(SELECT
u_grantor.oid AS grantor,
grantee.oid AS grantee,
pr.type AS privilege_type,
aclcontains(c.proacl, makeaclitem(grantee.oid, u_grantor.oid, pr.type, true)) AS is_grantable
FROM pg_proc c, pg_namespace nc, 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 'EXECUTE') pr(type)
WHERE c.pronamespace = nc.oid
AND (
c.proacl is NULL
OR aclcontains(c.proacl, 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 c.oid = {{ fnid }}::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,7 @@
SELECT
'relacl' AS deftype,
'PUBLIC' AS grantee,
NULL AS grantor,
NULL AS privileges,
NULL AS grantable
LIMIT 0;

View File

@@ -0,0 +1,7 @@
SELECT
'attacl' AS deftype,
'PUBLIC' AS grantee,
NULL AS grantor,
NULL AS privileges,
NULL AS grantable
LIMIT 0;

View File

@@ -0,0 +1,7 @@
SELECT
'relacl' AS deftype,
'PUBLIC' AS grantee,
NULL AS grantor,
NULL AS privileges,
NULL AS grantable
LIMIT 0;

View File

@@ -1,38 +1,7 @@
{# Fetch privileges for schema #}
SELECT SELECT
'nspacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') AS grantee, 'nspacl' AS deftype,
g.rolname AS grantor, array_agg(b.privilege_type) AS privileges, 'PUBLIC' AS grantee,
array_agg(b.is_grantable) AS grantable NULL AS grantor,
FROM NULL AS privileges,
(SELECT NULL AS grantable
(d).grantee AS grantee, (d).grantor AS grantor, LIMIT 0;
(d).is_grantable AS is_grantable,
CASE (d).privilege_type
WHEN 'CREATE' THEN 'C'
WHEN 'USAGE' THEN 'U'
ELSE 'UNKNOWN - ' || (d).privilege_type
END AS privilege_type
FROM
(
SELECT
u_grantor.oid AS grantor,
grantee.oid AS grantee,
pr.type AS privilege_type,
aclcontains(nc.nspacl, makeaclitem(grantee.oid, u_grantor.oid, pr.type, true)) AS is_grantable
FROM pg_namespace nc, 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 'CREATE'
UNION ALL
SELECT 'USAGE') pr(type)
WHERE aclcontains(nc.nspacl, 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 nc.oid = {{ scid|qtLiteral }}::OID
) a
) b
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (b.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname;

View File

@@ -1,38 +1,7 @@
{# Fetch privileges for schema #}
SELECT SELECT
'nspacl' as deftype, COALESCE(gt.rolname, 'PUBLIC') AS grantee, 'nspacl' AS deftype,
g.rolname AS grantor, array_agg(b.privilege_type) AS privileges, 'PUBLIC' AS grantee,
array_agg(b.is_grantable) AS grantable NULL AS grantor,
FROM NULL AS privileges,
(SELECT NULL AS grantable
(a).grantee AS grantee, (a).grantor AS grantor, LIMIT 0;
(a).is_grantable AS is_grantable,
CASE (a).privilege_type
WHEN 'CREATE' THEN 'C'
WHEN 'USAGE' THEN 'U'
ELSE 'UNKNOWN - ' || (a).privilege_type
END AS privilege_type
FROM
(
SELECT
u_grantor.oid AS grantor,
grantee.oid AS grantee,
pr.type AS privilege_type,
aclcontains(nc.nspacl, makeaclitem(grantee.oid, u_grantor.oid, pr.type, true)) AS is_grantable
FROM pg_namespace nc, 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 'CREATE'
UNION ALL
SELECT 'USAGE') pr(type)
WHERE aclcontains(nc.nspacl, 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 nc.oid = {{ scid|qtLiteral }}::OID
) a
) b
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
LEFT JOIN pg_catalog.pg_roles gt ON (b.grantee = gt.oid)
GROUP BY g.rolname, gt.rolname;

View File

@@ -1,74 +1,8 @@
{# ============================ Get ACLs ========================= #} {# ============================ Get ACLs ========================= #}
{% if vid %}
SELECT SELECT
'datacl' as deftype, 'datacl' AS deftype,
COALESCE(gt.rolname, 'PUBLIC') grantee, 'PUBLIC' AS grantee,
g.rolname grantor, NULL AS grantor,
array_agg(privilege_type) as privileges, NULL AS privileges,
array_agg(is_grantable) as grantable NULL AS grantable
FROM LIMIT 0;
(SELECT
d.grantee, d.grantor, d.is_grantable,
CASE d.privilege_type
WHEN 'DELETE' THEN 'd'
WHEN 'INSERT' THEN 'a'
WHEN 'REFERENCES' THEN 'x'
WHEN 'SELECT' THEN 'r'
WHEN 'TRIGGER' THEN 't'
WHEN 'UPDATE' THEN 'w'
WHEN 'TRUNCATE' THEN 'D'
ELSE 'UNKNOWN'
END AS privilege_type
FROM
(SELECT
relacl
FROM
pg_class cl
LEFT OUTER JOIN pg_shdescription descr ON (
cl.oid=descr.objoid AND descr.classoid='pg_class'::regclass)
WHERE
cl.oid = {{ vid }}::OID AND relkind = 'v'
) acl,
(SELECT
(d).grantee AS grantee,
(d).grantor AS grantor,
(d).is_grantable AS is_grantable,
(d).privilege_type AS privilege_type
FROM
(SELECT
u_grantor.oid AS grantor,
grantee.oid AS grantee,
pr.type AS privilege_type,
aclcontains(c.relacl, makeaclitem(grantee.oid, u_grantor.oid, pr.type, true)) AS is_grantable
FROM pg_class c, pg_namespace nc, 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 'SELECT'
UNION ALL
SELECT 'INSERT'
UNION ALL
SELECT 'UPDATE'
UNION ALL
SELECT 'DELETE'
UNION ALL
SELECT 'TRUNCATE'
UNION ALL
SELECT 'REFERENCES'
UNION ALL
SELECT 'TRIGGER') pr(type)
WHERE c.relnamespace = nc.oid
AND (c.relkind = ANY (ARRAY['r'::"char", 'v'::"char"]))
AND aclcontains(c.relacl, 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 c.oid = {{ vid }}
) d
) 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
{% endif %}

View File

@@ -0,0 +1,7 @@
SELECT
'datacl' AS deftype,
'PUBLIC' AS grantee,
NULL AS grantor,
NULL AS privileges,
NULL AS grantable
LIMIT 0;

View File

@@ -0,0 +1,7 @@
SELECT
'spcacl' AS deftype,
'PUBLIC' AS grantee,
NULL AS grantor,
NULL AS privileges,
NULL AS grantable
LIMIT 0;