Re: [patch] psql tab completion for ALTER DEFAULT PRIVILEGES

From: Gilles Darold <gilles(dot)darold(at)dalibo(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: [patch] psql tab completion for ALTER DEFAULT PRIVILEGES
Date: 2016-11-28 08:16:31
Message-ID: 9905474c-ab29-bb66-408f-ca776fb3d69c@dalibo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Le 20/11/2016 à 15:46, Gilles Darold a écrit :
> Hi,
>
> When tab-completing after ALTER DEFAULT PRIVILEGES ... GRANT|REVOKE,
> currently psql injects completion from the GRANT|REVOKE order, rather
> than the one expected.
>
> A patch is attached. It adds the right completion to GRANT|REVOKE after
> ALTER DEFAULT PRIVILEGES and after FOR ROLE|USER + IN SCHEMA.
>
> If there's no objection I will add it to next commit fest.
>
> Best regards,

Added to next commitfest. To explain more this patch, the completion of
SQL command:

ALTER DEFAULT PRIVILEGES FOR ROLE xxx [tab]

propose:

GRANT REVOKE

and it should also propose IN SCHEMA. Same with ALTER DEFAULT PRIVILEGES
IN SCHEMA it should propose FOR ROLE. For example:

gilles=# ALTER DEFAULT PRIVILEGES IN SCHEMA public FOR ROLE user1 GRANT
ALL ON TABLES TO user2;
ALTER DEFAULT PRIVILEGES

is valid but current completion doesn't help.

The second issue addressed is the completion after GRANT|REVOKE, which
show completion for the GRANT|REVOKE command but the element are not the
same in the ALTER DEFAULT PRIVILEGES command.

I mean completion on command

ALTER DEFAULT PRIVILEGES IN SCHEMA public FOR ROLE user1 GRANT ALL [tab]

propose the following keywords:

ALL FUNCTIONS IN SCHEMA
ALL SEQUENCES IN SCHEMA
DOMAIN
LANGUAGE
LARGE OBJECT
TABLE
TABLESPACE
ALL TABLES IN SCHEMA
FOREIGN DATA WRAPPER
FOREIGN SERVER
SCHEMA
FUNCTION
SEQUENCE
TYPE
DATABASE

which is wrong. Keywords should only be

ON TABLES
ON SEQUENCES
ON FUNCTIONS
ON TYPES

This is what the patch is trying to fix.

--
Gilles Darold
Consultant PostgreSQL
http://dalibo.com - http://dalibo.org

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dilip Kumar 2016-11-28 09:30:51 Re: Proposal: scan key push down to heap [WIP]
Previous Message Pavel Stehule 2016-11-28 07:42:40 Re: proposal: session server side variables