Thread

  1. MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-19T18:44:03Z

    Hey  -hackers,
    
    I whipped up a quick patch for supporting some of the common mysql- 
    based "meta" commands; this is different than some things which have  
    been discussed in the past, in that it provides just a quick direction  
    to the appropriate psql command, not an actual alternative syntax for  
    the same action.  This is not intended to be comprehensive, but just  
    to provide proper direction
    
    The changes are in a single hunk touching only src/bin/psql/ 
    mainloop.c; I modeled the code against the logic currently in place  
    for the "help" command.
    
    First postgres patch, so bring it on^W^W^Wbe gentle.  I obviously  
    don't expect this to not promote a wild debate/flamewar... ;-)  The  
    formatting and specific wording for the various messages are totally  
    up-in-the-air, and gladly up for debate.
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    ----
    diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
    index e2914ae..cc89728 100644
    --- a/src/bin/psql/mainloop.c
    +++ b/src/bin/psql/mainloop.c
    @@ -197,6 +197,48 @@ MainLoop(FILE *source)
                             continue;
                     }
    
    +#define MYSQL_HELP_CHECK(o) \
    +               (pg_strncasecmp(line, (o), strlen(o)) == 0 &&\
    +               (line[strlen(o)] == '\0' || line[strlen(o)] == ';' ||  
    isspace((unsigned char) line[strlen(o)])))
    +
    +#define MYSQL_HELP_OUTPUT(o) \
    +               free(line);\
    +               printf(_("See:\n           " \
    +                                o\
    +                                "\n"\
    +                                "               or \\? for general  
    help with psql commands\n"));\
    +               fflush(stdout);\
    +               continue;
    +
    +               /* Present the Postgres equivalent common mysqlisms */
    +               if (pset.cur_cmd_interactive && query_buf->len == 0)
    +               {
    +                       if (MYSQL_HELP_CHECK("use"))
    +                       {
    +                               MYSQL_HELP_OUTPUT("\\c database");
    +                       }
    +                       else if (MYSQL_HELP_CHECK("show tables"))
    +                       {
    +                               MYSQL_HELP_OUTPUT("\\dt");
    +                       }
    +                       else if (MYSQL_HELP_CHECK("source"))
    +                       {
    +                               MYSQL_HELP_OUTPUT("\\i filename");
    +                       }
    +                       else if (MYSQL_HELP_CHECK("show databases"))
    +                       {
    +                               MYSQL_HELP_OUTPUT("\\l");
    +                       }
    +                       else if (MYSQL_HELP_CHECK("describe"))
    +                       {
    +                               MYSQL_HELP_OUTPUT("\\d tablename");
    +                       }
    +                       else if (MYSQL_HELP_CHECK("load data infile"))
    +                       {
    +                               MYSQL_HELP_OUTPUT("\\copy");
    +                       }
    +               }
    +
                     /* echo back if flag is set */
                     if (pset.echo == PSQL_ECHO_ALL && ! 
    pset.cur_cmd_interactive)
                             puts(line);
    
    
    
  2. Re: MySQL-ism help patch for psql

    Jeff Davis <pgsql@j-davis.com> — 2010-01-19T19:25:48Z

    On Tue, 2010-01-19 at 12:44 -0600, David Christensen wrote:
    > Hey  -hackers,
    > 
    > I whipped up a quick patch for supporting some of the common mysql- 
    > based "meta" commands; this is different than some things which have  
    > been discussed in the past, in that it provides just a quick direction  
    > to the appropriate psql command, not an actual alternative syntax for  
    > the same action.  This is not intended to be comprehensive, but just  
    > to provide proper direction
    
    I like that idea. There may be a lot of MySQL people that want to use
    the next postgresql release, and this would make it easier.
    
    Please add the patch to the next commitfest:
    
    https://commitfest.postgresql.org/action/commitfest_view?id=6
    
    It's small enough that, if others like it as well, maybe it (or
    something similar) could still make it in this release.
    
    Regards,
    	Jeff Davis
    
    
    
  3. Re: MySQL-ism help patch for psql

    Stefan Kaltenbrunner <stefan@kaltenbrunner.cc> — 2010-01-19T19:35:38Z

    Jeff Davis wrote:
    > On Tue, 2010-01-19 at 12:44 -0600, David Christensen wrote:
    >> Hey  -hackers,
    >>
    >> I whipped up a quick patch for supporting some of the common mysql- 
    >> based "meta" commands; this is different than some things which have  
    >> been discussed in the past, in that it provides just a quick direction  
    >> to the appropriate psql command, not an actual alternative syntax for  
    >> the same action.  This is not intended to be comprehensive, but just  
    >> to provide proper direction
    > 
    > I like that idea. There may be a lot of MySQL people that want to use
    > the next postgresql release, and this would make it easier.
    > 
    > Please add the patch to the next commitfest:
    > 
    > https://commitfest.postgresql.org/action/commitfest_view?id=6
    > 
    > It's small enough that, if others like it as well, maybe it (or
    > something similar) could still make it in this release.
    
    I'm not convinced that we should start adding syntax helpers like that 
    to psql. For now it is an arbitrary subset of MySQL stuff, are we going 
    to add oracle/db2/mssql/drizzle/mariadb and whatnot later on?
    Also I can already see people asking "well you already know that this is 
    that command - why not emulate it fully?".
    So -1 on the general idea of providing that kind of stuff (though I 
    think there is plenty of opportunity to make psql more useful in itself).
    
    
    Stefan
    
    
  4. Re: MySQL-ism help patch for psql

    Jeff Davis <pgsql@j-davis.com> — 2010-01-19T19:43:50Z

    > I'm not convinced that we should start adding syntax helpers like that 
    > to psql. For now it is an arbitrary subset of MySQL stuff, are we going 
    > to add oracle/db2/mssql/drizzle/mariadb and whatnot later on?
    > Also I can already see people asking "well you already know that this is 
    > that command - why not emulate it fully?".
    
    Good points. However, it only takes effect in interactive mode, so I
    don't see it as a promise to do much. I'll make an analogy to:
    
      $ git difff
      git: 'difff' is not a git-command. See 'git --help'.
    
      Did you mean this?
              diff
    
    Regards,
    	Jeff Davis
    
    
    
  5. Re: MySQL-ism help patch for psql

    Jeff Davis <pgsql@j-davis.com> — 2010-01-19T19:51:13Z

    On Tue, 2010-01-19 at 11:43 -0800, Jeff Davis wrote:
    > > I'm not convinced that we should start adding syntax helpers like that 
    > > to psql. For now it is an arbitrary subset of MySQL stuff, are we going 
    > > to add oracle/db2/mssql/drizzle/mariadb and whatnot later on?
    > > Also I can already see people asking "well you already know that this is 
    > > that command - why not emulate it fully?".
    > 
    > Good points. However, it only takes effect in interactive mode, so I
    > don't see it as a promise to do much. I'll make an analogy to:
    > 
    
    On second thought, if it's not a very restricted set of words, it might
    limit what commands we can introduce later. In particular I notice that
    it uses "load" which is too similar to postgresql's LOAD.
    
    I think the words would need to be prefixed with something to separate
    them from normal commands.
    
    Regards,
    	Jeff Davis
    
    
    
  6. Re: MySQL-ism help patch for psql

    Stefan Kaltenbrunner <stefan@kaltenbrunner.cc> — 2010-01-19T19:52:05Z

    Jeff Davis wrote:
    >> I'm not convinced that we should start adding syntax helpers like that 
    >> to psql. For now it is an arbitrary subset of MySQL stuff, are we going 
    >> to add oracle/db2/mssql/drizzle/mariadb and whatnot later on?
    >> Also I can already see people asking "well you already know that this is 
    >> that command - why not emulate it fully?".
    > 
    > Good points. However, it only takes effect in interactive mode, so I
    > don't see it as a promise to do much. I'll make an analogy to:
    > 
    >   $ git difff
    >   git: 'difff' is not a git-command. See 'git --help'.
    > 
    >   Did you mean this?
    >           diff
    
    well the actual output is just:
    
    :~$ git difff
    git: 'difff' is not a git-command. See 'git --help'.
    
    
    which is more or less the same as:
    
    postgres=# \mysql
    Invalid command \mysql. Try \? for help.
    
    so I don't really see why we need to add some random second guessing of 
    what the user actually wanted (and if he is indeed a mysql refugee he 
    can always use "help" and go on from there).
    
    
    Stefan
    
    
  7. Re: MySQL-ism help patch for psql

    Euler Taveira <euler@timbira.com> — 2010-01-19T19:59:31Z

    David Christensen escreveu:
    > I whipped up a quick patch for supporting some of the common mysql-based
    > "meta" commands; this is different than some things which have been
    > discussed in the past, in that it provides just a quick direction to the
    > appropriate psql command, not an actual alternative syntax for the same
    > action.  This is not intended to be comprehensive, but just to provide
    > proper direction
    > 
    This idea was proposed and rejected later; search the archives. IMHO it's more
    appropriated for a wiki page than a PostgreSQL-*especific* help command. If we
    do that, we'll see requests like "why don't you add _my-favorite-db-here_ help
    too?". So, -1.
    
    
    -- 
      Euler Taveira de Oliveira
      http://www.timbira.com/
    
    
  8. Re: MySQL-ism help patch for psql

    Jeff Davis <pgsql@j-davis.com> — 2010-01-19T20:07:46Z

    On Tue, 2010-01-19 at 20:52 +0100, Stefan Kaltenbrunner wrote:
    > Jeff Davis wrote:
    > >> I'm not convinced that we should start adding syntax helpers like that 
    > >> to psql. For now it is an arbitrary subset of MySQL stuff, are we going 
    > >> to add oracle/db2/mssql/drizzle/mariadb and whatnot later on?
    > >> Also I can already see people asking "well you already know that this is 
    > >> that command - why not emulate it fully?".
    > > 
    > > Good points. However, it only takes effect in interactive mode, so I
    > > don't see it as a promise to do much. I'll make an analogy to:
    > > 
    > >   $ git difff
    > >   git: 'difff' is not a git-command. See 'git --help'.
    > > 
    > >   Did you mean this?
    > >           diff
    > 
    > well the actual output is just:
    > 
    > :~$ git difff
    > git: 'difff' is not a git-command. See 'git --help'.
    
    Well, the actual output on my machine is what I put in the email.
    
    That being said, I don't have much of an opinion, so if you see a
    problem, then we can forget it. After all, we would need some kind of a
    prefix anyway to avoid conflicting with actual SQL... maybe "\m"? And
    that defeats a lot of the purpose.
    
    Regards,
    	Jeff Davis
    
    
    
  9. Re: MySQL-ism help patch for psql

    Tom Lane <tgl@sss.pgh.pa.us> — 2010-01-19T20:44:35Z

    Jeff Davis <pgsql@j-davis.com> writes:
    > That being said, I don't have much of an opinion, so if you see a
    > problem, then we can forget it. After all, we would need some kind of a
    > prefix anyway to avoid conflicting with actual SQL... maybe "\m"? And
    > that defeats a lot of the purpose.
    
    Yeah, requiring a prefix would make it completely pointless I think.
    The submitted patch tries to avoid that by only matching syntax that's
    invalid in Postgres, but that certainly limits how far we can go with
    it.  (And like you, I'm a bit worried about the LOAD case.)
    
    The last go-round on this was just a couple months ago:
    http://archives.postgresql.org/pgsql-bugs/2009-11/msg00241.php
    although I guess that was aimed at a slightly different idea,
    namely making "show databases" etc actually *work*.  This one at
    least has a level of complication that's more in keeping with the
    possible gain.
    
    The previous discussion started from the idea that only DESCRIBE,
    SHOW DATABASES/TABLES, and USE were worth worrying about.  If we
    were to agree that we'd go that far and no farther, the potential
    conflict with SQL syntax would be pretty limited.  I have little
    enough experience with mysql to not want to opine too much on how
    useful that would be, but it does seem like those are commands
    I use right away anytime I am using mysql.
    
    			regards, tom lane
    
    
  10. Re: MySQL-ism help patch for psql

    Magnus Hagander <magnus@hagander.net> — 2010-01-19T20:49:37Z

    On Tue, Jan 19, 2010 at 21:44, Tom Lane <tgl@sss.pgh.pa.us> wrote:
    > Jeff Davis <pgsql@j-davis.com> writes:
    >> That being said, I don't have much of an opinion, so if you see a
    >> problem, then we can forget it. After all, we would need some kind of a
    >> prefix anyway to avoid conflicting with actual SQL... maybe "\m"? And
    >> that defeats a lot of the purpose.
    >
    > Yeah, requiring a prefix would make it completely pointless I think.
    
    Definitely.
    
    
    > The submitted patch tries to avoid that by only matching syntax that's
    > invalid in Postgres, but that certainly limits how far we can go with
    > it.  (And like you, I'm a bit worried about the LOAD case.)
    >
    > The last go-round on this was just a couple months ago:
    > http://archives.postgresql.org/pgsql-bugs/2009-11/msg00241.php
    > although I guess that was aimed at a slightly different idea,
    > namely making "show databases" etc actually *work*.  This one at
    > least has a level of complication that's more in keeping with the
    > possible gain.
    
    I think the gain is actually better with this than to try to do the
    work. We'd want it to teach people what to do.
    
    
    > The previous discussion started from the idea that only DESCRIBE,
    > SHOW DATABASES/TABLES, and USE were worth worrying about.  If we
    > were to agree that we'd go that far and no farther, the potential
    > conflict with SQL syntax would be pretty limited.  I have little
    > enough experience with mysql to not want to opine too much on how
    > useful that would be, but it does seem like those are commands
    > I use right away anytime I am using mysql.
    
    I think just getting te most common cases would still be quite
    helpful. Once you get the user to realize that "hey, that backslash
    thing seems to do stuff", you've gone most of the way.
    
    -- 
     Magnus Hagander
     Me: http://www.hagander.net/
     Work: http://www.redpill-linpro.com/
    
    
  11. Re: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-19T20:54:36Z

    > The previous discussion started from the idea that only DESCRIBE,
    > SHOW DATABASES/TABLES, and USE were worth worrying about.  If we
    > were to agree that we'd go that far and no farther, the potential
    > conflict with SQL syntax would be pretty limited.  I have little
    > enough experience with mysql to not want to opine too much on how
    > useful that would be, but it does seem like those are commands
    > I use right away anytime I am using mysql.
    
    I have no problems paring down the list of cases; these were the  
    correspondences I saw off the top of my head.  I definitely don't want  
    to conflict with any SQL syntax.  The exact wording/output of the  
    messages can be adjusted at whim.
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    
    
    
    
    
    
  12. Re: MySQL-ism help patch for psql

    Bruce Momjian <bruce@momjian.us> — 2010-01-19T20:56:18Z

    Tom Lane wrote:
    > Jeff Davis <pgsql@j-davis.com> writes:
    > > That being said, I don't have much of an opinion, so if you see a
    > > problem, then we can forget it. After all, we would need some kind of a
    > > prefix anyway to avoid conflicting with actual SQL... maybe "\m"? And
    > > that defeats a lot of the purpose.
    > 
    > Yeah, requiring a prefix would make it completely pointless I think.
    > The submitted patch tries to avoid that by only matching syntax that's
    > invalid in Postgres, but that certainly limits how far we can go with
    > it.  (And like you, I'm a bit worried about the LOAD case.)
    > 
    > The last go-round on this was just a couple months ago:
    > http://archives.postgresql.org/pgsql-bugs/2009-11/msg00241.php
    > although I guess that was aimed at a slightly different idea,
    > namely making "show databases" etc actually *work*.  This one at
    > least has a level of complication that's more in keeping with the
    > possible gain.
    > 
    > The previous discussion started from the idea that only DESCRIBE,
    > SHOW DATABASES/TABLES, and USE were worth worrying about.  If we
    > were to agree that we'd go that far and no farther, the potential
    > conflict with SQL syntax would be pretty limited.  I have little
    > enough experience with mysql to not want to opine too much on how
    > useful that would be, but it does seem like those are commands
    > I use right away anytime I am using mysql.
    
    Agreed.  I think this discussion mirrors the psql 'help' feature we
    added in 8.4.  After a lot of discussion we decided that a limited
    'help' functionality was the best approach --- the more we added the
    less attractive it became.
    
    -- 
      Bruce Momjian  <bruce@momjian.us>        http://momjian.us
      EnterpriseDB                             http://enterprisedb.com
    
      + If your life is a hard drive, Christ can be your backup. +
    
    
  13. Re: MySQL-ism help patch for psql

    Stefan Kaltenbrunner <stefan@kaltenbrunner.cc> — 2010-01-19T20:58:52Z

    Tom Lane wrote:
    > Jeff Davis <pgsql@j-davis.com> writes:
    >> That being said, I don't have much of an opinion, so if you see a
    >> problem, then we can forget it. After all, we would need some kind of a
    >> prefix anyway to avoid conflicting with actual SQL... maybe "\m"? And
    >> that defeats a lot of the purpose.
    > 
    > Yeah, requiring a prefix would make it completely pointless I think.
    > The submitted patch tries to avoid that by only matching syntax that's
    > invalid in Postgres, but that certainly limits how far we can go with
    > it.  (And like you, I'm a bit worried about the LOAD case.)
    
    yeah requiring a prefix would make it completely pointless
    
    > 
    > The last go-round on this was just a couple months ago:
    > http://archives.postgresql.org/pgsql-bugs/2009-11/msg00241.php
    > although I guess that was aimed at a slightly different idea,
    > namely making "show databases" etc actually *work*.  This one at
    > least has a level of complication that's more in keeping with the
    > possible gain.
    
    well providing a hint that one should use different command will only 
    lead to the path "uhm why not make it work as well" - and we also need 
    to recongnized that our replacements for some of those commands are not 
    really equivalent in most cases.
    
    > 
    > The previous discussion started from the idea that only DESCRIBE,
    > SHOW DATABASES/TABLES, and USE were worth worrying about.  If we
    > were to agree that we'd go that far and no farther, the potential
    > conflict with SQL syntax would be pretty limited.  I have little
    > enough experience with mysql to not want to opine too much on how
    > useful that would be, but it does seem like those are commands
    > I use right away anytime I am using mysql.
    
    well those are the most common ones I guess for the current version of 
    the mysql commandline client - but what about future versions or the 
    fact that we only have partial replacements for some of those that 
    people are really asking for?
    
    
    Stefan
    
    
  14. Re: MySQL-ism help patch for psql

    Andrew Dunstan <andrew@dunslane.net> — 2010-01-19T21:12:43Z

    
    David Christensen wrote:
    >
    > +                       if (MYSQL_HELP_CHECK("use"))
    > +                       {
    > +                               MYSQL_HELP_OUTPUT("\\c database");
    > +                       }
    >
    [snip]
    > +                       else if (MYSQL_HELP_CHECK("load data infile"))
    > +                       {
    > +                               MYSQL_HELP_OUTPUT("\\copy");
    > +                       }
    >
    
    Quite apart from any considerations covered by other people, these two 
    at least could be positively misleading ... the psql commands are not 
    exact equivalents of the MySQL commands, AIUI.
    
    cheers
    
    andrew
    
    
  15. Re: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-19T21:15:37Z

    On Jan 19, 2010, at 2:58 PM, Stefan Kaltenbrunner wrote:
    
    > Tom Lane wrote:
    >> Jeff Davis <pgsql@j-davis.com> writes:
    >>> That being said, I don't have much of an opinion, so if you see a
    >>> problem, then we can forget it. After all, we would need some kind  
    >>> of a
    >>> prefix anyway to avoid conflicting with actual SQL... maybe "\m"?  
    >>> And
    >>> that defeats a lot of the purpose.
    >> Yeah, requiring a prefix would make it completely pointless I think.
    >> The submitted patch tries to avoid that by only matching syntax  
    >> that's
    >> invalid in Postgres, but that certainly limits how far we can go with
    >> it.  (And like you, I'm a bit worried about the LOAD case.)
    >
    > yeah requiring a prefix would make it completely pointless
    
    Agreed.
    
    >> The last go-round on this was just a couple months ago:
    >> http://archives.postgresql.org/pgsql-bugs/2009-11/msg00241.php
    >> although I guess that was aimed at a slightly different idea,
    >> namely making "show databases" etc actually *work*.  This one at
    >> least has a level of complication that's more in keeping with the
    >> possible gain.
    >
    > well providing a hint that one should use different command will  
    > only lead to the path "uhm why not make it work as well" - and we  
    > also need to recongnized that our replacements for some of those  
    > commands are not really equivalent in most cases.
    
    I think if you set this line ahead of time, you don't have to worry  
    about the detractors; this is equivalent to vim outputting  
    "Type  :quit<Enter>  to exit Vim" when you type emacs' quit sequence.   
    The intent is to show the correct way or to provide a helpful reminder  
    to people new to psql, not to make it work the same.
    
    >> The previous discussion started from the idea that only DESCRIBE,
    >> SHOW DATABASES/TABLES, and USE were worth worrying about.  If we
    >> were to agree that we'd go that far and no farther, the potential
    >> conflict with SQL syntax would be pretty limited.  I have little
    >> enough experience with mysql to not want to opine too much on how
    >> useful that would be, but it does seem like those are commands
    >> I use right away anytime I am using mysql.
    >
    > well those are the most common ones I guess for the current version  
    > of the mysql commandline client - but what about future versions or  
    > the fact that we only have partial replacements for some of those  
    > that people are really asking for?
    
    I think it captures the intent of the people using the tool, and that  
    it adds a small net benefit in usability for those people.  Deciding  
    to support this small subset does not obligate you to expand the scope  
    in the future.  (Hey ma, this slope ain't slippery!)
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    
    
    
    
    
    
  16. Re: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-19T21:16:41Z

    On Jan 19, 2010, at 3:12 PM, Andrew Dunstan wrote:
    
    >
    >
    > David Christensen wrote:
    >>
    >> +                       if (MYSQL_HELP_CHECK("use"))
    >> +                       {
    >> +                               MYSQL_HELP_OUTPUT("\\c database");
    >> +                       }
    >>
    > [snip]
    >> +                       else if (MYSQL_HELP_CHECK("load data  
    >> infile"))
    >> +                       {
    >> +                               MYSQL_HELP_OUTPUT("\\copy");
    >> +                       }
    >>
    >
    > Quite apart from any considerations covered by other people, these  
    > two at least could be positively misleading ... the psql commands  
    > are not exact equivalents of the MySQL commands, AIUI.
    
    The \copy could definitely be considered a stretch; I know \c supports  
    more options than the equivalent USE, but isn't it a proper superset  
    of functionality?
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    
    
    
    
    
    
  17. Re: MySQL-ism help patch for psql

    David E. Wheeler <david@kineticode.com> — 2010-01-19T21:18:34Z

    On Jan 19, 2010, at 12:58 PM, Stefan Kaltenbrunner wrote:
    
    > well providing a hint that one should use different command will only lead to the path "uhm why not make it work as well"
    
    I don't think so. People know it's a different database. They'd be thrilled just to get the hint. I think it's a great idea (notwithstanding the caveats mentioned up-thread).
    
    Best,
    
    David
    
  18. Re: MySQL-ism help patch for psql

    Andrew Dunstan <andrew@dunslane.net> — 2010-01-19T21:39:16Z

    
    David Christensen wrote:
    >>
    >> Quite apart from any considerations covered by other people, these 
    >> two at least could be positively misleading ... the psql commands are 
    >> not exact equivalents of the MySQL commands, AIUI.
    >
    > The \copy could definitely be considered a stretch; I know \c supports 
    > more options than the equivalent USE, but isn't it a proper superset 
    > of functionality?
    >
    >
    
    Not really. "use" sets the default db in MySQL (and other DBs like 
    Sybase and MSSQL). But you don't really connect to a particular 
    database, unlike Postgres - you connect to the server. And you can 
    directly query other databases than the default, again unlike Postgres 
    where you can only directly query the database you're connected to. In 
    fact, "use" is part of MySQL's SQL dialect, and can be used from any 
    client, not just part of the metacommands of their commandline client. 
    See <http://dev.mysql.com/doc/refman/5.5/en/use.html>
    
    cheers
    
    andrew
    
    
  19. Re: MySQL-ism help patch for psql

    Tom Lane <tgl@sss.pgh.pa.us> — 2010-01-19T21:39:57Z

    David Christensen <david@endpoint.com> writes:
    > On Jan 19, 2010, at 2:58 PM, Stefan Kaltenbrunner wrote:
    >> well those are the most common ones I guess for the current version  
    >> of the mysql commandline client - but what about future versions or  
    >> the fact that we only have partial replacements for some of those  
    >> that people are really asking for?
    
    > I think it captures the intent of the people using the tool, and that  
    > it adds a small net benefit in usability for those people.  Deciding  
    > to support this small subset does not obligate you to expand the scope  
    > in the future.  (Hey ma, this slope ain't slippery!)
    
    I thought Magnus had a really good point: covering these four cases will
    probably be enough to teach newbies to look at psql's backslash
    commands.  And once they absorb that, we're over a big hump.
    
    Also, TTBOMK these commands have been in mysql for many years.  I don't
    think that commands that might get introduced in future versions would
    have anywhere near the same degree of wired-into-the-fingertips uptake
    to them.
    
    			regards, tom lane
    
    
  20. Re: MySQL-ism help patch for psql

    Tom Lane <tgl@sss.pgh.pa.us> — 2010-01-19T21:53:37Z

    David Christensen <david@endpoint.com> writes:
    > On Jan 19, 2010, at 3:12 PM, Andrew Dunstan wrote:
    >> Quite apart from any considerations covered by other people, these  
    >> two at least could be positively misleading ... the psql commands  
    >> are not exact equivalents of the MySQL commands, AIUI.
    
    > The \copy could definitely be considered a stretch; I know \c supports  
    > more options than the equivalent USE, but isn't it a proper superset  
    > of functionality?
    
    No, in fact I was going to bring up exactly that point, but Andrew beat
    me to it.  You can make a good case that mysql databases are more nearly
    a match to PG schemas than to PG databases.  So arguably instead of "use
    foo" a mysql convert would prefer "set search_path = foo".  This would
    have been a serious headache if we'd accepted the earlier plan of trying
    to implement equivalent functionality.  In this patch, it could probably
    be accommodated by having the help message read something like
    
    	Perhaps you want "\c database" or "set search_path = schema".
    
    Or we could punt and leave this one out of the set that have help
    messages.
    
    			regards, tom lane
    
    
  21. Re: MySQL-ism help patch for psql

    Devrim Gündüz <devrim@gunduz.org> — 2010-01-19T21:57:06Z

    On Tue, 2010-01-19 at 11:25 -0800, Jeff Davis wrote:
    
    > I like that idea. There may be a lot of MySQL people that want to use
    > the next postgresql release, and this would make it easier. 
    
    I disagree. If they want to use PostgreSQL, they should learn our
    syntax. How can you make sure that this will be enough for them? What if
    they want more?
    
    I have administrated lots of MySQL server until I started working for
    Command Prompt (I still take a look at one once a month, for a
    government related thing). 
    
    +#define MYSQL_HELP_CHECK(o) \
    
    What if some other people will come up with the idea of adding similar
    functionality for their favorite database? The only exception will be
    Informix IMHO, because of historical reasons. 
    
    So, -1 from me for adding such a support for MySQL's cli commands.
    -- 
    Devrim GÜNDÜZ, RHCE
    Command Prompt - http://www.CommandPrompt.com 
    devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
    http://www.gunduz.org  Twitter: http://twitter.com/devrimgunduz
    
  22. Re: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-19T22:00:14Z

    On Jan 19, 2010, at 3:39 PM, Tom Lane wrote:
    
    > David Christensen <david@endpoint.com> writes:
    >> On Jan 19, 2010, at 2:58 PM, Stefan Kaltenbrunner wrote:
    >>> well those are the most common ones I guess for the current version
    >>> of the mysql commandline client - but what about future versions or
    >>> the fact that we only have partial replacements for some of those
    >>> that people are really asking for?
    >
    >> I think it captures the intent of the people using the tool, and that
    >> it adds a small net benefit in usability for those people.  Deciding
    >> to support this small subset does not obligate you to expand the  
    >> scope
    >> in the future.  (Hey ma, this slope ain't slippery!)
    >
    > I thought Magnus had a really good point: covering these four cases  
    > will
    > probably be enough to teach newbies to look at psql's backslash
    > commands.  And once they absorb that, we're over a big hump.
    
    Okay, so I can revise the code to cover those four cases specifically  
    (or three, depending); is there any specific feedback as to the output/ 
    formatting of the messages themselves?
    
    Currently, a session will look like the following:
    
       machack:machack:5485=# show tables;
       See:
              \d
              or \? for general help with psql commands
       machack:machack:5485=#
    
    Said formatting looks like it could use some improvement, open to  
    suggestions, but something on a single line seems more useful.
    
    > Also, TTBOMK these commands have been in mysql for many years.  I  
    > don't
    > think that commands that might get introduced in future versions would
    > have anywhere near the same degree of wired-into-the-fingertips uptake
    > to them.
    
    They were in there since when I last used mysql on a regular basis, so  
    going on 10 years now.  i.e., pretty safe, and pretty engrained in  
    muscle-memory.
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    
    
    
    
    
    
  23. Re: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-19T22:04:33Z

    On Jan 19, 2010, at 3:57 PM, Devrim GÜNDÜZ wrote:
    
    > On Tue, 2010-01-19 at 11:25 -0800, Jeff Davis wrote:
    >
    >> I like that idea. There may be a lot of MySQL people that want to use
    >> the next postgresql release, and this would make it easier.
    >
    > I disagree. If they want to use PostgreSQL, they should learn our
    > syntax. How can you make sure that this will be enough for them?  
    > What if
    > they want more?
    
    This is intended to be a gentle nudge in the right direction, not a  
    replacement for their regular syntax.  This does not perform the  
    command in question, just points them to the right one, along with a  
    general reminder that all kinds of good help is available via \?.
    
    > I have administrated lots of MySQL server until I started working for
    > Command Prompt (I still take a look at one once a month, for a
    > government related thing).
    >
    > +#define MYSQL_HELP_CHECK(o) \
    >
    > What if some other people will come up with the idea of adding similar
    > functionality for their favorite database? The only exception will be
    > Informix IMHO, because of historical reasons.
    
    I'm not sure what you're saying here WRT Informix; if there is  
    substantial desire and a large enough group that would find such  
    newbie hints useful, I'd say we could generalize this more, but I  
    don't think this patch obligates one to any such future proposals.
    
    > So, -1 from me for adding such a support for MySQL's cli commands.
    > -- 
    > Devrim GÜNDÜZ, RHCE
    > Command Prompt - http://www.CommandPrompt.com
    > devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
    > http://www.gunduz.org  Twitter: http://twitter.com/devrimgunduz
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    
    
    
    
    
    
  24. Re: MySQL-ism help patch for psql

    David E. Wheeler <david@kineticode.com> — 2010-01-19T22:14:31Z

    On Jan 19, 2010, at 1:39 PM, Tom Lane wrote:
    
    > I thought Magnus had a really good point: covering these four cases will
    > probably be enough to teach newbies to look at psql's backslash
    > commands.  And once they absorb that, we're over a big hump.
    
    +1
    
    On Jan 19, 2010, at 1:57 PM, Devrim GÜNDÜZ wrote:
    
    > I disagree. If they want to use PostgreSQL, they should learn our
    > syntax. How can you make sure that this will be enough for them? What if
    > they want more?
    
    Why would they want more? It's not MySQL, and they know that. If we give them some very minor helpful hints for the most common things they try to do, it would be a huge benefit to them. I know I've badly wanted the opposite when I've had to use MySQL, but I don't expect MySQL to implement \c for me.
    
    > What if some other people will come up with the idea of adding similar
    > functionality for their favorite database? The only exception will be
    > Informix IMHO, because of historical reasons. 
    
    I think it'd be helpful for other databases, too. Oracle comes to mind: What commands are finger-trained in Oracle DBAs?
    
    Best,
    
    David
    
    
    
  25. Re: MySQL-ism help patch for psql

    Robert Haas <robertmhaas@gmail.com> — 2010-01-19T22:23:09Z

    On Tue, Jan 19, 2010 at 5:14 PM, David E. Wheeler <david@kineticode.com> wrote:
    > Why would they want more? It's not MySQL, and they know that. If we give them some very minor helpful hints for the most common things they try to do, it would be a huge benefit to them. I know I've badly wanted the opposite when I've had to use MySQL, but I don't expect MySQL to implement \c for me.
    
    +1.  I think this is a well-thought out proposal.  I like Tom's
    suggestion upthread for how to handle \c.
    
    Although the deadline for patches for 8.5 has supposedly already passed....
    
    ...Robert
    
    
  26. Re: MySQL-ism help patch for psql

    Rob Wultsch <wultsch@gmail.com> — 2010-01-19T22:31:30Z

    On Tue, Jan 19, 2010 at 3:14 PM, David E. Wheeler <david@kineticode.com> wrote:
    > On Jan 19, 2010, at 1:39 PM, Tom Lane wrote:
    >
    >> I thought Magnus had a really good point: covering these four cases will
    >> probably be enough to teach newbies to look at psql's backslash
    >> commands.  And once they absorb that, we're over a big hump.
    >
    > +1
    >
    > On Jan 19, 2010, at 1:57 PM, Devrim GÜNDÜZ wrote:
    >
    >> I disagree. If they want to use PostgreSQL, they should learn our
    >> syntax. How can you make sure that this will be enough for them? What if
    >> they want more?
    >
    > Why would they want more? It's not MySQL, and they know that. If we give them some very minor helpful hints for the most common things they try to do, it would be a huge benefit to them. I know I've badly wanted the opposite when I've had to use MySQL, but I don't expect MySQL to implement \c for me.
    >
    >> What if some other people will come up with the idea of adding similar
    >> functionality for their favorite database? The only exception will be
    >> Informix IMHO, because of historical reasons.
    >
    > I think it'd be helpful for other databases, too. Oracle comes to mind: What commands are finger-trained in Oracle DBAs?
    >
    > Best,
    >
    > David
    >
    
    As a MySQL DBA the commands I think are most useful are:
    show databases (please punt this, most MySQL dba's that I have worked
    with will need to consider the difference between a db and a schema)
    use database (please punt)
    LOAD DATA INFILE(please punt, they should look at the manual as COPY
    is... well, more limited)
    show tables
    desc(ribe) table
    show processlist
    
    
    I suggest adding:
    +                       else if (MYSQL_HELP_CHECK("show processlist"))
    +                       {
    +                               MYSQL_HELP_OUTPUT("SELECT * from
    pg_stat_activity");
    +                       }
    +                       else if (MYSQL_HELP_CHECK("desc"))
    +                       {
    +                               MYSQL_HELP_OUTPUT("\\d tablename");
    +                       }
    
    
    
    -- 
    Rob Wultsch
    wultsch@gmail.com
    
    
  27. Re: MySQL-ism help patch for psql

    Dimitri Fontaine <dfontaine@hi-media.com> — 2010-01-19T22:37:36Z

    Robert Haas <robertmhaas@gmail.com> writes:
    > Although the deadline for patches for 8.5 has supposedly already passed....
    
    I guess it already got more review than some of the commit fest items
    already…
    
    Regards,
    -- 
    dim
    
    
  28. Patch rev 2: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-20T00:01:29Z

    On Jan 19, 2010, at 4:23 PM, Robert Haas wrote:
    
    > On Tue, Jan 19, 2010 at 5:14 PM, David E. Wheeler <david@kineticode.com 
    > > wrote:
    >> Why would they want more? It's not MySQL, and they know that. If we  
    >> give them some very minor helpful hints for the most common things  
    >> they try to do, it would be a huge benefit to them. I know I've  
    >> badly wanted the opposite when I've had to use MySQL, but I don't  
    >> expect MySQL to implement \c for me.
    >
    > +1.  I think this is a well-thought out proposal.  I like Tom's
    > suggestion upthread for how to handle \c.
    
    I've attached a second revision of this patch incorporating the  
    various feedback I've received.
    
    > Although the deadline for patches for 8.5 has supposedly already  
    > passed....
    
    Yeah, I realized this after I scratched my itch, and had just thought  
    I would send to the list any way for after the CF; you can commit or  
    bump as needed.  Patch enclosed as a context-diff attachment this time.
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    
    
  29. Re: Patch rev 2: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-20T00:05:32Z

    On Jan 19, 2010, at 6:01 PM, David Christensen wrote:
    
    >
    > On Jan 19, 2010, at 4:23 PM, Robert Haas wrote:
    >
    >> On Tue, Jan 19, 2010 at 5:14 PM, David E. Wheeler <david@kineticode.com 
    >> > wrote:
    >>> Why would they want more? It's not MySQL, and they know that. If  
    >>> we give them some very minor helpful hints for the most common  
    >>> things they try to do, it would be a huge benefit to them. I know  
    >>> I've badly wanted the opposite when I've had to use MySQL, but I  
    >>> don't expect MySQL to implement \c for me.
    >>
    >> +1.  I think this is a well-thought out proposal.  I like Tom's
    >> suggestion upthread for how to handle \c.
    >
    > I've attached a second revision of this patch incorporating the  
    > various feedback I've received.
    >
    >> Although the deadline for patches for 8.5 has supposedly already  
    >> passed....
    >
    > Yeah, I realized this after I scratched my itch, and had just  
    > thought I would send to the list any way for after the CF; you can  
    > commit or bump as needed.  Patch enclosed as a context-diff  
    > attachment this time.
    
    
    I also forgot to enclose the sample output in this version, based  
    largely on Tom's wording for the USE usecase:
    
    ----
    machack:machack:5432=# show tables
    
    Perhaps you want "\dt"?
    See \? for help with psql commands
    
    [Tue Jan 19 18:04:50 CST 2010]
    machack:machack:5432=# use database;
    
    Perhaps you want "\c database" or "set search_path = schema"?
    See \? for help with psql commands
    
    [Tue Jan 19 18:05:07 CST 2010]
    machack:machack:5432=#
    ----
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    
    
    
    
    
    
  30. Re: Patch rev 2: MySQL-ism help patch for psql

    Tom Lane <tgl@sss.pgh.pa.us> — 2010-01-20T00:13:27Z

    David Christensen <david@endpoint.com> writes:
    > I also forgot to enclose the sample output in this version, based  
    > largely on Tom's wording for the USE usecase:
    
    Please note that that was just an off-the-cuff example, not something
    I thought was perfect as is ...
    
    			regards, tom lane
    
    
  31. Re: MySQL-ism help patch for psql

    Craig Ringer <craig@postnewspapers.com.au> — 2010-01-20T01:54:44Z

    On 20/01/2010 6:31 AM, Rob Wultsch wrote:
    
    > As a MySQL DBA the commands I think are most useful are:
    > show databases (please punt this, most MySQL dba's that I have worked
    > with will need to consider the difference between a db and a schema)
    > use database (please punt)
    
    So perhaps for SHOW DATABASES the help should suggest:
    
    "
       \l   - list databases; or
       \dn  - list schema
    "
    
    ?
    
    --
    Craig Ringer
    
    
  32. Re: MySQL-ism help patch for psql

    Greg Sabino Mullane <greg@turnstep.com> — 2010-01-20T02:56:27Z

    -----BEGIN PGP SIGNED MESSAGE-----                                    
    Hash: RIPEMD160                                                       
    
    
    > Why would they want more? It's not MySQL, and they know that.
    > If we give them some very minor helpful hints for the most
    > common things they try to do, it would be a huge benefit to them.
    
    +1
    
    >> What if some other people will come up with the idea of adding similar
    >> functionality for their favorite database? The only exception will be
    >> Informix IMHO, because of historical reasons.
    
    > I think it'd be helpful for other databases, too. Oracle comes to mind:
    > What commands are finger-trained in Oracle DBAs?
    
    Ha! Best laugh I've had all week. The finger training consists of "double
    click the mouse, navigate the GUI to find your table...". For command line,
    you have monstrosities such as "select * from ALL_ALL_TABLES"
    and "select * from TABS" - unless they've implemented some sort of shortcuts
    since the last time I used Oracle. Which seems very unlikely, as they
    obviously have no love for sqlplus (Oracle's command line client), which
    has been stuck technologically in place for decades (hello, readline?)
    
    - --
    Greg Sabino Mullane greg@turnstep.com
    PGP Key: 0x14964AC8 201001192155
    http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
    -----BEGIN PGP SIGNATURE-----
    
    iEYEAREDAAYFAktWcMkACgkQvJuQZxSWSsgAoQCgw/9e+viAs6RyGCeuSze42oqx
    Ym4An2Q9FSpXYkX1ZC507Y/NwUb3ODmG
    =fnUL
    -----END PGP SIGNATURE-----
    
    
    
    
  33. Re: MySQL-ism help patch for psql

    Greg Stark <stark@mit.edu> — 2010-01-20T09:19:56Z

    this is mostly true. I don't think any Oracle DBA will expect ALL_TABLES our
    DBA_TABLES to be there.
    
    however DESCRIBE and HELP would be the two that come to mind.
    
    greg
    
    On 20 Jan 2010 02:56, "Greg Sabino Mullane" <greg@turnstep.com> wrote:
    
    
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: RIPEMD160
    
    > Why would they want more? It's not MySQL, and they know that. > If we give
    them some very minor ...
    +1
    
    >> What if some other people will come up with the idea of adding similar >>
    functionality for thei...
    Ha! Best laugh I've had all week. The finger training consists of "double
    click the mouse, navigate the GUI to find your table...". For command line,
    you have monstrosities such as "select * from ALL_ALL_TABLES"
    and "select * from TABS" - unless they've implemented some sort of shortcuts
    since the last time I used Oracle. Which seems very unlikely, as they
    obviously have no love for sqlplus (Oracle's command line client), which
    has been stuck technologically in place for decades (hello, readline?)
    
    - --
    Greg Sabino Mullane greg@turnstep.com
    PGP Key: 0x14964AC8 201001192155
    http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
    -----BEGIN PGP SIGNATURE-----
    
    iEYEAREDAAYFAktWcMkACgkQvJuQZxSWSsgAoQCgw/9e+viAs6RyGCeuSze42oqx
    Ym4An2Q9FSpXYkX1ZC507Y/NwUb3ODmG
    =fnUL
    -----END PGP SIGNATURE-----
    
    -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To
    make changes to your su...
    
  34. Re: Patch rev 2: MySQL-ism help patch for psql

    Rob Wultsch <wultsch@gmail.com> — 2010-01-20T12:11:03Z

    On Tue, Jan 19, 2010 at 5:01 PM, David Christensen <david@endpoint.com> wrote:
    >
    > On Jan 19, 2010, at 4:23 PM, Robert Haas wrote:
    >
    >> On Tue, Jan 19, 2010 at 5:14 PM, David E. Wheeler <david@kineticode.com>
    >> wrote:
    >>>
    >>> Why would they want more? It's not MySQL, and they know that. If we give
    >>> them some very minor helpful hints for the most common things they try to
    >>> do, it would be a huge benefit to them. I know I've badly wanted the
    >>> opposite when I've had to use MySQL, but I don't expect MySQL to implement
    >>> \c for me.
    >>
    >> +1.  I think this is a well-thought out proposal.  I like Tom's
    >> suggestion upthread for how to handle \c.
    >
    > I've attached a second revision of this patch incorporating the various
    > feedback I've received.
    >
    >> Although the deadline for patches for 8.5 has supposedly already
    >> passed....
    >
    > Yeah, I realized this after I scratched my itch, and had just thought I
    > would send to the list any way for after the CF; you can commit or bump as
    > needed.  Patch enclosed as a context-diff attachment this time.
    >
    > Regards,
    >
    > David
    > --
    > David Christensen
    > End Point Corporation
    > david@endpoint.com
    
    
    Although I have a snowballs chance in hell to convert my coworkers to
    using pg I think that this patch would make such an outcome more
    likely. Please consider what a  MySQL dba does when he gets a call at
    3AM that a server
    (p3.any43.db69.I_have_no_clue_what_this_stupid_f'ing_server_is.wtf.pg
    ) is at max-connections. I think that some helpful hints for non-pg
    dba's that are using pg in some capacity are a very good idea.
    
    -- 
    Rob Wultsch
    wultsch@gmail.com
    
    
  35. Re: MySQL-ism help patch for psql

    Peter Eisentraut <peter_e@gmx.net> — 2010-01-20T13:15:27Z

    On tis, 2010-01-19 at 11:43 -0800, Jeff Davis wrote:
    > I'll make an analogy to:
    > 
    >   $ git difff
    >   git: 'difff' is not a git-command. See 'git --help'.
    > 
    >   Did you mean this?
    >           diff
    
    This is presumably spelling-based, which might be an interesting feature
    (although probably useless for psql's single-letter commands).  Maybe
    this analogy is more interesting, for a user that recently used cvs:
    
    $ git update
    git: 'update' is not a git-command. See 'git --help'.
    
    Did you mean this?
            update-ref
    
    --> Probably not.
    
    
    
    
  36. Re: MySQL-ism help patch for psql

    Peter Eisentraut <peter_e@gmx.net> — 2010-01-20T13:36:55Z

    On tis, 2010-01-19 at 16:00 -0600, David Christensen wrote:
    > Currently, a session will look like the following:
    > 
    >    machack:machack:5485=# show tables;
    >    See:
    >           \d
    >           or \? for general help with psql commands
    >    machack:machack:5485=#
    
    I think if you make "show tables" and the others actually execute \d and
    then possibly print a notice about what the "better" command would have
    been, you actually *help* people do their work instead of appearing to
    be a smartass -- "See, we took the time to research what you want to do,
    and here is why it's wrong."
    
    Moreover, the backslash is really hard to type on some keyboards, so I'd
    expect significant uptake for people to use the SHOW variants as their
    primary method.
    
    
    
  37. Re: MySQL-ism help patch for psql

    Bruce Momjian <bruce@momjian.us> — 2010-01-20T14:05:33Z

    Peter Eisentraut wrote:
    > On tis, 2010-01-19 at 16:00 -0600, David Christensen wrote:
    > > Currently, a session will look like the following:
    > > 
    > >    machack:machack:5485=# show tables;
    > >    See:
    > >           \d
    > >           or \? for general help with psql commands
    > >    machack:machack:5485=#
    > 
    > I think if you make "show tables" and the others actually execute \d and
    > then possibly print a notice about what the "better" command would have
    > been, you actually *help* people do their work instead of appearing to
    > be a smartass -- "See, we took the time to research what you want to do,
    > and here is why it's wrong."
    > 
    > Moreover, the backslash is really hard to type on some keyboards, so I'd
    > expect significant uptake for people to use the SHOW variants as their
    > primary method.
    
    I disagree.   No one has complained that we are being a "smartass" by
    reporting this for "help" in psql:
    
    	You are using psql, the command-line interface to PostgreSQL.
    	Type:  \copyright for distribution terms
    	       \h for help with SQL commands
    	       \? for help with psql commands
    	       \g or terminate with semicolon to execute query
    	       \q to quit
    
    while to be really helpful we would display \?.  After extensive
    discussion we chose against that because we wanted to steer people to
    the proper commands, rather than have them consider 'help' as a valid
    command.  The same is true for the MySQL commands --- we just want to
    point people to the proper commands.
    
    -- 
      Bruce Momjian  <bruce@momjian.us>        http://momjian.us
      EnterpriseDB                             http://enterprisedb.com
    
      + If your life is a hard drive, Christ can be your backup. +
    
    
  38. Re: MySQL-ism help patch for psql

    Peter Eisentraut <peter_e@gmx.net> — 2010-01-20T14:26:39Z

    On ons, 2010-01-20 at 09:05 -0500, Bruce Momjian wrote:
    > I disagree.   No one has complained that we are being a "smartass" by
    > reporting this for "help" in psql:
    > 
    >         You are using psql, the command-line interface to PostgreSQL.
    >         Type:  \copyright for distribution terms
    >                \h for help with SQL commands
    >                \? for help with psql commands
    >                \g or terminate with semicolon to execute query
    >                \q to quit
    > 
    > while to be really helpful we would display \?.  After extensive
    > discussion we chose against that because we wanted to steer people to
    > the proper commands, rather than have them consider 'help' as a valid
    > command.  The same is true for the MySQL commands --- we just want to
    > point people to the proper commands.
    
    That's not the same thing.  The user typed "help" and you help him.  If
    the user types "show tables", you show him the tables.  If the user
    typed "show tables" and you send him a help message, that is not what
    the user wanted.
    
    
    
  39. Re: MySQL-ism help patch for psql

    Robert Haas <robertmhaas@gmail.com> — 2010-01-20T14:27:53Z

    On Wed, Jan 20, 2010 at 9:05 AM, Bruce Momjian <bruce@momjian.us> wrote:
    > Peter Eisentraut wrote:
    >> On tis, 2010-01-19 at 16:00 -0600, David Christensen wrote:
    >> > Currently, a session will look like the following:
    >> >
    >> >    machack:machack:5485=# show tables;
    >> >    See:
    >> >           \d
    >> >           or \? for general help with psql commands
    >> >    machack:machack:5485=#
    >>
    >> I think if you make "show tables" and the others actually execute \d and
    >> then possibly print a notice about what the "better" command would have
    >> been, you actually *help* people do their work instead of appearing to
    >> be a smartass -- "See, we took the time to research what you want to do,
    >> and here is why it's wrong."
    >>
    >> Moreover, the backslash is really hard to type on some keyboards, so I'd
    >> expect significant uptake for people to use the SHOW variants as their
    >> primary method.
    >
    > I disagree.   No one has complained that we are being a "smartass" by
    > reporting this for "help" in psql:
    >
    >        You are using psql, the command-line interface to PostgreSQL.
    >        Type:  \copyright for distribution terms
    >               \h for help with SQL commands
    >               \? for help with psql commands
    >               \g or terminate with semicolon to execute query
    >               \q to quit
    >
    > while to be really helpful we would display \?.  After extensive
    > discussion we chose against that because we wanted to steer people to
    > the proper commands, rather than have them consider 'help' as a valid
    > command.  The same is true for the MySQL commands --- we just want to
    > point people to the proper commands.
    
    +1.
    
    ...Robert
    
    
  40. Re: MySQL-ism help patch for psql

    Robert Haas <robertmhaas@gmail.com> — 2010-01-20T14:48:26Z

    On Wed, Jan 20, 2010 at 9:26 AM, Peter Eisentraut <peter_e@gmx.net> wrote:
    > On ons, 2010-01-20 at 09:05 -0500, Bruce Momjian wrote:
    >> I disagree.   No one has complained that we are being a "smartass" by
    >> reporting this for "help" in psql:
    >>
    >>         You are using psql, the command-line interface to PostgreSQL.
    >>         Type:  \copyright for distribution terms
    >>                \h for help with SQL commands
    >>                \? for help with psql commands
    >>                \g or terminate with semicolon to execute query
    >>                \q to quit
    >>
    >> while to be really helpful we would display \?.  After extensive
    >> discussion we chose against that because we wanted to steer people to
    >> the proper commands, rather than have them consider 'help' as a valid
    >> command.  The same is true for the MySQL commands --- we just want to
    >> point people to the proper commands.
    >
    > That's not the same thing.  The user typed "help" and you help him.  If
    > the user types "show tables", you show him the tables.  If the user
    > typed "show tables" and you send him a help message, that is not what
    > the user wanted.
    
    If what the user wanted was to be using MySQL, he is out of luck anyway.
    
    I'm actually no big advocate of the \d commands.  They're basically
    magical queries that you can't easily see or edit - I've more than
    once wished for a WHERE clause (\df WHERE "Result data type" =
    'internal' or what have you.  But I don't have a practical solution
    for dealing with that problem, and I think trying to emulate MySQL is
    probably not a good idea... what if we wanted to make "USE" actually
    mean something some day?  If it just prints out a helpful error
    message, that could still be possible (and we lose the helpful error
    message), but if people are expecting it to work, we're hosed.
    
    ...Robert
    
    
  41. Re: MySQL-ism help patch for psql

    Andrew Dunstan <andrew@dunslane.net> — 2010-01-20T15:00:05Z

    
    Robert Haas wrote:
    > I'm actually no big advocate of the \d commands.  They're basically
    > magical queries that you can't easily see or edit - I've more than
    > once wished for a WHERE clause (\df WHERE "Result data type" =
    > 'internal' or what have you.  
    >   
    
    You *can* easily see them, at least. Run "psql -E" or inside psql do 
    "\set ECHO_HIDDEN"
    
    cheers
    
    andrew
    
    
  42. Re: MySQL-ism help patch for psql

    Dimitri Fontaine <dfontaine@hi-media.com> — 2010-01-20T15:11:11Z

    Robert Haas <robertmhaas@gmail.com> writes:
    > If what the user wanted was to be using MySQL, he is out of luck
    > anyway.
    
    That's not what we're talking about. We're talking about having a nice
    client tool for those people having to do both MySQL and PostgreSQL
    support, or new to PostgreSQL and comming from MySQL.
    
    I'll give my vote to Peter's idea that show tables; should better act as
    if you typed \d.
    
    I don't see what the gain is to refuse being nice to MySQL newcomers
    when someone actually does the work. If the USE keyword is one we want
    to keep free for our own usage, let just skip that compat option.
    
    > I'm actually no big advocate of the \d commands.  They're basically
    > magical queries that you can't easily see or edit
    
    We already have the psql \set ECHO_HIDDEN command to easily see the
    query, then it's a copy/paste away. I'd propose to have this setting
    also make it so that the query it runs is placed in the buffer for next
    \e command, which is not the case in 8.4.
    
    Regards,
    -- 
    dim
    
    
  43. Re: MySQL-ism help patch for psql

    Bruce Momjian <bruce@momjian.us> — 2010-01-20T15:19:38Z

    Dimitri Fontaine wrote:
    > Robert Haas <robertmhaas@gmail.com> writes:
    > > If what the user wanted was to be using MySQL, he is out of luck
    > > anyway.
    > 
    > That's not what we're talking about. We're talking about having a nice
    > client tool for those people having to do both MySQL and PostgreSQL
    > support, or new to PostgreSQL and comming from MySQL.
    > 
    > I'll give my vote to Peter's idea that show tables; should better act as
    > if you typed \d.
    > 
    > I don't see what the gain is to refuse being nice to MySQL newcomers
    > when someone actually does the work. If the USE keyword is one we want
    > to keep free for our own usage, let just skip that compat option.
    
    I think the problem is that many other MySQL commands will not work or
    be supported, and if you give the person the desired output _and_ a
    suggestion to use \d, the suggests is easily overlooked.
    
    -- 
      Bruce Momjian  <bruce@momjian.us>        http://momjian.us
      EnterpriseDB                             http://enterprisedb.com
    
      + If your life is a hard drive, Christ can be your backup. +
    
    
  44. Re: MySQL-ism help patch for psql

    Kevin Grittner <kevin.grittner@wicourts.gov> — 2010-01-20T15:30:03Z

    Dimitri Fontaine <dfontaine@hi-media.com> wrote:
     
    > I'll give my vote to Peter's idea that show tables; should better
    > act as if you typed \d.
     
    I guess we don't need a "tables" GUC.  Show all wouldn't include it?
    Would we require a semicolon?  Do we support \d-style globs?
     
    Still seems kinda messy.  +1 for help to show the PostgreSQL command
    as a guess for what they want to do.  -1 for MySQL emulation.
     
    -Kevin
    
    
  45. Re: MySQL-ism help patch for psql

    Gabriele Bartolini <gabriele.bartolini@2ndquadrant.it> — 2010-01-20T15:38:04Z

    I would personally emulate \d and take the chance for showing a funny  
    warning, something like: "hey, it's not MySql!" or similar. I am sure  
    we will Finder something appropriate. :)
    
    Inviato da iPhone
    
    Il giorno 20/gen/2010, alle ore 16.30, "Kevin Grittner" <Kevin.Grittner@wicourts.gov 
     > ha scritto:
    
    > Dimitri Fontaine <dfontaine@hi-media.com> wrote:
    >
    >> I'll give my vote to Peter's idea that show tables; should better
    >> act as if you typed \d.
    >
    > I guess we don't need a "tables" GUC.  Show all wouldn't include it?
    > Would we require a semicolon?  Do we support \d-style globs?
    >
    > Still seems kinda messy.  +1 for help to show the PostgreSQL command
    > as a guess for what they want to do.  -1 for MySQL emulation.
    >
    > -Kevin
    >
    > -- 
    > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
    > To make changes to your subscription:
    > http://www.postgresql.org/mailpref/pgsql-hackers
    
    
  46. Re: MySQL-ism help patch for psql

    Tom Lane <tgl@sss.pgh.pa.us> — 2010-01-20T16:53:35Z

    Dimitri Fontaine <dfontaine@hi-media.com> writes:
    > I'll give my vote to Peter's idea that show tables; should better act as
    > if you typed \d.
    
    We have previously considered and rejected this type of approach, for
    example in the pgsql-bugs discussion I referenced upthread.
    
    > I don't see what the gain is to refuse being nice to MySQL newcomers
    > when someone actually does the work.
    
    Nobody has actually done such work, nor offered to.  If it did show up
    it would be a large and ugly patch that would have a good chance of
    being rejected.  The proposed patch to just provide a helpful message
    is only a dozen or two lines, which is about the right amount of effort
    to expend in this direction IMHO.
    
    			regards, tom lane
    
    
  47. Re: MySQL-ism help patch for psql

    Dimitri Fontaine <dfontaine@hi-media.com> — 2010-01-20T16:59:28Z

    Tom Lane <tgl@sss.pgh.pa.us> writes:
    >   The proposed patch to just provide a helpful message
    > is only a dozen or two lines, which is about the right amount of effort
    > to expend in this direction IMHO.
    
    For the record, agreed on the commands for which we have no obvious
    equivalent :)
    
    Regards,
    -- 
    Dimitri Fontaine
    PostgreSQL DBA, Architecte
    
    
  48. Re: MySQL-ism help patch for psql

    Florian Weimer <fweimer@bfk.de> — 2010-01-21T17:48:18Z

    * David Christensen:
    
    > Currently, a session will look like the following:
    >
    >   machack:machack:5485=# show tables;
    >   See:
    >          \d
    >          or \? for general help with psql commands
    >   machack:machack:5485=#
    >
    > Said formatting looks like it could use some improvement, open to
    > suggestions, but something on a single line seems more useful.
    
    You should at least make clear that this is an error message due to an
    unsupported command.  The output above looks broken.  Something like
    this should be okay, I think:
    
    ERROR:  unrecognized configuration parameter "tables"
    NOTICE: use \d to list tables, or \? for general help with psql commands
    
    ERROR:  unrecognized configuration parameter "databases"
    NOTICE: use \l to list databases, or \? for general help with psql commands
    
    (I hope that this is less controversial, too.)
    
    -- 
    Florian Weimer                <fweimer@bfk.de>
    BFK edv-consulting GmbH       http://www.bfk.de/
    Kriegsstraße 100              tel: +49-721-96201-1
    D-76133 Karlsruhe             fax: +49-721-96201-99
    
    
  49. Re: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-21T17:58:25Z

    On Jan 21, 2010, at 11:48 AM, Florian Weimer wrote:
    
    > * David Christensen:
    >
    >> Currently, a session will look like the following:
    >>
    >>  machack:machack:5485=# show tables;
    >>  See:
    >>         \d
    >>         or \? for general help with psql commands
    >>  machack:machack:5485=#
    >>
    >> Said formatting looks like it could use some improvement, open to
    >> suggestions, but something on a single line seems more useful.
    >
    > You should at least make clear that this is an error message due to an
    > unsupported command.  The output above looks broken.  Something like
    > this should be okay, I think:
    >
    > ERROR:  unrecognized configuration parameter "tables"
    > NOTICE: use \d to list tables, or \? for general help with psql  
    > commands
    >
    > ERROR:  unrecognized configuration parameter "databases"
    > NOTICE: use \l to list databases, or \? for general help with psql  
    > commands
    
    
    That's a very good point as far as the visibility is concerned.   
    Should the error messages between the SHOW cases and the others be  
    consistent ("ERROR: unsupported command" or similar)?  It's worth  
    noting that this is only in the psql client, but we could simulate the  
    ereport output from the server.
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com
    
    
    
    
    
    
  50. Re: MySQL-ism help patch for psql

    Pavel Stehule <pavel.stehule@gmail.com> — 2010-01-21T18:01:30Z

    2010/1/21 David Christensen <david@endpoint.com>:
    >
    > On Jan 21, 2010, at 11:48 AM, Florian Weimer wrote:
    >
    >> * David Christensen:
    >>
    >>> Currently, a session will look like the following:
    >>>
    >>>  machack:machack:5485=# show tables;
    >>>  See:
    >>>        \d
    >>>        or \? for general help with psql commands
    >>>  machack:machack:5485=#
    >>>
    >>> Said formatting looks like it could use some improvement, open to
    >>> suggestions, but something on a single line seems more useful.
    >>
    >> You should at least make clear that this is an error message due to an
    >> unsupported command.  The output above looks broken.  Something like
    >> this should be okay, I think:
    >>
    >> ERROR:  unrecognized configuration parameter "tables"
    >> NOTICE: use \d to list tables, or \? for general help with psql commands
    >>
    >> ERROR:  unrecognized configuration parameter "databases"
    >> NOTICE: use \l to list databases, or \? for general help with psql
    >> commands
    >
    >
    > That's a very good point as far as the visibility is concerned.  Should the
    > error messages between the SHOW cases and the others be consistent ("ERROR:
    > unsupported command" or similar)?  It's worth noting that this is only in
    > the psql client, but we could simulate the ereport output from the server.
    
    I don't think so it is the best idea. I like different message types,
    because I able to identify place of error. If it is server or client
    error.
    
    Pavel
    
    >
    > Regards,
    >
    > David
    > --
    > David Christensen
    > End Point Corporation
    > david@endpoint.com
    >
    >
    >
    >
    >
    > --
    > Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
    > To make changes to your subscription:
    > http://www.postgresql.org/mailpref/pgsql-hackers
    >
    
    
  51. Re: MySQL-ism help patch for psql

    Tom Lane <tgl@sss.pgh.pa.us> — 2010-01-21T18:02:28Z

    David Christensen <david@endpoint.com> writes:
    > Should the error messages between the SHOW cases and the others be  
    > consistent ("ERROR: unsupported command" or similar)?  It's worth  
    > noting that this is only in the psql client, but we could simulate the  
    > ereport output from the server.
    
    No.  Not unless you want to simulate it to the point of honoring the
    different verbosity settings, which would greatly expand the size of the
    patch.  We do not try to make the response to "help" look like an error
    message, and I don't see the value of doing so here either.
    
    (I think Florian's real problem with the proposed output is that it's
    ugly, which I agree with --- the formatting is strange.)
    
    			regards, tom lane
    
    
  52. Re: MySQL-ism help patch for psql

    David Christensen <david@endpoint.com> — 2010-01-21T18:06:18Z

    On Jan 21, 2010, at 12:02 PM, Tom Lane wrote:
    
    > David Christensen <david@endpoint.com> writes:
    >> Should the error messages between the SHOW cases and the others be
    >> consistent ("ERROR: unsupported command" or similar)?  It's worth
    >> noting that this is only in the psql client, but we could simulate  
    >> the
    >> ereport output from the server.
    >
    > No.  Not unless you want to simulate it to the point of honoring the
    > different verbosity settings, which would greatly expand the size of  
    > the
    > patch.  We do not try to make the response to "help" look like an  
    > error
    > message, and I don't see the value of doing so here either.
    >
    > (I think Florian's real problem with the proposed output is that it's
    > ugly, which I agree with --- the formatting is strange.)
    
    
    I'm with you on that one; I tried to address that in the second  
    revision of the patch.  But I'm definitely open to suggestions.
    
    Regards,
    
    David
    --
    David Christensen
    End Point Corporation
    david@endpoint.com