Re: [PATCHES] psql tab-completion improvements

2004-09-21 Thread Neil Conway
On Wed, 2004-09-01 at 09:34, Greg Sabino Mullane wrote:
> Some improvements for the tab-completion of psql. This should 
> address all of the items in the todo list and adds some new 
> things as well.

Patch applied. Thanks.

Bruce: this was also on the pending list.

-Neil



---(end of broadcast)---
TIP 7: don't forget to increase your free space map settings


Re: [PATCHES] psql tab-completion improvements

2004-09-10 Thread Gaetano Mendola
Bruce Momjian wrote:
Neil Conway wrote:
Bruce Momjian wrote:
Is this for 8.0?  Seems it is fixes.
Personally, I think it is more feature work than fixes. But I wouldn't 
object to committing it to HEAD in time for 8.0, because it is likely 
low-impact.

That was my feeling.  Part fix, part low impact.
Is there a "low impact" concept that override the "feature freeze" ?
Regards
Gaetano Mendola

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] psql tab-completion improvements

2004-09-09 Thread Bruce Momjian
Neil Conway wrote:
> Bruce Momjian wrote:
> > Is this for 8.0?  Seems it is fixes.
> 
> Personally, I think it is more feature work than fixes. But I wouldn't 
> object to committing it to HEAD in time for 8.0, because it is likely 
> low-impact.

That was my feeling.  Part fix, part low impact.

-- 
  Bruce Momjian|  http://candle.pha.pa.us
  [EMAIL PROTECTED]   |  (610) 359-1001
  +  If your life is a hard drive, |  13 Roberts Road
  +  Christ can be your backup.|  Newtown Square, Pennsylvania 19073

---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] psql tab-completion improvements

2004-09-09 Thread Neil Conway
Bruce Momjian wrote:
Is this for 8.0?  Seems it is fixes.
Personally, I think it is more feature work than fixes. But I wouldn't 
object to committing it to HEAD in time for 8.0, because it is likely 
low-impact.

-Neil
---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] psql tab-completion improvements

2004-09-09 Thread Greg Sabino Mullane

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
 
 
> Is this for 8.0? Seems it is fixes?
 
Well, there are no new features in it anyway. My vote is for 8.0,
if only so that any bugs get found quicker and fixed for 8.1 :)
 
- --
Greg Sabino Mullane [EMAIL PROTECTED]
PGP Key: 0x14964AC8 200409092206
 
-BEGIN PGP SIGNATURE-
 
iD8DBQFBQQwnvJuQZxSWSsgRAlWpAJ9AoWuGTGM9ix/ZcTy/lCaJ0c0qWACgh8Jm
2GAeWoEEjOorvxNWDHDIYHo=
=vLEd
-END PGP SIGNATURE-



---(end of broadcast)---
TIP 8: explain analyze is your friend


Re: [PATCHES] psql tab-completion improvements

2004-09-09 Thread Bruce Momjian

Is this for 8.0?  Seems it is fixes.

---

