On Mon, 27 Nov 2023 at 21:58, vignesh C <vignes...@gmail.com> wrote: > > On Fri, 24 Nov 2023 at 18:37, Shubham Khanna > <khannashubham1...@gmail.com> wrote: > > > > n Fri, Nov 24, 2023 at 6:33 PM vignesh C <vignes...@gmail.com> wrote: > > > > > > Hi, > > > > > > Improved tab completion for "ALTER DEFAULT PRIVILEGE" and "ALTER TABLE": > > > 1) GRANT, REVOKE and FOR USER keyword was not displayed in tab > > > completion of alter default privileges like the below statement: > > > ALTER DEFAULT PRIVILEGES GRANT INSERT ON tables TO PUBLIC; > > > ALTER DEFAULT PRIVILEGES REVOKE INSERT ON tables FROM PUBLIC; > > > ALTER DEFAULT PRIVILEGES FOR USER vignesh revoke INSERT ON tables FROM > > > dba1; > > > > > > 2) USER was not displayed for "ALTER DEFAULT PRIVILEGES IN SCHEMA > > > public FOR " like in below statement: > > > ALTER DEFAULT PRIVILEGES IN SCHEMA public FOR USER dba1 GRANT INSERT > > > ON TABLES TO PUBLIC; > > > > > > 3) "FOR GRANT OPTION" was not display for "ALTER DEFAULT PRIVILEGES > > > REVOKE " like in below statement: > > > alter default privileges revoke grant option for select ON tables FROM > > > dba1; > > > > > > 4) "DATA TYPE" was missing in "ALTER TABLE table-name ALTER COLUMN > > > column-name SET" like in: > > > ALTER TABLE t1 ALTER COLUMN c1 SET DATA TYPE text; > > > > > > Attached patch has the changes for the same. > > > > + COMPLETE_WITH("ROLE", "USER"); > > + /* ALTER DEFAULT PRIVILEGES REVOKE */ > > + else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "REVOKE")) > > + COMPLETE_WITH("SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", > > + "REFERENCES", "TRIGGER", "CREATE", "EXECUTE", "USAGE", > > + "MAINTAIN", "ALL", "GRANT OPTION FOR"); > > > > I could not find "alter default privileges revoke maintain", should > > this be removed? > > This was reverted as part of: > 151c22deee66a3390ca9a1c3675e29de54ae73fc. > Revert MAINTAIN privilege and pg_maintain predefined role. > > This reverts the following commits: 4dbdb82513, c2122aae63, > 5b1a879943, 9e1e9d6560, ff9618e82a, 60684dd834, 4441fc704d, > and b5d6382496. A role with the MAINTAIN privilege may be able to > use search_path tricks to escalate privileges to the table owner. > Unfortunately, it is too late in the v16 development cycle to apply > the proposed fix, i.e., restricting search_path when running > maintenance commands. > > The attached v2 version has the changes for the same.
The patch was not applying because of a recent commit in tab completion, PSA new patch set. Regards, Vignesh
From e3695181cf7d5f31dda520a01def544dc576d6c1 Mon Sep 17 00:00:00 2001 From: Vignesh C <vignes...@gmail.com> Date: Sun, 2 Jul 2023 19:35:46 +0530 Subject: [PATCH v3 1/2] Fix missing tab completion in "ALTER DEFAULT PRIVILEGES" GRANT, REVOKE and FOR USER keyword was not displayed in tab completion of alter default prvileges like the below statement: ALTER DEFAULT PRIVILEGES GRANT INSERT ON tables TO PUBLIC; ALTER DEFAULT PRIVILEGES REVOKE INSERT ON tables FROM PUBLIC; ALTER DEFAULT PRIVILEGES FOR USER vignesh revoke INSERT ON tables FROM vignesh; USER was not displayed for "ALTER DEFAULT PRIVILEGES IN SCHEMA public FOR " like in below statement: ALTER DEFAULT PRIVILEGES IN SCHEMA public FOR USER vignesh GRANT INSERT ON TABLES TO PUBLIC; "FOR GRANT OPTION" was not display for "ALTER DEFAULT PRIVILEGES REVOKE " like in below statement: alter default privileges revoke grant option for select ON tables FROM testdba; --- src/bin/psql/tab-complete.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index ada711d02f..d5b3794fd6 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2144,10 +2144,15 @@ psql_completion(const char *text, int start, int end) /* ALTER DEFAULT PRIVILEGES */ else if (Matches("ALTER", "DEFAULT", "PRIVILEGES")) - COMPLETE_WITH("FOR ROLE", "IN SCHEMA"); + COMPLETE_WITH("FOR", "GRANT", "IN SCHEMA", "REVOKE"); /* ALTER DEFAULT PRIVILEGES FOR */ else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "FOR")) - COMPLETE_WITH("ROLE"); + COMPLETE_WITH("ROLE", "USER"); + /* ALTER DEFAULT PRIVILEGES REVOKE */ + else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "REVOKE")) + COMPLETE_WITH("SELECT", "INSERT", "UPDATE", "DELETE", "TRUNCATE", + "REFERENCES", "TRIGGER", "CREATE", "EXECUTE", "USAGE", + "ALL", "GRANT OPTION FOR"); /* ALTER DEFAULT PRIVILEGES IN */ else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "IN")) COMPLETE_WITH("SCHEMA"); @@ -2158,11 +2163,11 @@ psql_completion(const char *text, int start, int end) /* ALTER DEFAULT PRIVILEGES IN SCHEMA ... */ else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA", MatchAny)) - COMPLETE_WITH("GRANT", "REVOKE", "FOR ROLE"); + COMPLETE_WITH("GRANT", "REVOKE", "FOR"); /* ALTER DEFAULT PRIVILEGES IN SCHEMA ... FOR */ else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "IN", "SCHEMA", MatchAny, "FOR")) - COMPLETE_WITH("ROLE"); + COMPLETE_WITH("ROLE", "USER"); /* ALTER DEFAULT PRIVILEGES FOR ROLE|USER ... IN SCHEMA ... */ /* ALTER DEFAULT PRIVILEGES IN SCHEMA ... FOR ROLE|USER ... */ else if (Matches("ALTER", "DEFAULT", "PRIVILEGES", "FOR", "ROLE|USER", -- 2.34.1
From bb84a17a9a09d230e05055c47978b562d1ae2bbe Mon Sep 17 00:00:00 2001 From: Vignesh C <vignes...@gmail.com> Date: Fri, 26 Jan 2024 08:02:13 +0530 Subject: [PATCH v3 2/2] Fix missing tab completion in "ALTER TABLE table-name ALTER COLUMN column-name SET" "DATA TYPE" was missing in "ALTER TABLE table-name ALTER COLUMN column-name SET" lke in: ALTER TABLE t1 ALTER COLUMN c1 SET DATA TYPE text; --- src/bin/psql/tab-complete.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index d5b3794fd6..e7d812e636 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2509,7 +2509,7 @@ psql_completion(const char *text, int start, int end) /* ALTER TABLE ALTER [COLUMN] <foo> SET */ else if (Matches("ALTER", "TABLE", MatchAny, "ALTER", "COLUMN", MatchAny, "SET") || Matches("ALTER", "TABLE", MatchAny, "ALTER", MatchAny, "SET")) - COMPLETE_WITH("(", "COMPRESSION", "DEFAULT", "EXPRESSION", "GENERATED", "NOT NULL", "STATISTICS", "STORAGE", + COMPLETE_WITH("(", "COMPRESSION", "DATA TYPE", "DEFAULT", "EXPRESSION", "GENERATED", "NOT NULL", "STATISTICS", "STORAGE", /* a subset of ALTER SEQUENCE options */ "INCREMENT", "MINVALUE", "MAXVALUE", "START", "NO", "CACHE", "CYCLE"); /* ALTER TABLE ALTER [COLUMN] <foo> SET ( */ -- 2.34.1