mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-01-16 19:52:19 -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
|
||||
END AS privilege_type
|
||||
FROM
|
||||
(SELECT aclexplode(nsp.nspacl) as d
|
||||
FROM pg_namespace nsp
|
||||
WHERE nsp.oid = {{ scid|qtLiteral }}::OID
|
||||
(
|
||||
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 nsp.oid = {{ scid|qtLiteral }}::OID
|
||||
) a
|
||||
) b
|
||||
LEFT JOIN pg_catalog.pg_roles g ON (b.grantor = g.oid)
|
||||
|
@ -1,40 +1,7 @@
|
||||
SELECT
|
||||
CASE (a.deftype)
|
||||
WHEN 'r' THEN 'deftblacl'
|
||||
WHEN 'S' THEN 'defseqacl'
|
||||
WHEN 'f' THEN 'deffuncacl'
|
||||
WHEN 'T' THEN 'deftypeacl'
|
||||
ELSE 'UNKNOWN - ' || a.deftype
|
||||
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;
|
||||
'' AS deftype,
|
||||
'' AS grantee,
|
||||
'' AS grantor,
|
||||
'' AS grantor,
|
||||
'' AS privileges,
|
||||
'' AS grantable
|
||||
|
@ -13,30 +13,13 @@ SELECT
|
||||
WHEN nspname LIKE E'pg\\_%' THEN true
|
||||
ELSE false END AS is_sys_object,
|
||||
{### Default ACL for Tables ###}
|
||||
(SELECT array_to_string(ARRAY(
|
||||
SELECT array_to_string(defaclacl::text[], ', ')
|
||||
FROM pg_default_acl
|
||||
WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid
|
||||
), ', ')) AS tblacl,
|
||||
'' AS tblacl,
|
||||
{### Default ACL for Sequnces ###}
|
||||
(SELECT array_to_string(ARRAY(
|
||||
SELECT array_to_string(defaclacl::text[], ', ')
|
||||
FROM pg_default_acl
|
||||
WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid
|
||||
), ', ')) AS seqacl,
|
||||
'' AS seqacl,
|
||||
{### Default ACL for Functions ###}
|
||||
(SELECT array_to_string(ARRAY(
|
||||
SELECT array_to_string(defaclacl::text[], ', ')
|
||||
FROM pg_default_acl
|
||||
WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid
|
||||
), ', ')) AS funcacl,
|
||||
'' AS funcacl,
|
||||
{### Default ACL for Type ###}
|
||||
(SELECT array_to_string(ARRAY(
|
||||
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
|
||||
'' AS typeacl
|
||||
FROM
|
||||
pg_namespace nsp
|
||||
LEFT OUTER JOIN pg_description des ON
|
||||
|
Loading…
Reference in New Issue
Block a user