On Fri, 1 Jul 2005, Bruce Momjian wrote:

Heikki Linnakangas wrote:
On Fri, 1 Jul 2005, Oliver Jowett wrote:

PS: noticed in passing: psql's help doesn't seem to know about the 2PC
command syntax yet.

True.

Should we add support for it? 2PC is not something you normally do
interactively...

Yes, we should add psql support for it.

Ok, here's a patch.

There's no tab-completion for "PREPARE TRANSACTION 'xxx'" since that would be ambigous with "PREPARE xxx AS xx".

- Heikki
Index: src/bin/psql/tab-complete.c
===================================================================
RCS file: /projects/cvsroot/pgsql/src/bin/psql/tab-complete.c,v
retrieving revision 1.133
diff -c -r1.133 tab-complete.c
*** src/bin/psql/tab-complete.c 22 Jun 2005 21:14:30 -0000      1.133
--- src/bin/psql/tab-complete.c 1 Jul 2005 18:34:20 -0000
***************
*** 926,941 ****
                         pg_strcasecmp(prev_wd, "USER") == 0)
                COMPLETE_WITH_QUERY(Query_for_list_of_users);
  
! /* BEGIN, END, COMMIT, ABORT */
        else if (pg_strcasecmp(prev_wd, "BEGIN") == 0 ||
                         pg_strcasecmp(prev_wd, "END") == 0 ||
-                        pg_strcasecmp(prev_wd, "COMMIT") == 0 ||
                         pg_strcasecmp(prev_wd, "ABORT") == 0)
        {
                static const char *const list_TRANS[] =
                {"WORK", "TRANSACTION", NULL};
  
                COMPLETE_WITH_LIST(list_TRANS);
        }
  /* RELEASE SAVEPOINT */
        else if (pg_strcasecmp(prev_wd, "RELEASE") == 0)
--- 926,948 ----
                         pg_strcasecmp(prev_wd, "USER") == 0)
                COMPLETE_WITH_QUERY(Query_for_list_of_users);
  
! /* BEGIN, END, ABORT */
        else if (pg_strcasecmp(prev_wd, "BEGIN") == 0 ||
                         pg_strcasecmp(prev_wd, "END") == 0 ||
                         pg_strcasecmp(prev_wd, "ABORT") == 0)
        {
                static const char *const list_TRANS[] =
                {"WORK", "TRANSACTION", NULL};
  
                COMPLETE_WITH_LIST(list_TRANS);
+       } 
+ /* COMMIT */
+       else if(pg_strcasecmp(prev_wd, "COMMIT") == 0)
+       {
+               static const char *const list_COMMIT[] =
+               {"WORK", "TRANSACTION", "PREPARED", NULL};
+ 
+               COMPLETE_WITH_LIST(list_COMMIT);
        }
  /* RELEASE SAVEPOINT */
        else if (pg_strcasecmp(prev_wd, "RELEASE") == 0)
***************
*** 944,950 ****
        else if (pg_strcasecmp(prev_wd, "ROLLBACK") == 0)
        {
                static const char *const list_TRANS[] =
!               {"WORK", "TRANSACTION", "TO SAVEPOINT", NULL};
  
                COMPLETE_WITH_LIST(list_TRANS);
        }
--- 951,957 ----
        else if (pg_strcasecmp(prev_wd, "ROLLBACK") == 0)
        {
                static const char *const list_TRANS[] =
!               {"WORK", "TRANSACTION", "TO SAVEPOINT", "PREPARED", NULL};
  
                COMPLETE_WITH_LIST(list_TRANS);
        }
---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to [EMAIL PROTECTED] so that your
       message can get through to the mailing list cleanly

Reply via email to