Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf1926c9

Browse files
committed
Assorted tab-completion improvements in psql.
Add missing completions for:- ALTER SEQUENCE name OWNER TO- ALTER TYPE name RENAME TO- ALTER VIEW name ALTER COLUMN- ALTER VIEW name OWNER TO- ALTER VIEW name SET SCHEMAFix wrong completions for:- ALTER FUNCTION/AGGREGATE name (arguments) ... "(arguments)" has been ignored.- ALTER ... SET SCHEMA "SCHEMA" has been considered as a variable name.
1 parent7004434 commitf1926c9

File tree

1 file changed

+32
-10
lines changed

1 file changed

+32
-10
lines changed

‎src/bin/psql/tab-complete.c

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* Copyright (c) 2000-2010, PostgreSQL Global Development Group
55
*
6-
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.196 2010/02/26 02:01:20 momjian Exp $
6+
* $PostgreSQL: pgsql/src/bin/psql/tab-complete.c,v 1.197 2010/04/05 05:33:24 itagaki Exp $
77
*/
88

99
/*----------------------------------------------------------------------
@@ -507,6 +507,11 @@ static const SchemaQuery Query_for_list_of_views = {
507507
" FROM pg_catalog.pg_am "\
508508
" WHERE substring(pg_catalog.quote_ident(amname),1,%d)='%s'"
509509

510+
#defineQuery_for_list_of_arguments \
511+
" SELECT pg_catalog.oidvectortypes(proargtypes)||')' "\
512+
" FROM pg_catalog.pg_proc "\
513+
" WHERE proname='%s'"
514+
510515
/*
511516
* This is a list of all "things" in Pgsql, which can show up after CREATE or
512517
* DROP; and there is also a query to get a list of them.
@@ -705,11 +710,27 @@ psql_completion(char *text, int start, int end)
705710
elseif (pg_strcasecmp(prev3_wd,"ALTER")==0&&
706711
(pg_strcasecmp(prev2_wd,"AGGREGATE")==0||
707712
pg_strcasecmp(prev2_wd,"FUNCTION")==0))
713+
COMPLETE_WITH_CONST("(");
714+
/* ALTER AGGREGATE,FUNCTION <name> (...) */
715+
elseif (pg_strcasecmp(prev4_wd,"ALTER")==0&&
716+
(pg_strcasecmp(prev3_wd,"AGGREGATE")==0||
717+
pg_strcasecmp(prev3_wd,"FUNCTION")==0))
708718
{
709-
staticconstchar*constlist_ALTERAGG[]=
710-
{"OWNER TO","RENAME TO","SET SCHEMA",NULL};
719+
if (prev_wd[strlen(prev_wd)-1]==')')
720+
{
721+
staticconstchar*constlist_ALTERAGG[]=
722+
{"OWNER TO","RENAME TO","SET SCHEMA",NULL};
711723

712-
COMPLETE_WITH_LIST(list_ALTERAGG);
724+
COMPLETE_WITH_LIST(list_ALTERAGG);
725+
}
726+
else
727+
{
728+
char*tmp_buf=malloc(strlen(Query_for_list_of_arguments)+strlen(prev2_wd));
729+
730+
sprintf(tmp_buf,Query_for_list_of_arguments,prev2_wd);
731+
COMPLETE_WITH_QUERY(tmp_buf);
732+
free(tmp_buf);
733+
}
713734
}
714735

715736
/* ALTER CONVERSION,SCHEMA <name> */
@@ -860,7 +881,7 @@ psql_completion(char *text, int start, int end)
860881
{
861882
staticconstchar*constlist_ALTERSEQUENCE[]=
862883
{"INCREMENT","MINVALUE","MAXVALUE","RESTART","NO","CACHE","CYCLE",
863-
"SET SCHEMA","OWNED BY","RENAME TO",NULL};
884+
"SET SCHEMA","OWNED BY","OWNER TO","RENAME TO",NULL};
864885

865886
COMPLETE_WITH_LIST(list_ALTERSEQUENCE);
866887
}
@@ -887,7 +908,8 @@ psql_completion(char *text, int start, int end)
887908
elseif (pg_strcasecmp(prev3_wd,"ALTER")==0&&
888909
pg_strcasecmp(prev2_wd,"VIEW")==0)
889910
{
890-
staticconstchar*constlist_ALTERVIEW[]= {"RENAME TO",NULL};
911+
staticconstchar*constlist_ALTERVIEW[]=
912+
{"ALTER COLUMN","OWNER TO","RENAME TO","SET SCHEMA",NULL};
891913

892914
COMPLETE_WITH_LIST(list_ALTERVIEW);
893915
}
@@ -1206,7 +1228,7 @@ psql_completion(char *text, int start, int end)
12061228
pg_strcasecmp(prev2_wd,"TYPE")==0)
12071229
{
12081230
staticconstchar*constlist_ALTERTYPE[]=
1209-
{"OWNER TO","SET SCHEMA",NULL};
1231+
{"OWNER TO","RENAME TO","SET SCHEMA",NULL};
12101232

12111233
COMPLETE_WITH_LIST(list_ALTERTYPE);
12121234
}
@@ -1761,10 +1783,9 @@ psql_completion(char *text, int start, int end)
17611783
pg_strcasecmp(prev3_wd,"FUNCTION")==0)&&
17621784
pg_strcasecmp(prev_wd,"(")==0)
17631785
{
1764-
staticconstcharfunc_args_query[]="select pg_catalog.oidvectortypes(proargtypes)||')' from pg_proc where proname='%s'";
1765-
char*tmp_buf=malloc(strlen(func_args_query)+strlen(prev2_wd));
1786+
char*tmp_buf=malloc(strlen(Query_for_list_of_arguments)+strlen(prev2_wd));
17661787

1767-
sprintf(tmp_buf,func_args_query,prev2_wd);
1788+
sprintf(tmp_buf,Query_for_list_of_arguments,prev2_wd);
17681789
COMPLETE_WITH_QUERY(tmp_buf);
17691790
free(tmp_buf);
17701791
}
@@ -2230,6 +2251,7 @@ psql_completion(char *text, int start, int end)
22302251
elseif (pg_strcasecmp(prev2_wd,"SET")==0&&
22312252
pg_strcasecmp(prev4_wd,"UPDATE")!=0&&
22322253
pg_strcasecmp(prev_wd,"TABLESPACE")!=0&&
2254+
pg_strcasecmp(prev_wd,"SCHEMA")!=0&&
22332255
prev_wd[strlen(prev_wd)-1]!=')'&&
22342256
pg_strcasecmp(prev4_wd,"DOMAIN")!=0)
22352257
COMPLETE_WITH_CONST("TO");

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp