From: Fujii Masao <masao.fujii@oss.nttdata.com>
To: bt21tanigaway <bt21tanigaway@oss.nttdata.com>
To: Shinya11.Kato@nttdata.com
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: (LOCK TABLE options) “ONLY” and “NOWAIT” are not yet implemented
Date: Mon, 4 Oct 2021 13:59:19 +0900
Message-ID: <0d484953-8bfc-9e88-2dfd-3cb1cb4a3e59@oss.nttdata.com> (raw)
In-Reply-To: <d4e33e4f465d67c6e723a7f45eeb1d43@oss.nttdata.com>
References: <a322684daa36319e6ebc60b541000a3a@oss.nttdata.com>
<79967bce-cc80-1941-463b-883bd5606790@oss.nttdata.com>
<81b150bf40a3dad24fb8674feb07308e@oss.nttdata.com>
<bf29c936d1ba16d71423bde2ce2d4be1@oss.nttdata.com>
<TYAPR01MB28966A3AAE20D0A48C9BF41BC4A89@TYAPR01MB2896.jpnprd01.prod.outlook.com>
<913e1abb8fca30aeb370343d47876a0c@oss.nttdata.com>
<TYAPR01MB2896005A7BA10FEDD897B4E3C4AA9@TYAPR01MB2896.jpnprd01.prod.outlook.com>
<d4e33e4f465d67c6e723a7f45eeb1d43@oss.nttdata.com>
On 2021/10/04 11:17, bt21tanigaway wrote:
>>> else if (Matches("LOCK", MatchAny, "IN", "ACCESS|ROW") ||
>>> - Matches("LOCK", "TABLE", MatchAny, "IN", "ACCESS|ROW"))
>>> + Matches("LOCK", "TABLE", MatchAny, "IN", "ACCESS|ROW") ||
>>> + Matches("LOCK", "ONLY", MatchAny, "IN", "ACCESS|ROW") ||
>>> + Matches("LOCK", "TABLE", "ONLY", MatchAny, "IN", "ACCESS|ROW"))
>> I think this code is redundant, so I change following.
>> ---
>> else if (HeadMatches("LOCK") && TailMatches("IN", "ACCESS|ROW"))
>> ---
>> I created the patch, and attached it. Do you think?
> Thank you for update!
> I think that your code is more concise than mine.
> There seems to be no problem.
The patch looks good to me, too. I applied cosmetic changes to it.
Attached is the updated version of the patch. Barring any objection,
I will commit it.
Regards,
--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION
Attachments:fix_tab_completion_of_lock_fujii.patch (text/plain, 3.1K) downloaddiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.cindex 5cd5838668..ecae9df8ed 100644--- a/src/bin/psql/tab-complete.c+++ b/src/bin/psql/tab-complete.c@@ -3599,40 +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'");+ " 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, NULL);
/* 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 */- else if (Matches("LOCK", MatchAny, "IN") ||- Matches("LOCK", "TABLE", MatchAny, "IN"))+ /* Complete LOCK [TABLE] [ONLY] <table> IN with a lock mode */+ else if (HeadMatches("LOCK") && TailMatches("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 */- else if (Matches("LOCK", MatchAny, "IN", "ACCESS|ROW") ||- Matches("LOCK", "TABLE", MatchAny, "IN", "ACCESS|ROW"))+ /*+ * Complete LOCK [TABLE][ONLY] <table> IN ACCESS|ROW with rest of lock+ * mode+ */+ else if (HeadMatches("LOCK") && TailMatches("IN", "ACCESS|ROW"))
COMPLETE_WITH("EXCLUSIVE MODE", "SHARE MODE");
- /* Complete LOCK [TABLE] <table> IN SHARE with rest of lock mode */- else if (Matches("LOCK", MatchAny, "IN", "SHARE") ||- Matches("LOCK", "TABLE", MatchAny, "IN", "SHARE"))+ /* Complete LOCK [TABLE] [ONLY] <table> IN SHARE with rest of lock mode */+ else if (HeadMatches("LOCK") && TailMatches("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"))
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'");
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: masao.fujii@oss.nttdata.com, bt21tanigaway@oss.nttdata.com, Shinya11.Kato@nttdata.com
Subject: Re: (LOCK TABLE options) “ONLY” and “NOWAIT” are not yet implemented
In-Reply-To: <0d484953-8bfc-9e88-2dfd-3cb1cb4a3e59@oss.nttdata.com>
References: <a322684daa36319e6ebc60b541000a3a@oss.nttdata.com> <79967bce-cc80-1941-463b-883bd5606790@oss.nttdata.com> <81b150bf40a3dad24fb8674feb07308e@oss.nttdata.com> <bf29c936d1ba16d71423bde2ce2d4be1@oss.nttdata.com> <TYAPR01MB28966A3AAE20D0A48C9BF41BC4A89@TYAPR01MB2896.jpnprd01.prod.outlook.com> <913e1abb8fca30aeb370343d47876a0c@oss.nttdata.com> <TYAPR01MB2896005A7BA10FEDD897B4E3C4AA9@TYAPR01MB2896.jpnprd01.prod.outlook.com> <d4e33e4f465d67c6e723a7f45eeb1d43@oss.nttdata.com> <0d484953-8bfc-9e88-2dfd-3cb1cb4a3e59@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