pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: btnakamichin <btnakamichin@oss.nttdata.com>
To: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: pgsql-hackers@postgresql.org
Subject: Re: Feature improvement for FETCH tab completion
Date: Fri, 25 Sep 2020 17:21:29 +0900
Message-ID: <e41e668e4e68dfd9e4a74ce98e54eb2c@oss.nttdata.com> (raw)
In-Reply-To: <bea7d871-affc-d190-f72f-5369aa663c6d@oss.nttdata.com>
References: <d05a46b599634ca0d94144387507f4b4@oss.nttdata.com>
	<bea7d871-affc-d190-f72f-5369aa663c6d@oss.nttdata.com>

2020-09-25 15:38 に Fujii Masao さんは書きました:
> On 2020/09/25 14:24, btnakamichin wrote:
>> Hello!
>> 
>> I’d like to improve the FETCH tab completion.
>> 
>> The FETCH tab completion . Therefore, this patch fixes the problem.
>> 
>> Previous function completed one of FORWARD, BACKWARD, RELATIVE, 
>> ABSOLUTE, but now it completes one of FORWARD, BACKWARD, RELATIVE, 
>> ABSOLUTE, ALL, NEXT, PRIOR, FIRST, LAST and Corresponded to later IN 
>> and FROM clauses.
> 
> Thanks for the patch! Here are review comments.
> 
> +	/* Complete FETCH BACKWARD or FORWARD with one of ALL */
> +	else if (Matches("FETCH|MOVE", "BACKWARD|FORWARD"))
> +		COMPLETE_WITH("ALL");
> 
> Not only "ALL" but also "FROM" and "IN" should be displayed here
> because they also can follow "BACKWARD" and "FORWARD"?
> 
> 	else if (Matches("FETCH|MOVE", MatchAny, MatchAny))
> +	else if (Matches("FETCH|MOVE", "ABSOLUTE|BACKWARD|FORWARD|RELATIVE",
> MatchAny))
> +		COMPLETE_WITH("FROM", "IN");
> 
> This change seems to cause "FETCH FORWARD FROM <tab>" to display "FROM"
> and "IN". To avoid this confusing tab-completion, we should use 
> something like
> MatchAnyExcept("FROM|IN") here, instead?
> 
> Regards,

I’m Sorry, I forgot to include pgsql_hackers in the cc, so I resend it

Thank you, I appreciate your comment.

I have attached patch with newline.

Regards,

NaokiNakamichi

Attachments:

fix_tab_complete_fetch_v2.patch (text/x-diff, 2.0K) download diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c index d877cc86f0..dafbae0366 100644 --- a/src/bin/psql/tab-complete.c +++ b/src/bin/psql/tab-complete.c @@ -2911,7 +2911,8 @@ psql_completion(const char *text, int start, int end) /* DEALLOCATE */ else if (Matches("DEALLOCATE")) - COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements " UNION SELECT 'ALL'"); + COMPLETE_WITH_QUERY(Query_for_list_of_prepared_statements + " UNION SELECT 'ALL'"); /* DECLARE */ else if (Matches("DECLARE", MatchAny)) @@ -3076,19 +3077,27 @@ psql_completion(const char *text, int start, int end) COMPLETE_WITH("SELECT", "INSERT", "DELETE", "UPDATE", "DECLARE"); /* FETCH && MOVE */ - /* Complete FETCH with one of FORWARD, BACKWARD, RELATIVE */ + /* + * Complete FETCH with one of FORWARD, BACKWARD, RELATIVE, ALL, NEXT, + * PRIOR, FIRST, LAST + */ else if (Matches("FETCH|MOVE")) - COMPLETE_WITH("ABSOLUTE", "BACKWARD", "FORWARD", "RELATIVE"); - /* Complete FETCH <sth> with one of ALL, NEXT, PRIOR */ - else if (Matches("FETCH|MOVE", MatchAny)) - COMPLETE_WITH("ALL", "NEXT", "PRIOR"); + COMPLETE_WITH("ABSOLUTE", "BACKWARD", "FORWARD", "RELATIVE", "ALL", "NEXT", + "PRIOR", "FIRST", "LAST"); + /* Complete FETCH BACKWARD or FORWARD with one of ALL, IN, FROM */ + else if (Matches("FETCH|MOVE", "BACKWARD|FORWARD")) + COMPLETE_WITH("ALL", "FROM", "IN"); /* - * Complete FETCH <sth1> <sth2> with "FROM" or "IN". These are equivalent, + * Complete FETCH <direction> with "FROM" or "IN". These are equivalent, * but we may as well tab-complete both: perhaps some users prefer one * variant or the other. */ - else if (Matches("FETCH|MOVE", MatchAny, MatchAny)) + else if (Matches("FETCH|MOVE", "ABSOLUTE|BACKWARD|FORWARD|RELATIVE", + MatchAnyExcept("FROM|IN"))) + COMPLETE_WITH("FROM", "IN"); + + else if (Matches("FETCH|MOVE", "ALL|NEXT|PRIOR|FIRST|LAST")) COMPLETE_WITH("FROM", "IN"); /* FOREIGN DATA WRAPPER */

view thread (5+ messages)  latest in thread

Message-ID: <e41e668e4e68dfd9e4a74ce98e54eb2c@oss.nttdata.com>
Permalink:  ../e41e668e4e68dfd9e4a74ce98e54eb2c@oss.nttdata.com/
Also on:    postgresql.org/message-id/e41e668e4e68dfd9e4a74ce98e54eb2c@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: btnakamichin@oss.nttdata.com, masao.fujii@oss.nttdata.com
  Subject: Re: Feature improvement for FETCH tab completion
  In-Reply-To: <e41e668e4e68dfd9e4a74ce98e54eb2c@oss.nttdata.com>
  References: <d05a46b599634ca0d94144387507f4b4@oss.nttdata.com> <bea7d871-affc-d190-f72f-5369aa663c6d@oss.nttdata.com> <e41e668e4e68dfd9e4a74ce98e54eb2c@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