Hello All,
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:
wsdb=# \d q3c
Table "public.q3c"
Column | Type | Modifiers
--------+------------------+-----------
ipix | bigint |
ra | double precision |
dec | double precision |
Now if I do
wsdb# create index xxx on q3c
<press tab>
wsdb# CREATE INDEX xxx on q3c (
<press tab>
wsdb=# CREATE INDEX xxx on q3c (
"dec" ipix ra
<press r>
wsdb=# CREATE INDEX xxx on q3c ( ra
Regards,
Sergey
*****************************************************
Sergey E. Koposov
Max-Planck Institut for Astronomy
Web: http://lnfm1.sai.msu.ru/~math
E-mail: [EMAIL PROTECTED]
Index: tab-complete.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/tab-complete.c,v
retrieving revision 1.141
diff -r1.141 tab-complete.c
478a479,480
> static int find_open_parenthesis(int end);
>
1019c1021,1037
< 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);
> }
>
1225,1228c1243,1275
< static const char *const list_DROPCR[] =
< {"CASCADE", "RESTRICT", NULL};
<
< COMPLETE_WITH_LIST(list_DROPCR);
---
>
> if ((pg_strcasecmp(prev3_wd, "DROP") == 0) &&
> (pg_strcasecmp(prev2_wd, "FUNCTION") == 0))
> {
> 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);
1230a1278,1279
>
>
2249a2299,2319
> /* 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;
2250a2321
> }
---------------------------(end of broadcast)---------------------------
TIP 9: In versions below 8.0, the planner will ignore your desire to
choose an index scan if your joining column's datatypes do not
match