Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-11-05 Thread Fujii Masao




On 2021/11/05 21:35, Michael Paquier wrote:

On Fri, Nov 05, 2021 at 10:39:36AM +0100, Daniel Gustafsson wrote:

Is there anything left on this or can we close it in the commitfest?


Oops.  I have missed that there was a CF entry for this patch, and
missed that Fujii-san was registered as a committer for it.  My
apologies!


No problem. Thanks for committing the patch!

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION




Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-11-05 Thread Michael Paquier
On Fri, Nov 05, 2021 at 10:39:36AM +0100, Daniel Gustafsson wrote:
> Is there anything left on this or can we close it in the commitfest?

Oops.  I have missed that there was a CF entry for this patch, and
missed that Fujii-san was registered as a committer for it.  My
apologies!
--
Michael


signature.asc
Description: PGP signature


Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-11-05 Thread Daniel Gustafsson
> On 5 Nov 2021, at 07:30, Michael Paquier  wrote:
> 
> On Fri, Nov 05, 2021 at 12:31:42PM +0900, Ken Kato wrote:
>> I found unnecessary line deletion in my previous patch, so I made a minor
>> update for that.
> 
> I have looked at this version, and this is much simpler than what was
> proposed upthread.  This looks good, so applied after fixing a couple
> of indentation issues in the list of objects after COMMENT ON.

Is there anything left on this or can we close it in the commitfest?

--
Daniel Gustafsson   https://vmware.com/





Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-11-05 Thread Michael Paquier
On Fri, Nov 05, 2021 at 12:31:42PM +0900, Ken Kato wrote:
> I found unnecessary line deletion in my previous patch, so I made a minor
> update for that.

I have looked at this version, and this is much simpler than what was
proposed upthread.  This looks good, so applied after fixing a couple
of indentation issues in the list of objects after COMMENT ON.
--
Michael


signature.asc
Description: PGP signature


Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-11-04 Thread Ken Kato

Hi,

I found unnecessary line deletion in my previous patch, so I made a 
minor update for that.


--
Best wishes,

Ken Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATIONdiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index ecae9df8ed..b9af1df319 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -2399,22 +2399,19 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT"))
 		COMPLETE_WITH("ON");
 	else if (Matches("COMMENT", "ON"))
-		COMPLETE_WITH("ACCESS METHOD", "CAST", "COLLATION", "CONVERSION",
-	  "DATABASE", "EVENT TRIGGER", "EXTENSION",
-	  "FOREIGN DATA WRAPPER", "FOREIGN TABLE", "SERVER",
-	  "INDEX", "LANGUAGE", "POLICY", "PUBLICATION", "RULE",
-	  "SCHEMA", "SEQUENCE", "STATISTICS", "SUBSCRIPTION",
-	  "TABLE", "TYPE", "VIEW", "MATERIALIZED VIEW",
-	  "COLUMN", "AGGREGATE", "FUNCTION",
-	  "PROCEDURE", "ROUTINE",
-	  "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN",
-	  "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
+		COMPLETE_WITH("ACCESS METHOD", "AGGREGATE", "CAST", "COLLATION",
+	  "COLUMN","CONSTRAINT", "CONVERSION", "DATABASE",
+	  "DOMAIN","EXTENSION", "EVENT TRIGGER",
+	  "FOREIGN DATA WRAPPER","FOREIGN TABLE",
+	  "FUNCTION", "INDEX", "LANGUAGE","LARGE OBJECT",
+	  "MATERIALIZED VIEW", "OPERATOR","POLICY",
+	  "PROCEDURE", "PROCEDURAL LANGUAGE", "PUBLICATION","ROLE",
+	  "ROUTINE", "RULE", "SCHEMA", "SEQUENCE","SERVER",
+	  "STATISTICS", "SUBSCRIPTION", "TABLE",
+	  "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
+	  "TRIGGER", "TYPE", "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
-	else if (Matches("COMMENT", "ON", "FOREIGN"))
-		COMPLETE_WITH("DATA WRAPPER", "TABLE");
-	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH"))
-		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
 		COMPLETE_WITH_QUERY(Query_for_all_table_constraints);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny))
@@ -2422,15 +2419,67 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny, "ON"))
 	{
 		completion_info_charp = prev2_wd;
-		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_constraint);
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_constraint
+			" UNION SELECT 'DOMAIN'");
 	}
