Tab completion for INHERIT and NO INHERIT

Started by Jeff Janesover 13 years ago2 messages
#1Jeff Janes
jeff.janes@gmail.com
1 attachment(s)

I was playing around with partitioning recently, and was annoyed that
tab completion doesn't work for setting the table to (dis)inherit.

It seemed easy enough to add.

For the "NO INHERIT" case, it would be nice to complete only table
names currently being inherited by the first table, but I don't know
how to make that happen.

Cheers,

Jeff

Attachments:

complete_inherit_v1.patchapplication/octet-stream; name=complete_inherit_v1.patchDownload
diff --git a/src/bin/psql/tab-complete.c b/src/bin/psql/tab-complete.c
new file mode 100644
index 6b5dd49..a1bb230
*** a/src/bin/psql/tab-complete.c
--- b/src/bin/psql/tab-complete.c
*************** psql_completion(char *text, int start, i
*** 1261,1266 ****
--- 1261,1281 ----
  
  		COMPLETE_WITH_LIST(list_ALTERENABLE2);
  	}
+ 	/* ALTER TABLE xxx INHERIT */
+ 	else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
+ 			 pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
+ 			 pg_strcasecmp(prev_wd, "INHERIT") == 0)
+ 	{
+ 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, "");
+ 	}
+ 	/* ALTER TABLE xxx NO INHERIT */
+ 	else if (pg_strcasecmp(prev5_wd, "ALTER") == 0 &&
+ 			 pg_strcasecmp(prev4_wd, "TABLE") == 0 &&
+ 			 pg_strcasecmp(prev2_wd, "NO") == 0 &&
+ 			 pg_strcasecmp(prev_wd, "INHERIT") == 0)
+ 	{
+ 		COMPLETE_WITH_SCHEMA_QUERY(Query_for_list_of_tables, "");
+ 	}
  	else if (pg_strcasecmp(prev4_wd, "ALTER") == 0 &&
  			 pg_strcasecmp(prev3_wd, "TABLE") == 0 &&
  			 pg_strcasecmp(prev_wd, "DISABLE") == 0)
#2Robert Haas
robertmhaas@gmail.com
In reply to: Jeff Janes (#1)
Re: Tab completion for INHERIT and NO INHERIT

On Mon, Jul 23, 2012 at 9:22 PM, Jeff Janes <jeff.janes@gmail.com> wrote:

I was playing around with partitioning recently, and was annoyed that
tab completion doesn't work for setting the table to (dis)inherit.

Thanks for the patch. Committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company