mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
Correctly display SQL of multiple objects on the SQL tab in GPDB.
This commit is contained in:
parent
ca80cfa04a
commit
284adbbb90
@ -13,9 +13,24 @@ FROM
|
|||||||
ELSE 'UNKNOWN - ' || (d).privilege_type
|
ELSE 'UNKNOWN - ' || (d).privilege_type
|
||||||
END AS privilege_type
|
END AS privilege_type
|
||||||
FROM
|
FROM
|
||||||
(SELECT aclexplode(nsp.nspacl) as d
|
(
|
||||||
FROM pg_namespace nsp
|
SELECT
|
||||||
WHERE nsp.oid = {{ scid|qtLiteral }}::OID
|
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 nsp.oid = {{ scid|qtLiteral }}::OID
|
||||||
) a
|
) a
|
||||||
) b
|
) b
|
||||||
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
|
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
|
||||||
|
@ -1,40 +1,7 @@
|
|||||||
SELECT
|
SELECT
|
||||||
CASE (a.deftype)
|
'' AS deftype,
|
||||||
WHEN 'r' THEN 'deftblacl'
|
'' AS grantee,
|
||||||
WHEN 'S' THEN 'defseqacl'
|
'' AS grantor,
|
||||||
WHEN 'f' THEN 'deffuncacl'
|
'' AS grantor,
|
||||||
WHEN 'T' THEN 'deftypeacl'
|
'' AS privileges,
|
||||||
ELSE 'UNKNOWN - ' || a.deftype
|
'' AS grantable
|
||||||
END AS deftype,
|
|
||||||
COALESCE(gt.rolname, 'PUBLIC') grantee, g.rolname grantor, array_agg(a.privilege_type) as privileges, array_agg(a.is_grantable) as grantable
|
|
||||||
FROM
|
|
||||||
(SELECT
|
|
||||||
(acl).grantee as grantee, (acl).grantor AS grantor, (acl).is_grantable AS is_grantable,
|
|
||||||
CASE (acl).privilege_type
|
|
||||||
WHEN 'CONNECT' THEN 'c'
|
|
||||||
WHEN 'CREATE' THEN 'C'
|
|
||||||
WHEN 'DELETE' THEN 'd'
|
|
||||||
WHEN 'EXECUTE' THEN 'X'
|
|
||||||
WHEN 'INSERT' THEN 'a'
|
|
||||||
WHEN 'REFERENCES' THEN 'x'
|
|
||||||
WHEN 'SELECT' THEN 'r'
|
|
||||||
WHEN 'TEMPORARY' THEN 'T'
|
|
||||||
WHEN 'TRIGGER' THEN 't'
|
|
||||||
WHEN 'TRUNCATE' THEN 'D'
|
|
||||||
WHEN 'UPDATE' THEN 'w'
|
|
||||||
WHEN 'USAGE' THEN 'U'
|
|
||||||
ELSE 'UNKNOWN - ' || (acl).privilege_type
|
|
||||||
END AS privilege_type,
|
|
||||||
defaclobjtype as deftype
|
|
||||||
FROM
|
|
||||||
(SELECT defaclobjtype, aclexplode(defaclacl) as acl
|
|
||||||
FROM
|
|
||||||
pg_namespace nsp
|
|
||||||
LEFT OUTER JOIN pg_catalog.pg_default_acl dacl ON (dacl.defaclnamespace = nsp.oid)
|
|
||||||
WHERE
|
|
||||||
nsp.oid={{scid}}::oid
|
|
||||||
) d) a
|
|
||||||
LEFT JOIN pg_catalog.pg_roles g ON (a.grantor = g.oid)
|
|
||||||
LEFT JOIN pg_catalog.pg_roles gt ON (a.grantee = gt.oid)
|
|
||||||
GROUP BY g.rolname, gt.rolname, a.deftype
|
|
||||||
ORDER BY a.deftype;
|
|
||||||
|
@ -13,30 +13,13 @@ SELECT
|
|||||||
WHEN nspname LIKE E'pg\\_%' THEN true
|
WHEN nspname LIKE E'pg\\_%' THEN true
|
||||||
ELSE false END AS is_sys_object,
|
ELSE false END AS is_sys_object,
|
||||||
{### Default ACL for Tables ###}
|
{### Default ACL for Tables ###}
|
||||||
(SELECT array_to_string(ARRAY(
|
'' AS tblacl,
|
||||||
SELECT array_to_string(defaclacl::text[], ', ')
|
|
||||||
FROM pg_default_acl
|
|
||||||
WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid
|
|
||||||
), ', ')) AS tblacl,
|
|
||||||
{### Default ACL for Sequnces ###}
|
{### Default ACL for Sequnces ###}
|
||||||
(SELECT array_to_string(ARRAY(
|
'' AS seqacl,
|
||||||
SELECT array_to_string(defaclacl::text[], ', ')
|
|
||||||
FROM pg_default_acl
|
|
||||||
WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid
|
|
||||||
), ', ')) AS seqacl,
|
|
||||||
{### Default ACL for Functions ###}
|
{### Default ACL for Functions ###}
|
||||||
(SELECT array_to_string(ARRAY(
|
'' AS funcacl,
|
||||||
SELECT array_to_string(defaclacl::text[], ', ')
|
|
||||||
FROM pg_default_acl
|
|
||||||
WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid
|
|
||||||
), ', ')) AS funcacl,
|
|
||||||
{### Default ACL for Type ###}
|
{### Default ACL for Type ###}
|
||||||
(SELECT array_to_string(ARRAY(
|
'' AS typeacl
|
||||||
SELECT array_to_string(defaclacl::text[], ', ')
|
|
||||||
FROM pg_default_acl
|
|
||||||
WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid
|
|
||||||
), ', ')) AS typeacl,
|
|
||||||
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels
|
|
||||||
FROM
|
FROM
|
||||||
pg_namespace nsp
|
pg_namespace nsp
|
||||||
LEFT OUTER JOIN pg_description des ON
|
LEFT OUTER JOIN pg_description des ON
|
||||||
|
Loading…
Reference in New Issue
Block a user