Greg Sabino Mullane wrote:
[ There is text before PGP section. ]
> 
[ PGP not available, raw data follows ]
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA1
> NotDashEscaped: You need GnuPG to verify this message
> 
> 
> Some improvements for the tab-completion of psql. This should 
> address all of the items in the todo list and adds some new 
> things as well. Specifically:
> 
> * Add support for ALTER SEQUENCE ...
> * Add "RENAME TO" for ALTER TRIGGER xx ON yy
> * Pick proper table for ALTER TRIGGER xx ON ...
> * Support for ALTER USER xxx ...
> * Fix ALTER GROUP xxx DROP ...
> * Fix ALTER DOMAIN xxx DROP ...
> * Remove "OWNER TO" from ALTER DOMAIN xx DROP ...
> * Fix ALTER DOMAIN xx SET DEFAULT ..
> * Prevent ALTER INDEX xxx SET TABLESPACE from using "TO"
> * Support for ALTER LANGUAGE xxx (RENAME TO)
> * More support for ALTER TABLE xxx ALTER COLUMN xxx ...
> * More support for COPY
> 
> --
> Greg Sabino Mullane [EMAIL PROTECTED]
> PGP Key: 0x14964AC8 200408311930
> 
> 
> 
> 
> Index: tab-complete.c
> ===
> RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/tab-complete.c,v
> retrieving revision 1.114
> diff -c -r1.114 tab-complete.c
> *** tab-complete.c29 Aug 2004 05:06:54 -  1.114
> --- tab-complete.c31 Aug 2004 23:25:07 -
> ***
> *** 386,391 
> --- 386,400 
>   "   and pg_catalog.quote_ident(c1.relname)='%s'"\
>   "   and pg_catalog.pg_table_is_visible(c2.oid)"
>   
> + /* the silly-looking length condition is just to eat up the current word */
> + #define Query_for_list_of_tables_for_trigger \
> + "SELECT pg_catalog.quote_ident(relname) "\
> + "  FROM pg_catalog.pg_class"\
> + " WHERE (%d = length('%s'))"\
> + "   AND oid IN "\
> + "   (SELECT tgrelid FROM pg_catalog.pg_trigger "\
> + " WHERE pg_catalog.quote_ident(tgname)='%s')"
> + 
>   /*
>* This is a list of all "things" in Pgsql, which can show up after CREATE or
>* DROP; and there is also a query to get a list of them.
> ***
> *** 637,647 
>   else if (!prev_wd)
>   COMPLETE_WITH_LIST(sql_commands);
>   
> ! /* CREATE or DROP but not ALTER TABLE sth DROP */
>   /* complete with something you can create or drop */
>   else if (pg_strcasecmp(prev_wd, "CREATE") == 0 ||
>(pg_strcasecmp(prev_wd, "DROP") == 0 &&
> !   pg_strcasecmp(prev3_wd, "TABLE") != 0))
>   matches = completion_matches(text, create_command_generator);
>   
>   /* ALTER */
> --- 646,658 
>   else if (!prev_wd)
>   COMPLETE_WITH_LIST(sql_commands);
>   
> ! /* CREATE or DROP but not ALTER (TABLE|DOMAIN|GROUP) sth DROP */
>   /* complete with something you can create or drop */
>   else if (pg_strcasecmp(prev_wd, "CREATE") == 0 ||
>(pg_strcasecmp(prev_wd, "DROP") == 0 &&
> !   pg_strcasecmp(prev3_wd, "TABLE") != 0 &&
> !   pg_strcasecmp(prev3_wd, "DOMAIN") != 0 &&
> !   pg_strcasecmp(prev3_wd, "GROUP") != 0))
>   matches = completion_matches(text, create_command_generator);
>   
>   /* ALTER */
> ***
> *** 694,699 
> --- 705,726 
>   COMPLETE_WITH_LIST(list_ALTERINDEX);
>   }
>   
> + /* ALTER LANGUAGE  */
> + else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
> +  pg_strcasecmp(prev2_wd, "LANGUAGE") == 0)
> + COMPLETE_WITH_CONST("RENAME TO");
> + 
> + /* ALTER USER  */
> + else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
> +  pg_strcasecmp(prev2_wd, "USER") == 0)
> + {
> + static const char *const list_ALTERUSER[] =
> + {"ENCRYPTED", "UNENCRYPTED", "CREATEDB", "NOCREATEDB", "CREATEUSER",
> +  "NOCREATEUSER", "VALID UNTIL", "RENAME TO", "SET", "RESET", NULL};
> + 
> + COMPLETE_WITH_LIST(list_ALTERUSER);
> + }
> + 
>   /* ALTER DOMAIN  */
>   else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
>pg_strcasecmp(prev2_wd, "DOMAIN") == 0)
> ***
> *** 709,715 
>pg_strcasecmp(prev_wd, "DROP") == 0)
>   {
>   static const char *const list_ALTERDOMAIN2[] =
> ! {"CONSTRAINT", "DEFAULT", "NOT NULL", "OWNER TO", NULL};
>   
>   COMPLETE_WITH_LIST(list_ALTERDOMAIN2);
>   }
> --- 736,742 
>pg_strcasecmp(prev_wd, "DROP") == 0)
>   {
>   static const char *const list_ALTERDOMAIN2[] =
> ! {"CONSTRAINT", "DEFAULT", "NOT NULL", NULL};
>   
>   COMPLETE_WITH_LIST(list_ALTERDOMAIN2);
>   }
> ***
> *** 723,733 
>   
>   COMPLETE_WITH_LIST(list_ALTER

[PATCHES] psql tab-completion improvements

2004-08-31 Thread Greg Sabino Mullane

-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1
NotDashEscaped: You need GnuPG to verify this message


Some improvements for the tab-completion of psql. This should 
address all of the items in the todo list and adds some new 
things as well. Specifically:

* Add support for ALTER SEQUENCE ...
* Add "RENAME TO" for ALTER TRIGGER xx ON yy
* Pick proper table for ALTER TRIGGER xx ON ...
* Support for ALTER USER xxx ...
* Fix ALTER GROUP xxx DROP ...
* Fix ALTER DOMAIN xxx DROP ...
* Remove "OWNER TO" from ALTER DOMAIN xx DROP ...
* Fix ALTER DOMAIN xx SET DEFAULT ..
* Prevent ALTER INDEX xxx SET TABLESPACE from using "TO"
* Support for ALTER LANGUAGE xxx (RENAME TO)
* More support for ALTER TABLE xxx ALTER COLUMN xxx ...
* More support for COPY

--
Greg Sabino Mullane [EMAIL PROTECTED]
PGP Key: 0x14964AC8 200408311930




Index: tab-complete.c
===
RCS file: /projects/cvsroot/pgsql-server/src/bin/psql/tab-complete.c,v
retrieving revision 1.114
diff -c -r1.114 tab-complete.c
*** tab-complete.c  29 Aug 2004 05:06:54 -  1.114
--- tab-complete.c  31 Aug 2004 23:25:07 -
***
*** 386,391 
--- 386,400 
  "   and pg_catalog.quote_ident(c1.relname)='%s'"\
  "   and pg_catalog.pg_table_is_visible(c2.oid)"
  
+ /* the silly-looking length condition is just to eat up the current word */
+ #define Query_for_list_of_tables_for_trigger \
+ "SELECT pg_catalog.quote_ident(relname) "\
+ "  FROM pg_catalog.pg_class"\
+ " WHERE (%d = length('%s'))"\
+ "   AND oid IN "\
+ "   (SELECT tgrelid FROM pg_catalog.pg_trigger "\
+ " WHERE pg_catalog.quote_ident(tgname)='%s')"
+ 
  /*
   * This is a list of all "things" in Pgsql, which can show up after CREATE or
   * DROP; and there is also a query to get a list of them.
***
*** 637,647 
else if (!prev_wd)
COMPLETE_WITH_LIST(sql_commands);
  
! /* CREATE or DROP but not ALTER TABLE sth DROP */
/* complete with something you can create or drop */
else if (pg_strcasecmp(prev_wd, "CREATE") == 0 ||
 (pg_strcasecmp(prev_wd, "DROP") == 0 &&
! pg_strcasecmp(prev3_wd, "TABLE") != 0))
matches = completion_matches(text, create_command_generator);
  
  /* ALTER */
--- 646,658 
else if (!prev_wd)
COMPLETE_WITH_LIST(sql_commands);
  
! /* CREATE or DROP but not ALTER (TABLE|DOMAIN|GROUP) sth DROP */
/* complete with something you can create or drop */
else if (pg_strcasecmp(prev_wd, "CREATE") == 0 ||
 (pg_strcasecmp(prev_wd, "DROP") == 0 &&
! pg_strcasecmp(prev3_wd, "TABLE") != 0 &&
! pg_strcasecmp(prev3_wd, "DOMAIN") != 0 &&
! pg_strcasecmp(prev3_wd, "GROUP") != 0))
matches = completion_matches(text, create_command_generator);
  
  /* ALTER */
***
*** 694,699 
--- 705,726 
COMPLETE_WITH_LIST(list_ALTERINDEX);
}
  
