Re: [patch] psql tab completion for ALTER DEFAULT PRIVILEGES - Mailing list pgsql-hackers

From Gilles Darold
Subject Re: [patch] psql tab completion for ALTER DEFAULT PRIVILEGES
Date
Msg-id 9905474c-ab29-bb66-408f-ca776fb3d69c@dalibo.com
Whole thread Raw
In response to [patch] psql tab completion for ALTER DEFAULT PRIVILEGES  (Gilles Darold <gilles.darold@dalibo.com>)
Responses Re: [HACKERS] [patch] psql tab completion for ALTER DEFAULTPRIVILEGES
Re: [HACKERS] [patch] psql tab completion for ALTER DEFAULTPRIVILEGES
List 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




pgsql-hackers by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: proposal: session server side variables
Next
From: Dilip Kumar
Date:
Subject: Re: Proposal: scan key push down to heap [WIP]