Fix an issue where several default privileges cause error on database. Fixes #1670

pull/3/head
Murtuza Zabuawala 2016-09-16 16:06:29 +01:00 committed by Dave Page
parent 92bc312d2d
commit c5f04d03c6
7 changed files with 152 additions and 27 deletions

View File

@ -12,9 +12,24 @@ SELECT
CASE
WHEN nspname LIKE E'pg\\_%' THEN true
ELSE false END AS is_sys_object,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl,
{### 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,
{### 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,
{### 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,
(SELECT array_agg(provider || '=' || label) FROM pg_seclabels sl1 WHERE sl1.objoid=nsp.oid) AS seclabels
FROM
pg_namespace nsp

View File

@ -12,10 +12,30 @@ SELECT
CASE
WHEN nspname LIKE E'pg\\_%' THEN true
ELSE false END AS is_sys_object,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid) AS typeacl,
{### 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,
{### 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,
{### 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,
{### 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
FROM
pg_namespace nsp

View File

@ -12,9 +12,24 @@ SELECT
CASE
WHEN nspname LIKE E'pg\\_%' THEN true
ELSE false END AS is_sys_object,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl
{### 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,
{### 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,
{### 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
FROM
pg_namespace nsp
LEFT OUTER JOIN pg_description des ON

View File

@ -12,10 +12,30 @@ SELECT
CASE
WHEN nspname LIKE E'pg\\_%' THEN true
ELSE false END AS is_sys_object,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = nsp.oid) AS tblacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = nsp.oid) AS seqacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = nsp.oid) AS funcacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = nsp.oid) AS typeacl
{### 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,
{### 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,
{### 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,
{### 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
FROM
pg_namespace nsp
LEFT OUTER JOIN pg_description des ON

View File

@ -5,9 +5,24 @@ SELECT
has_database_privilege(db.oid, 'CREATE') as cancreate,
current_setting('default_tablespace') AS default_tablespace,
descr.description as comments,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID) AS tblacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = 0::OID) AS seqacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = 0::OID) AS funcacl,
{### Default ACL for Tables ###}
(SELECT array_to_string(ARRAY(
SELECT array_to_string(defaclacl::text[], ', ')
FROM pg_default_acl
WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID
), ', ')) 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 = 0::OID
), ', ')) 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 = 0::OID
), ', ')) AS funcacl,
array_to_string(datacl::text[], ', ') AS acl
FROM pg_database db
LEFT OUTER JOIN pg_tablespace ta ON db.dattablespace=ta.OID

View File

@ -5,10 +5,30 @@ SELECT
has_database_privilege(db.oid, 'CREATE') as cancreate,
current_setting('default_tablespace') AS default_tablespace,
descr.description as comments,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID) AS tblacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = 0::OID) AS seqacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = 0::OID) AS funcacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = 0::OID) AS typeacl,
{### Default ACL for Tables ###}
(SELECT array_to_string(ARRAY(
SELECT array_to_string(defaclacl::text[], ', ')
FROM pg_default_acl
WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID
), ', ')) 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 = 0::OID
), ', ')) 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 = 0::OID
), ', ')) 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 = 0::OID
), ', ')) AS typeacl,
(SELECT array_agg(provider || '=' || label) FROM pg_shseclabel sl1 WHERE sl1.objoid=db.oid) AS seclabels,
array_to_string(datacl::text[], ', ') AS acl
FROM pg_database db
@ -22,4 +42,4 @@ db.datname = {{ name|qtLiteral }}::text{% else %}
db.oid > {{ last_system_oid|qtLiteral }}::OID
{% endif %}{% endif %}
ORDER BY datname
ORDER BY datname;

View File

@ -5,10 +5,30 @@ SELECT
has_database_privilege(db.oid, 'CREATE') as cancreate,
current_setting('default_tablespace') AS default_tablespace,
descr.description as comments,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID) AS tblacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'S' AND defaclnamespace = 0::OID) AS seqacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'f' AND defaclnamespace = 0::OID) AS funcacl,
(SELECT array_to_string(defaclacl::text[], ', ') FROM pg_default_acl WHERE defaclobjtype = 'T' AND defaclnamespace = 0::OID) AS typeacl,
{### Default ACL for Tables ###}
(SELECT array_to_string(ARRAY(
SELECT array_to_string(defaclacl::text[], ', ')
FROM pg_default_acl
WHERE defaclobjtype = 'r' AND defaclnamespace = 0::OID
), ', ')) 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 = 0::OID
), ', ')) 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 = 0::OID
), ', ')) 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 = 0::OID
), ', ')) AS typeacl,
(SELECT array_agg(provider || '=' || label) FROM pg_shseclabel sl1 WHERE sl1.objoid=db.oid) AS seclabels,
array_to_string(datacl::text[], ', ') AS acl
FROM pg_database db
@ -22,4 +42,4 @@ db.datname = {{ name|qtLiteral }}::text{% else %}
db.oid > {{ last_system_oid|qtLiteral }}::OID
{% endif %}{% endif %}
ORDER BY datname
ORDER BY datname;