pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: bt21tanigaway <bt21tanigaway@oss.nttdata.com>
To: pgsql-hackers@lists.postgresql.org
Subject: (LOCK TABLE options) “ONLY” and “NOWAIT” are not yet implemented
Date: Tue, 28 Sep 2021 16:13:45 +0900
Message-ID: <a322684daa36319e6ebc60b541000a3a@oss.nttdata.com> (raw)

Hi,

(LOCK TABLE options) “ONLY” and “NOWAIT” are not yet implemented in 
tab-complete. I made a patch for these options.

regards,
Koyu Tanigawa

Attachments:

fix-tab-complete.patch (text/x-diff, 3.2K) download diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index 5cd5838668..12c55f5904 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -3599,39 +3599,49 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("("); /* LOCK */ - /* Complete LOCK [TABLE] with a list of tables */ + /* Complete LOCK [TABLE] [ONLY] with a list of tables */ else if (Matches("LOCK")) - COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, - " UNION SELECT 'TABLE'"); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, " UNION SELECT 'TABLE'" " UNION SELECT 'ONLY'"); + else if (Matches("LOCK", "TABLE")) - COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, ""); + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, " UNION SELECT 'ONLY'"); + else if (Matches("LOCK", "TABLE", "ONLY") || Matches("LOCK", "ONLY")) + COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, ""); /* For the following, handle the case of a single table only for now */ - /* Complete LOCK [TABLE] <table> with "IN" */ - else if (Matches("LOCK", MatchAnyExcept("TABLE")) || - Matches("LOCK", "TABLE", MatchAny)) - COMPLETE_WITH("IN"); + /* Complete LOCK [TABLE] [ONLY] <table> with "IN" or "NOWAIT" */ + else if (Matches("LOCK", MatchAnyExcept("TABLE|ONLY")) || + Matches("LOCK", "TABLE", MatchAnyExcept("ONLY")) || + Matches("LOCK", "ONLY", MatchAny) || + Matches("LOCK", "TABLE", "ONLY", MatchAny)) + COMPLETE_WITH("IN", "NOWAIT"); - /* Complete LOCK [TABLE] <table> IN with a lock mode */ + /* Complete LOCK [TABLE] [ONLY] <table> IN with a lock mode */ else if (Matches("LOCK", MatchAny, "IN") || - Matches("LOCK", "TABLE", MatchAny, "IN")) + Matches("LOCK", "TABLE", MatchAny, "IN") || + Matches("LOCK", "TABLE", "ONLY", MatchAny, "IN")) COMPLETE_WITH("ACCESS SHARE MODE", "ROW SHARE MODE", "ROW EXCLUSIVE MODE", "SHARE UPDATE EXCLUSIVE MODE", "SHARE MODE", "SHARE ROW EXCLUSIVE MODE", "EXCLUSIVE MODE", "ACCESS EXCLUSIVE MODE"); - /* Complete LOCK [TABLE] <table> IN ACCESS|ROW with rest of lock mode */ + /* Complete LOCK [TABLE][ONLY] <table> IN ACCESS|ROW with rest of lock mode */ else if (Matches("LOCK", MatchAny, "IN", "ACCESS|ROW") || - Matches("LOCK", "TABLE", MatchAny, "IN", "ACCESS|ROW")) + Matches("LOCK", "TABLE", MatchAny, "IN", "ACCESS|ROW") || + Matches("LOCK", "TABLE", "ONLY", MatchAny, "IN", "ACCESS|ROW")) COMPLETE_WITH("EXCLUSIVE MODE", "SHARE MODE"); - /* Complete LOCK [TABLE] <table> IN SHARE with rest of lock mode */ + /* Complete LOCK [TABLE] [ONLY] <table> IN SHARE with rest of lock mode */ else if (Matches("LOCK", MatchAny, "IN", "SHARE") || - Matches("LOCK", "TABLE", MatchAny, "IN", "SHARE")) - COMPLETE_WITH("MODE", "ROW EXCLUSIVE MODE", - "UPDATE EXCLUSIVE MODE"); + Matches("LOCK", "TABLE", MatchAny, "IN", "SHARE") || + Matches("LOCK", "TABLE", "ONLY", MatchAny, "IN", "SHARE")) + COMPLETE_WITH("MODE", "ROW EXCLUSIVE MODE", "UPDATE EXCLUSIVE MODE"); + + /* Complete LOCK [TABLE] [ONLY] <table> [IN lockmode MODE] with "NOWAIT"*/ + else if (HeadMatches("LOCK") && TailMatches("MODE")) + COMPLETE_WITH("NOWAIT"); /* NOTIFY --- can be inside EXPLAIN, RULE, etc */ else if (TailMatches("NOTIFY"))

view thread (12+ messages)  latest in thread

Message-ID: <a322684daa36319e6ebc60b541000a3a@oss.nttdata.com>
Permalink:  ../a322684daa36319e6ebc60b541000a3a@oss.nttdata.com/
Also on:    postgresql.org/message-id/a322684daa36319e6ebc60b541000a3a@oss.nttdata.com

 ·  · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: bt21tanigaway@oss.nttdata.com
  Subject: Re: (LOCK TABLE options) “ONLY” and “NOWAIT” are not yet implemented
  In-Reply-To: <a322684daa36319e6ebc60b541000a3a@oss.nttdata.com>
  References: <a322684daa36319e6ebc60b541000a3a@oss.nttdata.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox