Re: Patch to change psql default banner v6 - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: Patch to change psql default banner v6
Date
Msg-id 200805142328.m4ENS1U23539@momjian.us
Whole thread Raw
In response to Re: Patch to change psql default banner v6  ("Joshua D. Drake" <jd@commandprompt.com>)
Responses Re: Patch to change psql default banner v6  (Bruce Momjian <bruce@momjian.us>)
Re: Patch to change psql default banner v6  (Alvaro Herrera <alvherre@commandprompt.com>)
List pgsql-patches
Joshua D. Drake wrote:
> On Wed, 23 Apr 2008 14:41:20 -0700
> "Joshua D. Drake" <jd@commandprompt.com> wrote:
>
> Hello,
>
> Per final discussion here:
>
> http://archives.postgresql.org/pgsql-hackers/2008-04/msg01607.php

I have looked over this patch and made a few adjustments.

You used for a help startup banner:

    Type: help for help.

I feel this has too much indirection because 'help' then produced:

    You are using psql, the command-line interface to PostgreSQL.

        \h or \\help for SQL help.
        \? for psql help.
        \q to quit psql.

        \copyright to view the copyright.

Because \? now has \h, \q, and \copyright alone at the top I think we
should just use:

    $ psql test
    psql (8.4devel)   Type \? for help.

    test=>

If you type 'help' it just repeats the startup banner suggestion:

    test=> help

    You are using psql, the command-line interface to PostgreSQL.
    Type \? for help.

    test=>

I think that consistency will be clearer.  In the past we were trying to
avoid \?, but I think now it is clean enough to be used by new people
without confusion.

I also put the version number in parentheses so it wouldn't be as
prominent.

Updated patch attached.

--
  Bruce Momjian  <bruce@momjian.us>        http://momjian.us
  EnterpriseDB                             http://enterprisedb.com

  + If your life is a hard drive, Christ can be your backup. +
Index: src/bin/psql/help.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/help.c,v
retrieving revision 1.127
diff -c -c -r1.127 help.c
*** src/bin/psql/help.c    14 May 2008 15:30:22 -0000    1.127
--- src/bin/psql/help.c    14 May 2008 23:09:06 -0000
***************
*** 176,182 ****

      fprintf(output, _("Query Buffer\n"));
      fprintf(output, _("  \\e [FILE]      edit the query buffer (or file) with external editor\n"));
!     fprintf(output, _("  \\g [FILE]      send query buffer to server (and results to file or |pipe)\n"));
      fprintf(output, _("  \\p             show the contents of the query buffer\n"));
      fprintf(output, _("  \\r             reset (clear) the query buffer\n"));
  #ifdef USE_READLINE
--- 176,182 ----

      fprintf(output, _("Query Buffer\n"));
      fprintf(output, _("  \\e [FILE]      edit the query buffer (or file) with external editor\n"));
!     fprintf(output, _("  \\g [FILE] or ; send query buffer to server (and results to file or |pipe)\n"));
      fprintf(output, _("  \\p             show the contents of the query buffer\n"));
      fprintf(output, _("  \\r             reset (clear) the query buffer\n"));
  #ifdef USE_READLINE
Index: src/bin/psql/mainloop.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/mainloop.c,v
retrieving revision 1.90
diff -c -c -r1.90 mainloop.c
*** src/bin/psql/mainloop.c    5 Apr 2008 03:40:15 -0000    1.90
--- src/bin/psql/mainloop.c    14 May 2008 23:09:06 -0000
***************
*** 177,186 ****
              (line[4] == '\0' || line[4] == ';' || isspace((unsigned char) line[4])))
          {
              free(line);
!             puts(_("You are using psql, the command-line interface to PostgreSQL."));
!             puts(_("Enter SQL commands, or type \\? for a list of backslash options."));
!             puts(_("Use \\h for SQL command help."));
!             puts(_("Use \\q to quit."));
              fflush(stdout);
              continue;
          }
--- 177,185 ----
              (line[4] == '\0' || line[4] == ';' || isspace((unsigned char) line[4])))
          {
              free(line);
!             puts(_("\nYou are using psql, the command-line interface to PostgreSQL."));
!             puts(_("Type \\? for help.\n"));
!
              fflush(stdout);
              continue;
          }
Index: src/bin/psql/startup.c
===================================================================
RCS file: /cvsroot/pgsql/src/bin/psql/startup.c,v
retrieving revision 1.147
diff -c -c -r1.147 startup.c
*** src/bin/psql/startup.c    8 May 2008 17:04:26 -0000    1.147
--- src/bin/psql/startup.c    14 May 2008 23:09:06 -0000
***************
*** 317,342 ****
                      server_version = server_ver_str;
                  }

!                 printf(_("Welcome to %s %s (server %s), the PostgreSQL interactive terminal.\n\n"),
!                        pset.progname, PG_VERSION, server_version);
              }
              else
!                 printf(_("Welcome to %s %s, the PostgreSQL interactive terminal.\n\n"),
!                        pset.progname, PG_VERSION);
!
!             printf(_("Type:  \\copyright for distribution terms\n"
!                      "       \\h for help with SQL commands\n"
!                      "       \\? for help with psql commands\n"
!                   "       \\g or terminate with semicolon to execute query\n"
!                      "       \\q to quit\n\n"));

              if (pset.sversion / 100 != client_ver / 100)
!                 printf(_("WARNING:  You are connected to a server with major version %d.%d,\n"
!                          "but your %s client is major version %d.%d.  Some backslash commands,\n"
!                          "such as \\d, might not work properly.\n\n"),
!                        pset.sversion / 10000, (pset.sversion / 100) % 100,
!                        pset.progname,
!                        client_ver / 10000, (client_ver / 100) % 100);

  #ifdef USE_SSL
              printSSLInfo();
--- 317,335 ----
                      server_version = server_ver_str;
                  }

!                 printf(_("\n\t%s (%s, server %s)"),
!                 pset.progname, PG_VERSION, server_version);
              }
              else
!                 printf("%s (%s)", pset.progname, PG_VERSION);

              if (pset.sversion / 100 != client_ver / 100)
!                 printf(_("\tWARNING: Server version %d.%d, %s version %d.%d.\n"
!                      "\tSome psql features may not work.\n\n"),
!                     pset.sversion / 10000, (pset.sversion / 100) % 100,
!                     pset.progname, client_ver / 10000, (client_ver / 100) % 100);
!
!             printf(_("   Type \\? for help.\n\n"));

  #ifdef USE_SSL
              printSSLInfo();

pgsql-patches by date:

Previous
From: Bruce Momjian
Date:
Subject: Fix for psql pager computations
Next
From: Bruce Momjian
Date:
Subject: Re: Patch to change psql default banner v6