Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sql: add pg_catalog.pg_default_acl #26378

Closed
BramGruneir opened this issue Jun 4, 2018 · 3 comments · Fixed by #38869
Closed

sql: add pg_catalog.pg_default_acl #26378

BramGruneir opened this issue Jun 4, 2018 · 3 comments · Fixed by #38869
Assignees
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

Comments

@BramGruneir
Copy link
Member

BramGruneir commented Jun 4, 2018

Note: this vtable is empty on pg by default.

PGAdmin issues the following query:

SELECT db.oid AS did,
       db.datname AS name,
       db.dattablespace AS spcoid,
       spcname,
       datallowconn,
       pg_encoding_to_char(encoding) AS encoding,
       pg_get_userbyid(datdba) AS datowner,
       datcollate,
       datctype,
       datconnlimit,
       has_database_privilege(db.oid, 'CREATE') AS cancreate,
       current_setting('default_tablespace') AS default_tablespace,
       descr.description AS comments,
       db.datistemplate AS is_template,
       (
         SELECT array_to_string(ARRAY (
          SELECT array_to_string(defaclacl::TEXT[], ', ')
          FROM pg_default_acl
          WHERE (defaclobjtype = 'r')
            AND (defaclnamespace = 0::OID)
         ), ', ')
        ) AS tblacl,
        (
          SELECT array_to_string(ARRAY (
            SELECT array_to_string(defaclacl::TEXT[], ', ')
            FROM pg_default_acl
            WHERE (defaclobjtype = 'S')
              AND (defaclnamespace = 0::OID)
          ), ', ')
        ) AS seqacl,
        (
          SELECT array_to_string(ARRAY (
            SELECT array_to_string(defaclacl::TEXT[], ', ')
            FROM pg_default_acl
            WHERE (defaclobjtype = 'f')
              AND (defaclnamespace = 0::OID)
          ), ', ')
        ) AS funcacl,
        (
          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 AS sl1
          WHERE sl1.objoid = db.oid
        ) AS seclabels,
        array_to_string(datacl::TEXT[], ', ') AS acl
FROM pg_database AS db
LEFT JOIN pg_tablespace AS ta
  ON db.dattablespace = ta.oid
LEFT JOIN pg_shdescription AS descr
  ON ((db.oid = descr.objoid) AND (descr.classoid = 'pg_database'::REGCLASS))
WHERE db.oid > NULL::OID
ORDER BY datname

Details can be found here: https://www.postgresql.org/docs/current/static/catalog-pg-default-acl.html

@BramGruneir BramGruneir added the A-sql-pgcompat Semantic compatibility with PostgreSQL label Jun 4, 2018
@BramGruneir BramGruneir added this to the 2.1 milestone Jun 4, 2018
@BramGruneir BramGruneir self-assigned this Jun 4, 2018
@knz knz mentioned this issue Jun 4, 2018
25 tasks
@knz knz changed the title sql: add pg_default_acl sql: add pg_catalog.pg_default_acl Jun 5, 2018
@knz knz added the C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) label Jul 21, 2018
@knz knz modified the milestones: 2.1, 2.2 Aug 30, 2018
@petermattis petermattis removed this from the 2.2 milestone Oct 5, 2018
@awoods187
Copy link
Contributor

@jordanlewis what's the level of effort to support this? It's a blocker to using PgAdmin
image

@jordanlewis
Copy link
Member

Low level of effort, but pgadmin won't nearly be usable after we fix this.

@BramGruneir
Copy link
Member Author

BramGruneir commented Apr 26, 2019 via email

craig bot pushed a commit that referenced this issue Jul 19, 2019
38869: sql: compatibility blitz for pgadmin r=jordanlewis a=jordanlewis

A bunch of small improvements to the catalog, new builtins, and a couple of typing improvements all in the name of making pgadmin work.

And it works okay now! Definitely still some flaws and unsupported things, but at least the default experience isn't completely broken anymore.

Closes #33341.
Closes #23299.
Closes #26389.
Closes #26378.
Closes #26390.
Closes #24747.
Closes #37124.
Updates #25213.

![image](https://user-images.githubusercontent.com/43821/61190353-f17fb980-a668-11e9-947f-d1bc3bb1e75d.png)

Co-authored-by: Jordan Lewis <jordanthelewis@gmail.com>
@craig craig bot closed this as completed in #38869 Jul 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-sql-pgcompat Semantic compatibility with PostgreSQL C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants