postgres.git / summary / log / commit / refs
commit 1d15d0db50a5f39ab69c1fe60f2d5dcc7e2ddb9c
Author: Robert Haas <rhaas@postgresql.org>
Date: Thu Nov 03 15:42:13 2016 +0000
psql: Tab-complete LOCK [TABLE] ... IN {ACCESS|ROW|SHARE}.
Suggest the lock modes that begin with the word in question.
Thomas Munro, reviewed by Marllius Ribeiro. Comments tweaked by me.
src/bin/psql/tab-complete.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 50a45eb9289..dd8bbe1467d 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2662,6 +2662,17 @@ psql_completion(const char *text, int start, int end)
"SHARE ROW EXCLUSIVE MODE",
"EXCLUSIVE MODE", "ACCESS EXCLUSIVE MODE");
+ /* Complete LOCK [TABLE] <table> IN ACCESS|ROW with rest of lock mode */
+ else if (Matches4("LOCK", MatchAny, "IN", "ACCESS|ROW") ||
+ Matches5("LOCK", "TABLE", MatchAny, "IN", "ACCESS|ROW"))
+ COMPLETE_WITH_LIST2("EXCLUSIVE MODE", "SHARE MODE");
+
+ /* Complete LOCK [TABLE] <table> IN SHARE with rest of lock mode */
+ else if (Matches4("LOCK", MatchAny, "IN", "SHARE") ||
+ Matches5("LOCK", "TABLE", MatchAny, "IN", "SHARE"))
+ COMPLETE_WITH_LIST3("MODE", "ROW EXCLUSIVE MODE",
+ "UPDATE EXCLUSIVE MODE");
+
/* NOTIFY --- can be inside EXPLAIN, RULE, etc */
else if (TailMatches1("NOTIFY"))
COMPLETE_WITH_QUERY("SELECT pg_catalog.quote_ident(channel) FROM pg_catalog.pg_listening_channels() AS channel WHERE substring(pg_catalog.quote_ident(channel),1,%d)='%s'");
[parent: c6ff380e3806]