+   /* ALTER LANGUAGE  */
+   else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
+pg_strcasecmp(prev2_wd, "LANGUAGE") == 0)
+   COMPLETE_WITH_CONST("RENAME TO");
+ 
+   /* ALTER USER  */
+   else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
+pg_strcasecmp(prev2_wd, "USER") == 0)
+   {
+   static const char *const list_ALTERUSER[] =
+   {"ENCRYPTED", "UNENCRYPTED", "CREATEDB", "NOCREATEDB", "CREATEUSER",
+"NOCREATEUSER", "VALID UNTIL", "RENAME TO", "SET", "RESET", NULL};
+ 
+   COMPLETE_WITH_LIST(list_ALTERUSER);
+   }
+ 
/* ALTER DOMAIN  */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
 pg_strcasecmp(prev2_wd, "DOMAIN") == 0)
***
*** 709,715 
 pg_strcasecmp(prev_wd, "DROP") == 0)
{
static const char *const list_ALTERDOMAIN2[] =
!   {"CONSTRAINT", "DEFAULT", "NOT NULL", "OWNER TO", NULL};
  
COMPLETE_WITH_LIST(list_ALTERDOMAIN2);
}
--- 736,742 
 pg_strcasecmp(prev_wd, "DROP") == 0)
{
static const char *const list_ALTERDOMAIN2[] =
!   {"CONSTRAINT", "DEFAULT", "NOT NULL", NULL};
  
COMPLETE_WITH_LIST(list_ALTERDOMAIN2);
}
***
*** 723,733 
  
COMPLETE_WITH_LIST(list_ALTERDOMAIN3);
}
/* ALTER TRIGGER , add ON */
else if (pg_strcasecmp(prev3_wd, "ALTER") == 0 &&
!pg_strcasecmp(prev2_wd, "TRIGGER") == 0 &&
!pg_strcasecmp(prev_wd, "ON") != 0)
!   COMPLETE_WITH_CONST("ON");
  
/*
 * If we have ALTER TRIGGER  ON, then add the correct tablename
--- 750