mirror of
https://github.com/postgres/postgres.git
synced 2025-06-02 00:01:40 -04:00
> 1) I'm proposing a patch to do the DROP FUNCTION argument tab completion.
> Now, the arguments of the drop function can be tab completed. for example > > drop function strpos ( > <press tab> > drop FUNCTION strpos (text, text) > > or: > > wsdb=# drop FUNCTION length ( > bit) bytea) character) lseg) path) text) > <press c> > wsdb# DROP FUNCTION length ( character) > > I think that this patch should be rather useful. At it least I hate > always to type all the arguments of the dropped functions. > > 2) Also some fixes applied for the > CREATE INDEX syntax > > now the parenthesises are inserted by tab pressing. > suppose I have the table q3c: Sergey E. Koposov
This commit is contained in:
parent
2986f42984
commit
c03aa1f9c9
@ -3,7 +3,7 @@
|
|||||||
*
|
*
|
||||||
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
* Copyright (c) 2000-2005, PostgreSQL Global Development Group
|
||||||
*
|
*
|
||||||
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.141 2005/11/18 16:31:11 alvherre Exp $
|
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.142 2005/12/08 21:33:58 momjian Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
@ -476,6 +476,8 @@ static PGresult *exec_query(const char *query);
|
|||||||
|
|
||||||
static char *previous_word(int point, int skip);
|
static char *previous_word(int point, int skip);
|
||||||
|
|
||||||
|
static int find_open_parenthesis(int end);
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
static char *quote_file_name(char *text, int match_type, char *quote_pointer);
|
static char *quote_file_name(char *text, int match_type, char *quote_pointer);
|
||||||
static char *dequote_file_name(char *text, char quote_char);
|
static char *dequote_file_name(char *text, char quote_char);
|
||||||
@ -1016,7 +1018,16 @@ psql_completion(char *text, int start, int end)
|
|||||||
*/
|
*/
|
||||||
else if (pg_strcasecmp(prev4_wd, "INDEX") == 0 &&
|
else if (pg_strcasecmp(prev4_wd, "INDEX") == 0 &&
|
||||||
pg_strcasecmp(prev2_wd, "ON") == 0)
|
pg_strcasecmp(prev2_wd, "ON") == 0)
|
||||||
COMPLETE_WITH_ATTR(prev_wd);
|
{
|
||||||
|
if (find_open_parenthesis(end))
|
||||||
|
COMPLETE_WITH_ATTR(prev_wd);
|
||||||
|
else
|
||||||
|
COMPLETE_WITH_CONST("(");
|
||||||
|
}
|
||||||
|
else if (pg_strcasecmp(prev5_wd, "INDEX") == 0 &&
|
||||||
|
pg_strcasecmp(prev3_wd, "ON") == 0 &&
|
||||||
|
pg_strcasecmp(prev_wd, "(") == 0)
|
||||||
|
COMPLETE_WITH_ATTR(prev2_wd);
|
||||||
/* same if you put in USING */
|
/* same if you put in USING */
|
||||||
else if (pg_strcasecmp(prev4_wd, "ON") == 0 &&
|
else if (pg_strcasecmp(prev4_wd, "ON") == 0 &&
|
||||||
pg_strcasecmp(prev2_wd, "USING") == 0)
|
pg_strcasecmp(prev2_wd, "USING") == 0)
|
||||||
@ -1222,11 +1233,42 @@ psql_completion(char *text, int start, int end)
|
|||||||
pg_strcasecmp(prev3_wd, "AGGREGATE") == 0 &&
|
pg_strcasecmp(prev3_wd, "AGGREGATE") == 0 &&
|
||||||
prev_wd[strlen(prev_wd) - 1] == ')'))
|
prev_wd[strlen(prev_wd) - 1] == ')'))
|
||||||
{
|
{
|
||||||
static const char *const list_DROPCR[] =
|
|
||||||
{"CASCADE", "RESTRICT", NULL};
|
if ((pg_strcasecmp(prev3_wd, "DROP") == 0) && (pg_strcasecmp(prev2_wd, "FUNCTION") == 0))
|
||||||
|
{
|
||||||
COMPLETE_WITH_LIST(list_DROPCR);
|
if (find_open_parenthesis(end))
|
||||||
|
{
|
||||||
|
static const char func_args_query[] = "select pg_catalog.oidvectortypes(proargtypes)||')' from pg_proc where proname='%s'";
|
||||||
|
char *tmp_buf = malloc(strlen(func_args_query) + strlen(prev_wd));
|
||||||
|
sprintf(tmp_buf, func_args_query, prev_wd);
|
||||||
|
COMPLETE_WITH_QUERY(tmp_buf);
|
||||||
|
free(tmp_buf);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
COMPLETE_WITH_CONST("(");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
static const char *const list_DROPCR[] =
|
||||||
|
{"CASCADE", "RESTRICT", NULL};
|
||||||
|
|
||||||
|
COMPLETE_WITH_LIST(list_DROPCR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (pg_strcasecmp(prev4_wd, "DROP") == 0 &&
|
||||||
|
pg_strcasecmp(prev3_wd, "FUNCTION") == 0 &&
|
||||||
|
pg_strcasecmp(prev_wd, "(") == 0 )
|
||||||
|
{
|
||||||
|
static const char func_args_query[] = "select pg_catalog.oidvectortypes(proargtypes)||')' from pg_proc where proname='%s'";
|
||||||
|
char *tmp_buf = malloc(strlen(func_args_query) + strlen(prev2_wd));
|
||||||
|
sprintf(tmp_buf, func_args_query, prev2_wd);
|
||||||
|
COMPLETE_WITH_QUERY(tmp_buf);
|
||||||
|
free(tmp_buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* EXPLAIN */
|
/* EXPLAIN */
|
||||||
|
|
||||||
@ -2247,8 +2289,30 @@ previous_word(int point, int skip)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Find the parenthesis after the last word */
|
||||||
|
|
||||||
|
|
||||||
|
static int find_open_parenthesis(int end)
|
||||||
|
{
|
||||||
|
int i = end-1;
|
||||||
|
|
||||||
|
while((rl_line_buffer[i]!=' ')&&(i>=0))
|
||||||
|
{
|
||||||
|
if (rl_line_buffer[i]=='(') return 1;
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
while((rl_line_buffer[i]==' ')&&(i>=0))
|
||||||
|
{
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
if (rl_line_buffer[i]=='(')
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
x
Reference in New Issue
Block a user