-	else if (Matches("COMMENT", "ON", "MATERIALIZED", "VIEW"))
-		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
+	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny, "ON", "DOMAIN"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_domains, NULL);
 	else if (Matches("COMMENT", "ON", "EVENT", "TRIGGER"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers);
+	else if (Matches("COMMENT", "ON", "FOREIGN"))
+		COMPLETE_WITH("DATA WRAPPER", "TABLE");
+	else if (Matches("COMMENT", "ON", "FOREIGN", "TABLE"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_foreign_tables, NULL);
+	else if (Matches("COMMENT", "ON", "MATERIALIZED", "VIEW"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
+	else if (Matches("COMMENT", "ON", "POLICY"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_policies);
+	else if (Matches("COMMENT", "ON", "POLICY", MatchAny))
+		COMPLETE_WITH("ON");
+	else if (Matches("COMMENT", "ON", "POLICY", MatchAny, "ON"))
+	{
+		completion_info_charp = prev2_wd;
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_policy);
+	}
+	else if (Matches("COMMENT", "ON", "PROCEDURAL", "LANGUAGE"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_languages);
+	else if (Matches("COMMENT", "ON", "RULE", MatchAny))
+		COMPLETE_WITH("ON");
+	else if (Matches("COMMENT", "ON", "RULE", MatchAny, "ON"))
+	{
+		completion_info_charp = prev2_wd;
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_rule);
+	}
+	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH"))
+		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
+	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH", "CONFIGURATION"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_ts_configurations);
+	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH", "DICTIONARY"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_ts_dictionaries);
+	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH", "PARSER"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_ts_parsers);
+	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH", "TEMPLATE"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_ts_templates);
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR", MatchAny))
+		COMPLETE_WITH("LANGUAGE");
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR", MatchAny, "LANGUAGE"))
+	{
+		completion_info_charp = prev2_wd;
+		

Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-11-04 Thread Ken Kato

+   else if (Matches("COMMENT", "ON", "PROCEDURAL"))
+   COMPLETE_WITH("LANGUAGE");
+   else if (Matches("COMMENT", "ON", "PROCEDURAL", "LANGUAGE"))
+   COMPLETE_WITH_QUERY(Query_for_list_of_languages);
I don't think that there is much point in being this picky either 
with

the usage of PROCEDURAL, as we already complete a similar and simpler
grammar with LANGUAGE.  I would just remove this part of the patch.
In my opinion, it is written in the documentation, so tab-completion 
of "PROCEDURAL"is good.
How about a completion with "LANGUAGE" and "PROCEDURAL LANGUAGE", like 
"PASSWORD" and "ENCRYPTED PASSWORD" in CREATE ROLE?


I kept LANGUAGE and PROCEDURAL LANGUAGE just like PASSWORD and ENCRYPTED 
PASSWORD.




+   else if (Matches("COMMENT", "ON", "OPERATOR"))
+   COMPLETE_WITH("CLASS", "FAMILY");
Isn't this one wrong?  Operators can have comments, and we'd miss
them.  This is mentioned upthread, but it seems to me that we'd 
better

drop this part of the patch if the operator naming part cannot be
solved easily.

As you said, it may be misleading.
I agree to drop it.


Hearing all the opinions given, I decided not to support OPERATOR CLASS 
or FAMILY in COMMENT.
Therefore, I drooped Query_for_list_of_operator_class_index_methods as 
well.



+static const SchemaQuery Query_for_list_of_text_search_configurations 
= {


We already have Query_for_list_of_ts_configurations in tab-complete.c.
Do we really need both queries? Or we can drop either of them?


Thank you for pointing out!
I didn't notice that there already exists 
Query_for_list_of_ts_configurations,

so I changed TEXT SEARCH completion with using Query_for_list_of_ts_XXX.

I made the changes to the points above and updated the patch.

--
Best wishes,

Ken Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATIONdiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index ecae9df8ed..ee63a54470 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -494,7 +494,6 @@ static const SchemaQuery Query_for_list_of_partitioned_indexes = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
-
 /* All relations */
 static const SchemaQuery Query_for_list_of_relations = {
 	.catname = "pg_catalog.pg_class c",
@@ -2399,22 +2398,19 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT"))
 		COMPLETE_WITH("ON");
 	else if (Matches("COMMENT", "ON"))
-		COMPLETE_WITH("ACCESS METHOD", "CAST", "COLLATION", "CONVERSION",
-	  "DATABASE", "EVENT TRIGGER", "EXTENSION",
-	  "FOREIGN DATA WRAPPER", "FOREIGN TABLE", "SERVER",
-	  "INDEX", "LANGUAGE", "POLICY", "PUBLICATION", "RULE",
-	  "SCHEMA", "SEQUENCE", "STATISTICS", "SUBSCRIPTION",
-	  "TABLE", "TYPE", "VIEW", "MATERIALIZED VIEW",
-	  "COLUMN", "AGGREGATE", "FUNCTION",
-	  "PROCEDURE", "ROUTINE",
-	  "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN",
-	  "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
+		COMPLETE_WITH("ACCESS METHOD", "AGGREGATE", "CAST", "COLLATION",
+	  "COLUMN","CONSTRAINT", "CONVERSION", "DATABASE",
+	  "DOMAIN","EXTENSION", "EVENT TRIGGER",
+	  "FOREIGN DATA WRAPPER","FOREIGN TABLE",
+	  "FUNCTION", "INDEX", "LANGUAGE","LARGE OBJECT",
+	  "MATERIALIZED VIEW", "OPERATOR","POLICY",
+	  "PROCEDURE", "PROCEDURAL LANGUAGE", "PUBLICATION","ROLE",
+	  "ROUTINE", "RULE", "SCHEMA", "SEQUENCE","SERVER",
+	  "STATISTICS", "SUBSCRIPTION", "TABLE",
+	  "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
+	  "TRIGGER", "TYPE", "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
-	else if (Matches("COMMENT", "ON", "FOREIGN"))
-		COMPLETE_WITH("DATA WRAPPER", "TABLE");
-	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH"))
-		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
 		COMPLETE_WITH_QUERY(Query_for_all_table_constraints);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny))
@@ -2422,15 +2418,67 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny, "ON"))
 	{
 		completion_info_charp = prev2_wd;
-		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_constraint);
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_constraint
+			" UNION SELECT 'DOMAIN'");
 	}
-	else if (Matches("COMMENT", "ON", "MATERIALIZED", "VIEW"))
-		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_matviews, NULL);
+	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny, "ON", "DOMAIN"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_domains, NULL);
 	else if (Matches("COMMENT", "ON", "EVENT", "TRIGGER"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers);
+	else if (Matches("COMMENT", "ON", "FOREIGN"))
+		COMPLETE_WITH("DATA WRAPPER", "TABLE");
+	else if (Matches("COMMENT", "ON", "FOREIGN", "TABLE"))
+		

Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-11-01 Thread Fujii Masao




On 2021/10/27 15:54, Shinya Kato wrote:

On 2021-10-27 14:45, Michael Paquier wrote:

On Tue, Oct 26, 2021 at 05:04:24PM +0900, Shinya Kato wrote:

Barring any objection, I will change status to Ready for Committer.


+   else if (Matches("COMMENT", "ON", "PROCEDURAL"))
+   COMPLETE_WITH("LANGUAGE");
+   else if (Matches("COMMENT", "ON", "PROCEDURAL", "LANGUAGE"))
+   COMPLETE_WITH_QUERY(Query_for_list_of_languages);
I don't think that there is much point in being this picky either with
the usage of PROCEDURAL, as we already complete a similar and simpler
grammar with LANGUAGE.  I would just remove this part of the patch.

In my opinion, it is written in the documentation, so tab-completion of 
"PROCEDURAL"is good.
How about a completion with "LANGUAGE" and "PROCEDURAL LANGUAGE", like "PASSWORD" and 
"ENCRYPTED PASSWORD" in CREATE ROLE?


+   else if (Matches("COMMENT", "ON", "OPERATOR"))
+   COMPLETE_WITH("CLASS", "FAMILY");
Isn't this one wrong?  Operators can have comments, and we'd miss
them.  This is mentioned upthread, but it seems to me that we'd better
drop this part of the patch if the operator naming part cannot be
solved easily.

As you said, it may be misleading.
I agree to drop it.


So I changed the status of the patch to Waiting on Author in CF.


+static const SchemaQuery Query_for_list_of_text_search_configurations = {

We already have Query_for_list_of_ts_configurations in tab-complete.c.
Do we really need both queries? Or we can drop either of them?


+#define Query_for_list_of_operator_class_index_methods \
+"SELECT pg_catalog.quote_ident(amname)"\
+"  FROM pg_catalog.pg_am"\
+" WHERE (%d = pg_catalog.length('%s'))"\
+"   AND oid IN "\
+"   (SELECT opcmethod FROM pg_catalog.pg_opclass "\
+" WHERE pg_catalog.quote_ident(opcname)='%s')"

Isn't it overkill to tab-complete this? I thought that because
I'm not sure if COMMENT command for OPERATOR CLASS or FAMILY is
usually executed via psql interactively, instead I just guess
it's executed via script. Also because there is no tab-completion
support for ALTER OPERATOR CLASS or FAMILY command. It's a bit
strange to support the tab-complete for COMMENT for OPERATOR CLASS
or FAMILY first.

Regards,

--
Fujii Masao
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION




Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-27 Thread Michael Paquier
On Wed, Oct 27, 2021 at 03:54:03PM +0900, Shinya Kato wrote:
> In my opinion, it is written in the documentation, so tab-completion of
> "PROCEDURAL"is good.

It does not mean that we need to add everything either, especially
here as there is a shorter option.

> How about a completion with "LANGUAGE" and "PROCEDURAL LANGUAGE", like
> "PASSWORD" and "ENCRYPTED PASSWORD" in CREATE ROLE?

This has been around for some time already, so I'd just leave those
parts be.
--
Michael


signature.asc
Description: PGP signature


Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-27 Thread Shinya Kato

On 2021-10-27 14:45, Michael Paquier wrote:

On Tue, Oct 26, 2021 at 05:04:24PM +0900, Shinya Kato wrote:

Barring any objection, I will change status to Ready for Committer.


+   else if (Matches("COMMENT", "ON", "PROCEDURAL"))
+   COMPLETE_WITH("LANGUAGE");
+   else if (Matches("COMMENT", "ON", "PROCEDURAL", "LANGUAGE"))
+   COMPLETE_WITH_QUERY(Query_for_list_of_languages);
I don't think that there is much point in being this picky either with
the usage of PROCEDURAL, as we already complete a similar and simpler
grammar with LANGUAGE.  I would just remove this part of the patch.
In my opinion, it is written in the documentation, so tab-completion of 
"PROCEDURAL"is good.
How about a completion with "LANGUAGE" and "PROCEDURAL LANGUAGE", like 
"PASSWORD" and "ENCRYPTED PASSWORD" in CREATE ROLE?



+   else if (Matches("COMMENT", "ON", "OPERATOR"))
+   COMPLETE_WITH("CLASS", "FAMILY");
Isn't this one wrong?  Operators can have comments, and we'd miss
them.  This is mentioned upthread, but it seems to me that we'd better
drop this part of the patch if the operator naming part cannot be
solved easily.

As you said, it may be misleading.
I agree to drop it.

--
Regards,

--
Shinya Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION




Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-26 Thread Michael Paquier
On Tue, Oct 26, 2021 at 05:04:24PM +0900, Shinya Kato wrote:
> Barring any objection, I will change status to Ready for Committer.

+   else if (Matches("COMMENT", "ON", "PROCEDURAL"))
+   COMPLETE_WITH("LANGUAGE");
+   else if (Matches("COMMENT", "ON", "PROCEDURAL", "LANGUAGE"))
+   COMPLETE_WITH_QUERY(Query_for_list_of_languages);
I don't think that there is much point in being this picky either with
the usage of PROCEDURAL, as we already complete a similar and simpler
grammar with LANGUAGE.  I would just remove this part of the patch.

+   else if (Matches("COMMENT", "ON", "OPERATOR"))
+   COMPLETE_WITH("CLASS", "FAMILY");
Isn't this one wrong?  Operators can have comments, and we'd miss
them.  This is mentioned upthread, but it seems to me that we'd better
drop this part of the patch if the operator naming part cannot be
solved easily.
--
Michael


signature.asc
Description: PGP signature


Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-26 Thread Shinya Kato

On 2021-10-15 17:49, Ken Kato wrote:

2021-10-15 13:29 に Shinya Kato さんは書きました:

On 2021-10-14 14:30, katouknl wrote:
It is very good, but it seems to me that there are some 
tab-completion

missing in COMMENT command.
For example,
- CONSTRAINT ... ON DOMAIN
- OPERATOR CLASS
- OPERATOR FAMILY
- POLICY ... ON
- [PROCEDURAL]
- RULE ... ON
- TRIGGER ... ON

I think these tab-comletion also can be improved and it's a good
timing for that.


Thank you for the comments!

I fixed where you pointed out.

Thank you for the update!
I tried "COMMENT ON OPERATOR ...", and an operator seemed to be
complemented with double quotation marks.
However, it caused the COMMENT command to fail.
---
postgres=# COMMENT ON OPERATOR "+" (integer, integer) IS 'test_fail';
ERROR:  syntax error at or near "("
LINE 1: COMMENT ON OPERATOR "+" (integer, integer) IS 'test_fail';
postgres=# COMMENT ON OPERATOR + (integer, integer) IS 'test_success';
COMMENT
---

So, I think as with \do command, you do not need to complete the 
operators.

Do you think?

Thank you for the further comments!

I fixed so that it doesn't complete the operators anymore.
It only completes with CLASS and FAMILY.

Also, I updated TEXT SEARCH.
It completes object names for each one of CONFIGURATION, DICTIONARY,
PARSER, and TEMPLATE.


Thank you for update!
The patch looks good to me. I applied cosmetic changes to it.
Attached is the updated version of the patch.

Barring any objection, I will change status to Ready for Committer.

--
Regards,

--
Shinya Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATIONdiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index ecae9df8ed..4c67b6842b 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -494,7 +494,6 @@ static const SchemaQuery Query_for_list_of_partitioned_indexes = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
-
 /* All relations */
 static const SchemaQuery Query_for_list_of_relations = {
 	.catname = "pg_catalog.pg_class c",
@@ -513,11 +512,46 @@ static const SchemaQuery Query_for_list_of_partitioned_relations = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
+static const SchemaQuery Query_for_list_of_operator_classes = {
+	.catname = "pg_catalog.pg_opclass o",
+	.viscondition = "pg_catalog.pg_opclass_is_visible(o.oid)",
+	.namespace = "o.opcnamespace",
+	.result = "pg_catalog.quote_ident(o.opcname)",
+};
+
 static const SchemaQuery Query_for_list_of_operator_families = {
-	.catname = "pg_catalog.pg_opfamily c",
-	.viscondition = "pg_catalog.pg_opfamily_is_visible(c.oid)",
-	.namespace = "c.opfnamespace",
-	.result = "pg_catalog.quote_ident(c.opfname)",
+	.catname = "pg_catalog.pg_opfamily o",
+	.viscondition = "pg_catalog.pg_opfamily_is_visible(o.oid)",
+	.namespace = "o.opfnamespace",
+	.result = "pg_catalog.quote_ident(o.opfname)",
+};
+
+static const SchemaQuery Query_for_list_of_text_search_configurations = {
+	.catname = "pg_catalog.pg_ts_config t",
+	.viscondition = "pg_catalog.pg_ts_config_is_visible(t.oid)",
+	.namespace = "t.cfgnamespace",
+	.result = "pg_catalog.quote_ident(t.cfgname)",
+};
+
+static const SchemaQuery Query_for_list_of_text_search_dictionaries = {
+	.catname = "pg_catalog.pg_ts_dict t",
+	.viscondition = "pg_catalog.pg_ts_dict_is_visible(t.oid)",
+	.namespace = "t.dictnamespace",
+	.result = "pg_catalog.quote_ident(t.dictname)",
+};
+
+static const SchemaQuery Query_for_list_of_text_search_parsers = {
+	.catname = "pg_catalog.pg_ts_parser t",
+	.viscondition = "pg_catalog.pg_ts_parser_is_visible(t.oid)",
+	.namespace = "t.prsnamespace",
+	.result = "pg_catalog.quote_ident(t.prsname)",
+};
+
+static const SchemaQuery Query_for_list_of_text_search_templates = {
+	.catname = "pg_catalog.pg_ts_template t",
+	.viscondition = "pg_catalog.pg_ts_template_is_visible(t.oid)",
+	.namespace = "t.tmplnamespace",
+	.result = "pg_catalog.quote_ident(t.tmplname)",
 };
 
 /* Relations supporting INSERT, UPDATE or DELETE */
@@ -628,7 +662,6 @@ static const SchemaQuery Query_for_list_of_collations = {
 	.result = "pg_catalog.quote_ident(c.collname)",
 };
 
-
 /*
  * Queries to get lists of names of various kinds of things, possibly
  * restricted to names matching a partially entered name.  In these queries,
@@ -767,6 +800,22 @@ static const SchemaQuery Query_for_list_of_collations = {
 " UNION ALL SELECT 'CURRENT_USER'"\
 " UNION ALL SELECT 'SESSION_USER'"
 
+#define Query_for_list_of_operator_class_index_methods \
+"SELECT pg_catalog.quote_ident(amname)"\
+"  FROM pg_catalog.pg_am"\
+" WHERE (%d = pg_catalog.length('%s'))"\
+"   AND oid IN "\
+"   (SELECT opcmethod FROM pg_catalog.pg_opclass "\
+" WHERE pg_catalog.quote_ident(opcname)='%s')"
+
+#define Query_for_list_of_operator_family_index_methods \
+"SELECT pg_catalog.quote_ident(amname)"\
+"  FROM pg_catalog.pg_am"\
+" WHERE (%d = pg_catalog.length('%s'))"\
+"   AND oid IN "\
+"   (SELECT opfmethod FROM 

Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-15 Thread Ken Kato

2021-10-15 13:29 に Shinya Kato さんは書きました:

On 2021-10-14 14:30, katouknl wrote:
It is very good, but it seems to me that there are some 
tab-completion

missing in COMMENT command.
For example,
- CONSTRAINT ... ON DOMAIN
- OPERATOR CLASS
- OPERATOR FAMILY
- POLICY ... ON
- [PROCEDURAL]
- RULE ... ON
- TRIGGER ... ON

I think these tab-comletion also can be improved and it's a good
timing for that.


Thank you for the comments!

I fixed where you pointed out.

Thank you for the update!
I tried "COMMENT ON OPERATOR ...", and an operator seemed to be
complemented with double quotation marks.
However, it caused the COMMENT command to fail.
---
postgres=# COMMENT ON OPERATOR "+" (integer, integer) IS 'test_fail';
ERROR:  syntax error at or near "("
LINE 1: COMMENT ON OPERATOR "+" (integer, integer) IS 'test_fail';
postgres=# COMMENT ON OPERATOR + (integer, integer) IS 'test_success';
COMMENT
---

So, I think as with \do command, you do not need to complete the 
operators.

Do you think?

Thank you for the further comments!

I fixed so that it doesn't complete the operators anymore.
It only completes with CLASS and FAMILY.

Also, I updated TEXT SEARCH.
It completes object names for each one of CONFIGURATION, DICTIONARY, 
PARSER, and TEMPLATE.


--
Best wishes,

Ken Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATIONdiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 5cd5838668..62f494630b 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -494,7 +494,6 @@ static const SchemaQuery Query_for_list_of_partitioned_indexes = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
-
 /* All relations */
 static const SchemaQuery Query_for_list_of_relations = {
 	.catname = "pg_catalog.pg_class c",
@@ -513,11 +512,46 @@ static const SchemaQuery Query_for_list_of_partitioned_relations = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
+static const SchemaQuery Query_for_list_of_operator_classes = {
+	.catname = "pg_catalog.pg_opclass o",
+	.viscondition = "pg_catalog.pg_opclass_is_visible(o.oid)",
+	.namespace = "o.opcnamespace",
+	.result = "pg_catalog.quote_ident(o.opcname)",
+};
+
 static const SchemaQuery Query_for_list_of_operator_families = {
-	.catname = "pg_catalog.pg_opfamily c",
-	.viscondition = "pg_catalog.pg_opfamily_is_visible(c.oid)",
-	.namespace = "c.opfnamespace",
-	.result = "pg_catalog.quote_ident(c.opfname)",
+	.catname = "pg_catalog.pg_opfamily o",
+	.viscondition = "pg_catalog.pg_opfamily_is_visible(o.oid)",
+	.namespace = "o.opfnamespace",
+	.result = "pg_catalog.quote_ident(o.opfname)",
+};
+
+static const SchemaQuery Query_for_list_of_text_search_configurations = {
+	.catname = "pg_catalog.pg_ts_config t",
+	.viscondition = "pg_catalog.pg_ts_config_is_visible(t.oid)",
+	.namespace = "t.cfgnamespace",
+	.result = "pg_catalog.quote_ident(t.cfgname)",
+};
+
+static const SchemaQuery Query_for_list_of_text_search_dictionaries = {
+	.catname = "pg_catalog.pg_ts_dict t",
+	.viscondition = "pg_catalog.pg_ts_dict_is_visible(t.oid)",
+	.namespace = "t.dictnamespace",
+	.result = "pg_catalog.quote_ident(t.dictname)",
+};
+
+static const SchemaQuery Query_for_list_of_text_search_parsers = {
+	.catname = "pg_catalog.pg_ts_parser t",
+	.viscondition = "pg_catalog.pg_ts_parser_is_visible(t.oid)",
+	.namespace = "t.prsnamespace",
+	.result = "pg_catalog.quote_ident(t.prsname)",
+};
+
+static const SchemaQuery Query_for_list_of_text_search_templates = {
+	.catname = "pg_catalog.pg_ts_template t",
+	.viscondition = "pg_catalog.pg_ts_template_is_visible(t.oid)",
+	.namespace = "t.tmplnamespace",
+	.result = "pg_catalog.quote_ident(t.tmplname)",
 };
 
 /* Relations supporting INSERT, UPDATE or DELETE */
@@ -628,7 +662,6 @@ static const SchemaQuery Query_for_list_of_collations = {
 	.result = "pg_catalog.quote_ident(c.collname)",
 };
 
-
 /*
  * Queries to get lists of names of various kinds of things, possibly
  * restricted to names matching a partially entered name.  In these queries,
@@ -767,6 +800,22 @@ static const SchemaQuery Query_for_list_of_collations = {
 " UNION ALL SELECT 'CURRENT_USER'"\
 " UNION ALL SELECT 'SESSION_USER'"
 
+#define Query_for_list_of_operator_class_index_methods \
+"SELECT pg_catalog.quote_ident(amname)"\
+"  FROM pg_catalog.pg_am"\
+" WHERE (%d = pg_catalog.length('%s'))"\
+"   AND  oid IN "\
+"   (SELECT opcmethod FROM pg_catalog.pg_opclass "\
+" WHERE pg_catalog.quote_ident(opcname)='%s')"
+
+#define Query_for_list_of_operator_family_index_methods \
+"SELECT pg_catalog.quote_ident(amname)"\
+"  FROM pg_catalog.pg_am"\
+" WHERE (%d = pg_catalog.length('%s'))"\
+"   AND oid IN "\
+"   (SELECT opfmethod FROM pg_catalog.pg_opfamily "\
+" WHERE pg_catalog.quote_ident(opfname)='%s')"
+
 /* the silly-looking length condition is just to eat up the current word */
 #define Query_for_index_of_table \
 "SELECT pg_catalog.quote_ident(c2.relname) "\
@@ -2399,22 

Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-14 Thread Shinya Kato

On 2021-10-14 14:30, katouknl wrote:

It is very good, but it seems to me that there are some tab-completion
missing in COMMENT command.
For example,
- CONSTRAINT ... ON DOMAIN
- OPERATOR CLASS
- OPERATOR FAMILY
- POLICY ... ON
- [PROCEDURAL]
- RULE ... ON
- TRIGGER ... ON

I think these tab-comletion also can be improved and it's a good
timing for that.


Thank you for the comments!

I fixed where you pointed out.

Thank you for the update!
I tried "COMMENT ON OPERATOR ...", and an operator seemed to be 
complemented with double quotation marks.

However, it caused the COMMENT command to fail.
---
postgres=# COMMENT ON OPERATOR "+" (integer, integer) IS 'test_fail';
ERROR:  syntax error at or near "("
LINE 1: COMMENT ON OPERATOR "+" (integer, integer) IS 'test_fail';
postgres=# COMMENT ON OPERATOR + (integer, integer) IS 'test_success';
COMMENT
---

So, I think as with \do command, you do not need to complete the 
operators.

Do you think?


--
Regards,

--
Shinya Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION




Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-13 Thread katouknl

It is very good, but it seems to me that there are some tab-completion
missing in COMMENT command.
For example,
- CONSTRAINT ... ON DOMAIN
- OPERATOR CLASS
- OPERATOR FAMILY
- POLICY ... ON
- [PROCEDURAL]
- RULE ... ON
- TRIGGER ... ON

I think these tab-comletion also can be improved and it's a good
timing for that.


Thank you for the comments!

I fixed where you pointed out.

Best wishes,
Ken Katodiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 5cd5838668..9b3651072f 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -494,7 +494,6 @@ static const SchemaQuery Query_for_list_of_partitioned_indexes = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
-
 /* All relations */
 static const SchemaQuery Query_for_list_of_relations = {
 	.catname = "pg_catalog.pg_class c",
@@ -513,6 +512,20 @@ static const SchemaQuery Query_for_list_of_partitioned_relations = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
+static const SchemaQuery Query_for_list_of_operators = {
+	.catname = "pg_catalog.pg_operator c",
+	.viscondition = "pg_catalog.pg_operator_is_visible(c.oid)",
+	.namespace = "c.oprnamespace",
+	.result = "pg_catalog.quote_ident(c.oprname)",
+};
+
+static const SchemaQuery Query_for_list_of_operator_classes = {
+	.catname = "pg_catalog.pg_opclass c",
+	.viscondition = "pg_catalog.pg_opclass_is_visible(c.oid)",
+	.namespace = "c.opcnamespace",
+	.result = "pg_catalog.quote_ident(c.opcname)",
+};
+
 static const SchemaQuery Query_for_list_of_operator_families = {
 	.catname = "pg_catalog.pg_opfamily c",
 	.viscondition = "pg_catalog.pg_opfamily_is_visible(c.oid)",
@@ -628,7 +641,6 @@ static const SchemaQuery Query_for_list_of_collations = {
 	.result = "pg_catalog.quote_ident(c.collname)",
 };
 
-
 /*
  * Queries to get lists of names of various kinds of things, possibly
  * restricted to names matching a partially entered name.  In these queries,
@@ -767,6 +779,22 @@ static const SchemaQuery Query_for_list_of_collations = {
 " UNION ALL SELECT 'CURRENT_USER'"\
 " UNION ALL SELECT 'SESSION_USER'"
 
+#define Query_for_list_of_operator_class_index_methods \
+"SELECT pg_catalog.quote_ident(amname)"\
+"  FROM pg_catalog.pg_am"\
+" WHERE (%d = pg_catalog.length('%s'))"\
+"   AND  oid IN "\
+"   (SELECT opcmethod FROM pg_catalog.pg_opclass "\
+" WHERE pg_catalog.quote_ident(opcname)='%s')"
+
+#define Query_for_list_of_operator_family_index_methods \
+"SELECT pg_catalog.quote_ident(amname)"\
+"  FROM pg_catalog.pg_am"\
+" WHERE (%d = pg_catalog.length('%s'))"\
+"   AND oid IN "\
+"   (SELECT opfmethod FROM pg_catalog.pg_opfamily "\
+" WHERE pg_catalog.quote_ident(opfname)='%s')"
+
 /* the silly-looking length condition is just to eat up the current word */
 #define Query_for_index_of_table \
 "SELECT pg_catalog.quote_ident(c2.relname) "\
@@ -2399,22 +2427,18 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT"))
 		COMPLETE_WITH("ON");
 	else if (Matches("COMMENT", "ON"))
-		COMPLETE_WITH("ACCESS METHOD", "CAST", "COLLATION", "CONVERSION",
-	  "DATABASE", "EVENT TRIGGER", "EXTENSION",
-	  "FOREIGN DATA WRAPPER", "FOREIGN TABLE", "SERVER",
-	  "INDEX", "LANGUAGE", "POLICY", "PUBLICATION", "RULE",
-	  "SCHEMA", "SEQUENCE", "STATISTICS", "SUBSCRIPTION",
-	  "TABLE", "TYPE", "VIEW", "MATERIALIZED VIEW",
-	  "COLUMN", "AGGREGATE", "FUNCTION",
-	  "PROCEDURE", "ROUTINE",
-	  "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN",
-	  "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
+		COMPLETE_WITH("ACCESS METHOD", "AGGREGATE", "CAST", "COLLATION", "COLUMN",
+	  "CONSTRAINT", "CONVERSION", "DATABASE", "DOMAIN",
+	  "EXTENSION", "EVENT TRIGGER", "FOREIGN DATA WRAPPER",
+	  "FOREIGN TABLE", "FUNCTION", "INDEX", "LANGUAGE",
+	  "LARGE OBJECT", "MATERIALIZED VIEW", "OPERATOR",
+	  "POLICY", "PROCEDURE", "PROCEDURAL", "PUBLICATION",
+	  "ROLE", "ROUTINE", "RULE", "SCHEMA", "SEQUENCE",
+	  "SERVER", "STATISTICS", "SUBSCRIPTION", "TABLE",
+	  "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR", "TRIGGER",
+	  "TYPE", "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
-	else if (Matches("COMMENT", "ON", "FOREIGN"))
-		COMPLETE_WITH("DATA WRAPPER", "TABLE");
-	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH"))
-		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
 		COMPLETE_WITH_QUERY(Query_for_all_table_constraints);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny))
@@ -2422,15 +2446,76 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny, "ON"))
 	{
 		completion_info_charp = prev2_wd;
-		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_constraint);
+		COMPLETE_WITH_QUERY(Query_for_list_of_tables_for_constraint
+" UNION 

Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-07 Thread Suraj Khamkar
Hello,
Thanks for the revised patch.

It is very good, but it seems to me that there are some tab-completion
> missing in COMMENT command.


Thanks Shinya, for having a look. I was also about to say that it would be
good
if we take care of tab-completion for other options as well in this patch
itself.
I would like to ask @katouknl  if it's ok to do
so.

And regarding the revised patch, arranging options in alphabetical order
seems
good to me. Though, there is one line where it crosses 80 characters in a
line.
+ COMPLETE_WITH("ACCESS METHOD", "AGGREGATE", "CAST", "COLLATION", "COLUMN",

Apart from this I don't have any major comment.


Regards,
Suraj Khamkar

On Thu, Oct 7, 2021 at 3:29 PM Shinya Kato 
wrote:

> On 2021-10-07 17:14, katouknl wrote:
> > Hi,
> >
> > Thank you for the review.
> >
> > I wasn't quite sure where to start counting the characters,
> > but I used pgindent to properly format it, so hopefully everything is
> > okay.
> > Also, I sorted them in alphabetical order just to make it look
> > prettier.
> >>  * The below change crosses the 80-character limit in a line. Please
> >> maintain the same.
> >> -   "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
> >> +   "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
> >> "ROLE");
> >
> > I made sure there is no whitespaces this time.
> >>  * There are trailing whitespaces after
> >> COMPLETE_WITH_QUERY(Query_for_list_of_languages);.
> >> Remove these extra whitespaces.
> >> surajkhamkar@localhost:tab_comment$ git apply
> >> fix_tab_complete_comment.patch
> >> fix_tab_complete_comment.patch:38: trailing whitespace.
> >> COMPLETE_WITH_QUERY(Query_for_list_of_languages);
> >> warning: 1 line adds whitespace errors.
> Thank you for the patch!
> It is very good, but it seems to me that there are some tab-completion
> missing in COMMENT command.
> For example,
> - CONSTRAINT ... ON DOMAIN
> - OPERATOR CLASS
> - OPERATOR FAMILY
> - POLICY ... ON
> - [PROCEDURAL]
> - RULE ... ON
> - TRIGGER ... ON
>
> I think these tab-comletion also can be improved and it's a good timing
> for that.
>
> --
> Regards,
>
> --
> Shinya Kato
> Advanced Computing Technology Center
> Research and Development Headquarters
> NTT DATA CORPORATION
>


Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-07 Thread Shinya Kato

On 2021-10-07 17:14, katouknl wrote:

Hi,

Thank you for the review.

I wasn't quite sure where to start counting the characters,
but I used pgindent to properly format it, so hopefully everything is 
okay.
Also, I sorted them in alphabetical order just to make it look 
prettier.

* The below change crosses the 80-character limit in a line. Please
maintain the same.
-   "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
+   "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
"ROLE");


I made sure there is no whitespaces this time.

* There are trailing whitespaces after
COMPLETE_WITH_QUERY(Query_for_list_of_languages);.
Remove these extra whitespaces.
surajkhamkar@localhost:tab_comment$ git apply
fix_tab_complete_comment.patch
fix_tab_complete_comment.patch:38: trailing whitespace.
COMPLETE_WITH_QUERY(Query_for_list_of_languages);
warning: 1 line adds whitespace errors.

Thank you for the patch!
It is very good, but it seems to me that there are some tab-completion 
missing in COMMENT command.

For example,
- CONSTRAINT ... ON DOMAIN
- OPERATOR CLASS
- OPERATOR FAMILY
- POLICY ... ON
- [PROCEDURAL]
- RULE ... ON
- TRIGGER ... ON

I think these tab-comletion also can be improved and it's a good timing 
for that.


--
Regards,

--
Shinya Kato
Advanced Computing Technology Center
Research and Development Headquarters
NTT DATA CORPORATION




Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-07 Thread katouknl

Hi,

Thank you for the review.

I wasn't quite sure where to start counting the characters,
but I used pgindent to properly format it, so hopefully everything is 
okay.

Also, I sorted them in alphabetical order just to make it look prettier.

* The below change crosses the 80-character limit in a line. Please
maintain the same.
-   "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
+   "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
"ROLE");


I made sure there is no whitespaces this time.

* There are trailing whitespaces after
COMPLETE_WITH_QUERY(Query_for_list_of_languages);.
Remove these extra whitespaces.
surajkhamkar@localhost:tab_comment$ git apply
fix_tab_complete_comment.patch
fix_tab_complete_comment.patch:38: trailing whitespace.
COMPLETE_WITH_QUERY(Query_for_list_of_languages);
warning: 1 line adds whitespace errors.


Best wishes,
Ken Katodiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 5cd5838668..0fc7b12f3f 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -494,7 +494,6 @@ static const SchemaQuery Query_for_list_of_partitioned_indexes = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
-
 /* All relations */
 static const SchemaQuery Query_for_list_of_relations = {
 	.catname = "pg_catalog.pg_class c",
@@ -628,7 +627,6 @@ static const SchemaQuery Query_for_list_of_collations = {
 	.result = "pg_catalog.quote_ident(c.collname)",
 };
 
-
 /*
  * Queries to get lists of names of various kinds of things, possibly
  * restricted to names matching a partially entered name.  In these queries,
@@ -2399,22 +2397,28 @@ psql_completion(const char *text, int start, int end)
 	else if (Matches("COMMENT"))
 		COMPLETE_WITH("ON");
 	else if (Matches("COMMENT", "ON"))
-		COMPLETE_WITH("ACCESS METHOD", "CAST", "COLLATION", "CONVERSION",
-	  "DATABASE", "EVENT TRIGGER", "EXTENSION",
-	  "FOREIGN DATA WRAPPER", "FOREIGN TABLE", "SERVER",
-	  "INDEX", "LANGUAGE", "POLICY", "PUBLICATION", "RULE",
-	  "SCHEMA", "SEQUENCE", "STATISTICS", "SUBSCRIPTION",
-	  "TABLE", "TYPE", "VIEW", "MATERIALIZED VIEW",
-	  "COLUMN", "AGGREGATE", "FUNCTION",
-	  "PROCEDURE", "ROUTINE",
-	  "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN",
-	  "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
+		COMPLETE_WITH("ACCESS METHOD", "AGGREGATE", "CAST", "COLLATION", "COLUMN",
+	  "CONSTRAINT", "CONVERSION", "DATABASE", "DOMAIN",
+	  "EXTENSION", "EVENT TRIGGER", "FOREIGN DATA WRAPPER",
+	  "FOREIGN TABLE", "FUNCTION", "INDEX", "LANGUAGE",
+	  "LARGE OBJECT", "MATERIALIZED VIEW", "OPERATOR",
+	  "POLICY", "PROCEDURE", "PUBLICATION", "ROLE",
+	  "ROUTINE", "RULE", "SCHEMA", "SEQUENCE", "SERVER",
+	  "STATISTICS", "SUBSCRIPTION", "TABLE", "TABLESPACE",
+	  "TEXT SEARCH", "TRANSFORM FOR", "TRIGGER", "TYPE",
+	  "VIEW");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 	else if (Matches("COMMENT", "ON", "FOREIGN"))
 		COMPLETE_WITH("DATA WRAPPER", "TABLE");
 	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH"))
 		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR", MatchAny))
+		COMPLETE_WITH("LANGUAGE");
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR", MatchAny, "LANGUAGE"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_languages);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
 		COMPLETE_WITH_QUERY(Query_for_all_table_constraints);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny))
@@ -2430,7 +2434,8 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers);
 	else if (Matches("COMMENT", "ON", MatchAny, MatchAnyExcept("IS")) ||
 			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAnyExcept("IS")) ||
-			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAny, MatchAnyExcept("IS")))
+			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAny, MatchAnyExcept("IS")) ||
+			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAny, MatchAny, MatchAnyExcept("IS")))
 		COMPLETE_WITH("IS");
 
 /* COPY */


Re: [PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-10-06 Thread Suraj Khamkar
Hello,
I reviewed your patch. At a first glance, I have the below comments.

   1. The below change crosses the 80-character limit in a line. Please
   maintain the same.
   -   "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
   +   "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR",
   "ROLE");
   2. There are trailing whitespaces after
   COMPLETE_WITH_QUERY(Query_for_list_of_languages);.
   Remove these extra whitespaces.
   surajkhamkar@localhost:tab_comment$ git apply
   fix_tab_complete_comment.patch
   fix_tab_complete_comment.patch:38: trailing whitespace.
   COMPLETE_WITH_QUERY(Query_for_list_of_languages);
   warning: 1 line adds whitespace errors.


Regards,
Suraj Khamkar

On Wed, Sep 29, 2021 at 2:04 PM katouknl  wrote:

> Hi,
>
> I created a patch for COMMENT tab completion.
> It was missing TRANSFORM FOR where it's supposed to be.
>
> Best wishes,
> Ken Kato


[PATCH] Added TRANSFORM FOR for COMMENT tab completion

2021-09-29 Thread katouknl

Hi,

I created a patch for COMMENT tab completion.
It was missing TRANSFORM FOR where it's supposed to be.

Best wishes,
Ken Katodiff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
index 5cd5838668..d18b26a4a5 100644
--- a/src/bin/psql/tab-complete.c
+++ b/src/bin/psql/tab-complete.c
@@ -494,7 +494,6 @@ static const SchemaQuery Query_for_list_of_partitioned_indexes = {
 	.result = "pg_catalog.quote_ident(c.relname)",
 };
 
-
 /* All relations */
 static const SchemaQuery Query_for_list_of_relations = {
 	.catname = "pg_catalog.pg_class c",
@@ -628,7 +627,6 @@ static const SchemaQuery Query_for_list_of_collations = {
 	.result = "pg_catalog.quote_ident(c.collname)",
 };
 
-
 /*
  * Queries to get lists of names of various kinds of things, possibly
  * restricted to names matching a partially entered name.  In these queries,
@@ -2408,13 +2406,19 @@ psql_completion(const char *text, int start, int end)
 	  "COLUMN", "AGGREGATE", "FUNCTION",
 	  "PROCEDURE", "ROUTINE",
 	  "OPERATOR", "TRIGGER", "CONSTRAINT", "DOMAIN",
-	  "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "ROLE");
+	  "LARGE OBJECT", "TABLESPACE", "TEXT SEARCH", "TRANSFORM FOR", "ROLE");
 	else if (Matches("COMMENT", "ON", "ACCESS", "METHOD"))
 		COMPLETE_WITH_QUERY(Query_for_list_of_access_methods);
 	else if (Matches("COMMENT", "ON", "FOREIGN"))
 		COMPLETE_WITH("DATA WRAPPER", "TABLE");
 	else if (Matches("COMMENT", "ON", "TEXT", "SEARCH"))
 		COMPLETE_WITH("CONFIGURATION", "DICTIONARY", "PARSER", "TEMPLATE");
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR"))
+		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_datatypes, NULL);
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR", MatchAny))
+		COMPLETE_WITH("LANGUAGE");
+	else if (Matches("COMMENT", "ON", "TRANSFORM", "FOR", MatchAny, "LANGUAGE"))
+		COMPLETE_WITH_QUERY(Query_for_list_of_languages);	
 	else if (Matches("COMMENT", "ON", "CONSTRAINT"))
 		COMPLETE_WITH_QUERY(Query_for_all_table_constraints);
 	else if (Matches("COMMENT", "ON", "CONSTRAINT", MatchAny))
@@ -2430,7 +2434,8 @@ psql_completion(const char *text, int start, int end)
 		COMPLETE_WITH_QUERY(Query_for_list_of_event_triggers);
 	else if (Matches("COMMENT", "ON", MatchAny, MatchAnyExcept("IS")) ||
 			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAnyExcept("IS")) ||
-			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAny, MatchAnyExcept("IS")))
+			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAny, MatchAnyExcept("IS")) ||
+			 Matches("COMMENT", "ON", MatchAny, MatchAny, MatchAny, MatchAny, MatchAnyExcept("IS")))
 		COMPLETE_WITH("IS");
 
 /* COPY */