From c54b888700814c5075f35995e4c0e32335e27d23 Mon Sep 17 00:00:00 2001 From: Dean Rasheed Date: Fri, 6 Jan 2023 11:09:56 +0000 Subject: [PATCH] Fix tab completion of ALTER FUNCTION/PROCEDURE/ROUTINE ... SET SCHEMA. The ALTER DATABASE|FUNCTION|PROCEDURE|ROLE|ROUTINE|USER ... SET case in psql tab completion failed to exclude = "SCHEMA", which caused ALTER FUNCTION|PROCEDURE|ROUTINE ... SET SCHEMA to complete with "FROM CURRENT" and "TO", which won't work. Fix that, so that those cases now complete with the list of schemas, like other ALTER ... SET SCHEMA commands. Noticed while testing the recent patch to improve tab completion for ALTER FUNCTION/PROCEDURE/ROUTINE, but this is not directly related to that patch. Rather, this is a long-standing bug, so back-patch to all supported branches. Discussion: https://postgr.es/m/CALDaNm0s7GQmkLP_mx5Cvk=UzYMnjhPmXBxU8DsHEunFbC5sTg@mail.gmail.com --- src/bin/psql/tab-complete.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index d6b4a5bc31f..afc9c26259d 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3528,11 +3528,12 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH_CONST("TO"); /* - * Complete ALTER DATABASE|FUNCTION||PROCEDURE|ROLE|ROUTINE|USER ... SET + * Complete ALTER DATABASE|FUNCTION|PROCEDURE|ROLE|ROUTINE|USER ... SET * */ else if (HeadMatches2("ALTER", "DATABASE|FUNCTION|PROCEDURE|ROLE|ROUTINE|USER") && - TailMatches2("SET", MatchAny)) + TailMatches2("SET", MatchAny) && + !TailMatches1("SCHEMA")) COMPLETE_WITH_LIST2("FROM CURRENT", "TO"); /* -- 2.39.5