MySQL-ism help patch for psql

Started by David Christensenalmost 16 years ago71 messages
#1David Christensen
david@endpoint.com

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);
#2Jeff Davis
pgsql@j-davis.com
In reply to: David Christensen (#1)
Re: MySQL-ism help patch for psql

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

#3Stefan Kaltenbrunner
stefan@kaltenbrunner.cc
In reply to: Jeff Davis (#2)
Re: MySQL-ism help patch for psql

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

#4Jeff Davis
pgsql@j-davis.com
In reply to: Stefan Kaltenbrunner (#3)
Re: MySQL-ism help patch for psql

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

#5Jeff Davis
pgsql@j-davis.com
In reply to: Jeff Davis (#4)
Re: MySQL-ism help patch for psql

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

#6Stefan Kaltenbrunner
stefan@kaltenbrunner.cc
In reply to: Jeff Davis (#4)
Re: MySQL-ism help patch for psql

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

In reply to: David Christensen (#1)
Re: MySQL-ism help patch for psql

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/

#8Jeff Davis
pgsql@j-davis.com
In reply to: Stefan Kaltenbrunner (#6)
Re: MySQL-ism help patch for psql

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

#9Tom Lane
tgl@sss.pgh.pa.us
In reply to: Jeff Davis (#8)
Re: MySQL-ism help patch for psql

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

#10Magnus Hagander
magnus@hagander.net
In reply to: Tom Lane (#9)
Re: MySQL-ism help patch for psql

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/

#11David Christensen
david@endpoint.com
In reply to: Tom Lane (#9)
Re: MySQL-ism help patch for psql

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

#12Bruce Momjian
bruce@momjian.us
In reply to: Tom Lane (#9)
Re: MySQL-ism help patch for psql

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. +

#13Stefan Kaltenbrunner
stefan@kaltenbrunner.cc
In reply to: Tom Lane (#9)
Re: MySQL-ism help patch for psql

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

#14Andrew Dunstan
andrew@dunslane.net
In reply to: David Christensen (#1)
Re: MySQL-ism help patch for psql

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

#15David Christensen
david@endpoint.com
In reply to: Stefan Kaltenbrunner (#13)
Re: MySQL-ism help patch for psql

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

#16David Christensen
david@endpoint.com
In reply to: Andrew Dunstan (#14)
Re: MySQL-ism help patch for psql

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

#17David E. Wheeler
david@kineticode.com
In reply to: Stefan Kaltenbrunner (#13)
Re: MySQL-ism help patch for psql

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

#18Andrew Dunstan
andrew@dunslane.net
In reply to: David Christensen (#16)
Re: MySQL-ism help patch for psql

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&gt;

cheers

andrew

#19Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Christensen (#15)
Re: MySQL-ism help patch for psql

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

#20Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Christensen (#16)
Re: MySQL-ism help patch for psql

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

#21Devrim GÜNDÜZ
devrim@gunduz.org
In reply to: Jeff Davis (#2)
Re: MySQL-ism help patch for psql

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

#22David Christensen
david@endpoint.com
In reply to: Tom Lane (#19)
Re: MySQL-ism help patch for psql

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

#23David Christensen
david@endpoint.com
In reply to: Devrim GÜNDÜZ (#21)
Re: MySQL-ism help patch for psql

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

#24David E. Wheeler
david@kineticode.com
In reply to: Tom Lane (#19)
Re: MySQL-ism help patch for psql

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

#25Robert Haas
robertmhaas@gmail.com
In reply to: David E. Wheeler (#24)
Re: MySQL-ism help patch for psql

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

#26Rob Wultsch
wultsch@gmail.com
In reply to: David E. Wheeler (#24)
Re: MySQL-ism help patch for psql

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

#27Dimitri Fontaine
dfontaine@hi-media.com
In reply to: Robert Haas (#25)
Re: MySQL-ism help patch for psql

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

#28David Christensen
david@endpoint.com
In reply to: Robert Haas (#25)
1 attachment(s)
Patch rev 2: MySQL-ism help patch for psql

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

Attachments:

mysql-help.patchapplication/octet-stream; name=mysql-help.patch; x-unix-mode=0644Download
diff --git a/src/bin/psql/mainloop.c b/src/bin/psql/mainloop.c
index e2914ae..5ed5ded 100644
*** a/src/bin/psql/mainloop.c
--- b/src/bin/psql/mainloop.c
*************** MainLoop(FILE *source)
*** 197,202 ****
--- 197,244 ----
  			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(_("\nPerhaps you want \"" \
+ 				 o\
+ 				 "\"?\n"\
+ 				 "See \\? for 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\" or \"set search_path = schema");
+ 			}
+ 			else if (MYSQL_HELP_CHECK("show tables"))
+ 			{
+ 				MYSQL_HELP_OUTPUT("\\dt");
+ 			}
+ 			else if (MYSQL_HELP_CHECK("show databases"))
+ 			{
+ 				MYSQL_HELP_OUTPUT("\\l");
+ 			}
+ 			else if (MYSQL_HELP_CHECK("show processlist"))
+ 			{
+ 				MYSQL_HELP_OUTPUT("SELECT * FROM pg_stat_activity;");
+ 			}
+ 			else if (MYSQL_HELP_CHECK("describe"))
+ 			{
+ 				MYSQL_HELP_OUTPUT("\\d tablename");
+ 			}
+ 			else if (MYSQL_HELP_CHECK("desc"))
+ 			{
+ 				MYSQL_HELP_OUTPUT("\\d tablename");
+ 			}
+ 		}
+ 
  		/* echo back if flag is set */
  		if (pset.echo == PSQL_ECHO_ALL && !pset.cur_cmd_interactive)
  			puts(line);
#29David Christensen
david@endpoint.com
In reply to: David Christensen (#28)
Re: Patch rev 2: MySQL-ism help patch for psql

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

#30Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Christensen (#29)
Re: Patch rev 2: MySQL-ism help patch for psql

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

#31Craig Ringer
craig@postnewspapers.com.au
In reply to: Rob Wultsch (#26)
Re: MySQL-ism help patch for psql

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

#32Greg Sabino Mullane
greg@turnstep.com
In reply to: David E. Wheeler (#24)
Re: MySQL-ism help patch for psql

-----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-----

#33Greg Stark
stark@mit.edu
In reply to: Greg Sabino Mullane (#32)
Re: MySQL-ism help patch for psql

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...

#34Rob Wultsch
wultsch@gmail.com
In reply to: David Christensen (#28)
Re: Patch rev 2: MySQL-ism help patch for psql

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

#35Peter Eisentraut
peter_e@gmx.net
In reply to: Jeff Davis (#4)
Re: MySQL-ism help patch for psql

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.

#36Peter Eisentraut
peter_e@gmx.net
In reply to: David Christensen (#22)
Re: MySQL-ism help patch for psql

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.

#37Bruce Momjian
bruce@momjian.us
In reply to: Peter Eisentraut (#36)
Re: MySQL-ism help patch for psql

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. +

#38Peter Eisentraut
peter_e@gmx.net
In reply to: Bruce Momjian (#37)
Re: MySQL-ism help patch for psql

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.

#39Robert Haas
robertmhaas@gmail.com
In reply to: Bruce Momjian (#37)
Re: MySQL-ism help patch for psql

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

#40Robert Haas
robertmhaas@gmail.com
In reply to: Peter Eisentraut (#38)
Re: MySQL-ism help patch for psql

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

#41Andrew Dunstan
andrew@dunslane.net
In reply to: Robert Haas (#40)
Re: MySQL-ism help patch for psql

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

#42Dimitri Fontaine
dfontaine@hi-media.com
In reply to: Robert Haas (#40)
Re: MySQL-ism help patch for psql

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

#43Bruce Momjian
bruce@momjian.us
In reply to: Dimitri Fontaine (#42)
Re: MySQL-ism help patch for psql

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. +

#44Kevin Grittner
Kevin.Grittner@wicourts.gov
In reply to: Dimitri Fontaine (#42)
Re: MySQL-ism help patch for psql

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

#45Gabriele Bartolini
gabriele.bartolini@2ndquadrant.it
In reply to: Kevin Grittner (#44)
Re: MySQL-ism help patch for psql

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

Show quoted text

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

#46Tom Lane
tgl@sss.pgh.pa.us
In reply to: Dimitri Fontaine (#42)
Re: MySQL-ism help patch for psql

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

#47Dimitri Fontaine
dfontaine@hi-media.com
In reply to: Tom Lane (#46)
Re: MySQL-ism help patch for psql

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

#48Florian Weimer
fweimer@bfk.de
In reply to: David Christensen (#22)
Re: MySQL-ism help patch for psql

* 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

#49David Christensen
david@endpoint.com
In reply to: Florian Weimer (#48)
Re: MySQL-ism help patch for psql

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

#50Pavel Stehule
pavel.stehule@gmail.com
In reply to: David Christensen (#49)
Re: MySQL-ism help patch for psql

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

Show quoted text

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

#51Tom Lane
tgl@sss.pgh.pa.us
In reply to: David Christensen (#49)
Re: MySQL-ism help patch for psql

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

#52David Christensen
david@endpoint.com
In reply to: Tom Lane (#51)
Re: MySQL-ism help patch for psql

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

#53Baron Schwartz
baron@xaprb.com
In reply to: David Christensen (#52)
Re: MySQL-ism help patch for psql

David Fetter just pointed this thread out to me. I think anything
that makes PostgreSQL more accessible could be a good thing. In some
sense it's harder to learn a technology when you are very familiar
with another similar one already. Is it easier to learn to type on
Dvorak, or to learn QWERTY and then switch to Dvorak? Switching was
harder for me than learning initially.

So I guess my advice, since David asked me :-) is not to underestimate
the pain of switching. I don't know whether this patch is the Right
Answer, but I think the sentiment is something to be encouraged. If
it's not the right answer, then maybe some brainstorming and user
input will reveal creative alternatives. I'll start:

== begin ==

Welcome to the POSTGRESQL interactive sql monitor:
Please read the file COPYRIGHT for copyright terms of POSTGRESQL

type \? for help on slash commands
type \mysql for a quick MySQL-to-PostgreSQL cheatsheet

somedb=> \mysql

psql uses backslash keywords instead of SHOW commands. There is
also a standard INFORMATION_SCHEMA if you're familiar with that.
The following commands might be helpful as you learn how to use psql:

Command in mysql Command in psql
================ ===============
SHOW TABLES \dt
DESCRIBE \d
... and so on.

== end ==

The full list of SHOW commands, should anyone be interested, is at
http://dev.mysql.com/doc/en/show.html

Cheers,
Baron

#54Cédric Villemain
cedric.villemain.debian@gmail.com
In reply to: Baron Schwartz (#53)
Re: MySQL-ism help patch for psql

2010/1/24 Baron Schwartz <baron@xaprb.com>:

David Fetter just pointed this thread out to me.  I think anything
that makes PostgreSQL more accessible could be a good thing.  In some
sense it's harder to learn a technology when you are very familiar
with another similar one already.  Is it easier to learn to type on
Dvorak, or to learn QWERTY and then switch to Dvorak?  Switching was
harder for me than learning initially.

So I guess my advice, since David asked me :-) is not to underestimate
the pain of switching.  I don't know whether this patch is the Right
Answer, but I think the sentiment is something to be encouraged.  If
it's not the right answer, then maybe some brainstorming and user
input will reveal creative alternatives.  I'll start:

'psql --help mysql' (or 'psql --tips mysql' ) might be good to call a
special helper : I don't see the point to introduce that kind of
things when it is useless for most of our users. (so 'psql' won't
output any tips relative to mysql)

It offer then to have a 'psql --help oracle' or anyother special tips
we want to provide for our new users and following their knowledge.

And it will be able to provide usefull tips à la git for postgresql
regular users. (selcet --> did you mean select instead of selcet ?)

Regards,
Cédric

== begin ==

Welcome to the POSTGRESQL interactive sql monitor:
 Please read the file COPYRIGHT for copyright terms of POSTGRESQL

  type \? for help on slash commands
  type \mysql for a quick MySQL-to-PostgreSQL cheatsheet

somedb=> \mysql

psql uses backslash keywords instead of SHOW commands.  There is
also a standard INFORMATION_SCHEMA if you're familiar with that.
The following commands might be helpful as you learn how to use psql:

 Command in mysql  Command in psql
 ================  ===============
 SHOW TABLES       \dt
 DESCRIBE          \d
 ... and so on.

== end ==

The full list of SHOW commands, should anyone be interested, is at
http://dev.mysql.com/doc/en/show.html

Cheers,
Baron

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

--
Cédric Villemain

#55Baron Schwartz
baron@xaprb.com
In reply to: Cédric Villemain (#54)
Re: MySQL-ism help patch for psql

Hi Cédric,

On Sun, Jan 24, 2010 at 5:11 PM, Cédric Villemain
<cedric.villemain.debian@gmail.com> wrote:

'psql --help mysql' (or 'psql --tips mysql' ) might be good to call a
special helper : I don't see the point to introduce that kind of
things when it is useless for most of our users.

I think it's good to go beyond what's useful for most users. It's
good to help potential users, too.

- Baron

#56Cédric Villemain
cedric.villemain.debian@gmail.com
In reply to: Baron Schwartz (#55)
Re: MySQL-ism help patch for psql

2010/1/25 Baron Schwartz <baron@xaprb.com>:

Hi Cédric,

On Sun, Jan 24, 2010 at 5:11 PM, Cédric Villemain
<cedric.villemain.debian@gmail.com> wrote:

'psql --help mysql' (or 'psql --tips mysql' ) might be good to call a
special helper : I don't see the point to introduce that kind of
things when it is useless for most of our users.

I think it's good to go beyond what's useful for most users.  It's
good to help potential users, too.

Absolutly, that's why I suggest to give a simple option to activate
those helpers.
We didn't remove extra lines on the psql login to add anothers now.

--
Cédric Villemain

#57Alastair "Bell" Turner
thebellhead@gmail.com
In reply to: Cédric Villemain (#56)
Re: MySQL-ism help patch for psql

If this option is designed to help people's transition - basically to
get to them before they've got to most of the manual - having to turn
it on will be pointless. It needs to be active by default. A way to
avoid it being a default option in psql may be setting an alias as
part of package installation so power users couid turn it off by
without having to add a switch to their command lines. It's not going
to have anything to say to experienced psql users anyway so it would
probably not bug anyone enough to turn it off.

Regards

Alastair

On Mon, Jan 25, 2010 at 5:46 PM, Cédric Villemain
<cedric.villemain.debian@gmail.com> wrote:

Show quoted text

2010/1/25 Baron Schwartz <baron@xaprb.com>:

Hi Cédric,

On Sun, Jan 24, 2010 at 5:11 PM, Cédric Villemain
<cedric.villemain.debian@gmail.com> wrote:

'psql --help mysql' (or 'psql --tips mysql' ) might be good to call a
special helper : I don't see the point to introduce that kind of
things when it is useless for most of our users.

I think it's good to go beyond what's useful for most users.  It's
good to help potential users, too.

Absolutly, that's why I suggest to give a simple option to activate
those helpers.
We didn't remove extra lines on the psql login to add anothers now.

--
Cédric Villemain

--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers

#58Aidan Van Dyk
aidan@highrise.ca
In reply to: Alastair "Bell" Turner (#57)
Re: MySQL-ism help patch for psql

* Alastair Bell Turner <thebellhead@gmail.com> [100125 11:07]:

If this option is designed to help people's transition - basically to
get to them before they've got to most of the manual - having to turn
it on will be pointless. It needs to be active by default. A way to
avoid it being a default option in psql may be setting an alias as
part of package installation so power users couid turn it off by
without having to add a switch to their command lines. It's not going
to have anything to say to experienced psql users anyway so it would
probably not bug anyone enough to turn it off.

I'ld be more comfortable for a line in t the more standard help along
the lines of:
"For more information on PSQL commands when coming from other
databases, see the documentation."

And then we can have a full discussion in the docs, psql man page,
wherever, where you can actually *describe* the differences between the
commands, etc, instead of loosing the useful information because of
trying to stuff things into a 1-line message about something that might
not have been intended...

And then you can have a section on MySQL, SQLite, DB2, Informix,
Firebird, Oracle, etc... Basically a section for whoever has an itch.

a.

--
Aidan Van Dyk Create like a god,
aidan@highrise.ca command like a king,
http://www.highrise.ca/ work like a slave.

#59Andrew Dunstan
andrew@dunslane.net
In reply to: Alastair "Bell" Turner (#57)
Re: MySQL-ism help patch for psql

Alastair "Bell" Turner wrote:

If this option is designed to help people's transition - basically to
get to them before they've got to most of the manual - having to turn
it on will be pointless. It needs to be active by default.

My problem with this whole idea is that it seems to be very
MySQL-specific. Why aren't we providing help for users migrating from
Oracle, Sybase, Informix, Ingres, DB2, SQLServer and Firebird, to name
but a few? And if we turn all those on by default, we'll have a pretty
horrible banner when starting psql.

cheers

andrew

#60Alastair "Bell" Turner
thebellhead@gmail.com
In reply to: Andrew Dunstan (#59)
Re: MySQL-ism help patch for psql

On Mon, Jan 25, 2010 at 6:14 PM, Andrew Dunstan <andrew@dunslane.net> wrote:

My problem with this whole idea is that it seems to be very MySQL-specific.
Why aren't we providing help for users migrating from Oracle, Sybase,
Informix, Ingres, DB2, SQLServer and Firebird, to name but a few? And if we
turn all those on by default, we'll have a pretty horrible banner when
starting psql.

cheers

andrew

The easy way around that would be a message along the lines of '
\migrate for information on how the commands from your previous
environment translate to psql' It's a bit verbose but could be trimmed
I'm sure.

The \migrate mysql, \migrate db2, \migrate ingres ... could all do
their own thing. Some of the command specific responses won't be
extened too much either since DESCRIBE and SHOW apply in multiple
places similarly enough that the one line reminder could be
interchangable.

#61Robert Haas
robertmhaas@gmail.com
In reply to: Andrew Dunstan (#59)
Re: MySQL-ism help patch for psql

On Mon, Jan 25, 2010 at 11:14 AM, Andrew Dunstan <andrew@dunslane.net> wrote:

Alastair "Bell" Turner wrote:

If this option is designed to help people's transition - basically to
get to them before they've got to most of the manual - having to turn
it on will be pointless. It needs to be active by default.

My problem with this whole idea is that it seems to be very MySQL-specific.
Why aren't we providing help for users migrating from Oracle, Sybase,
Informix, Ingres, DB2, SQLServer and Firebird, to name but a few? And if we
turn all those on by default, we'll have a pretty horrible banner when
starting psql.

I don't really have a horse in this race, but perhaps the answer is
that people are asking for MySQL help but no one is asking for help
migrating from any of those other databases. At least not yet. But I
think we're getting off into the weeds a little bit here. In theory,
people who notice that psql gives the following message should be OK:

Type "help" for help.

Now when you type help, you get this:

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

Now, at this point, if you are a MySQL user who wants to find the
equivalent of SHOW TABLES and DESCRIBE, it's very plausible that
you'll now try \h, because SHOW TABLES and DESCRIBE are SQL commands.
Then you might try some things like:

\h SHOW
\h TABLE

...hoping to find what you're looking for. If you eventually go back
and try \? you will hopefully notice this line (which at least in my
terminal window doesn't even show up until the second page):

\d[S+] list tables, views, and sequences

It's not too much to hope that you'll try \d at this point and get a
list of all your tables, but it's far from clear how you'd know that
"\d foo" is the way to get the column definitions for foo.

Maybe instead of (or in addition to) providing MySQL-specific help, we
should find a way to emphasize the "\d" and "\d table" commands,
because those are (IMO) two big things that people coming from ANY
other database product are likely to want to find, and it's not as
easy to find them right now as perhaps it should be.

...Robert

#62Ross J. Reedstrom
reedstrm@rice.edu
In reply to: Alastair "Bell" Turner (#57)
Re: MySQL-ism help patch for psql

On Mon, Jan 25, 2010 at 06:06:53PM +0200, Alastair Bell Turner wrote:
<..>

without having to add a switch to their command lines. It's not going
to have anything to say to experienced psql users anyway so it would
probably not bug anyone enough to turn it off.

I would so use this feature going the other way: fire up comfortable
psql and see what mysql command I need to type ... Having it in the
interface (behind \help [mysql|oracle|firebird|mssql|..] seems reasonable
to me, given how much info we already have in \help. I find the basic
BNF help for SQL syntax still useful reminder, and know to go to the
actual docs when there's not enough there. So a quick mapping of
most-needed commands, and a pointer to the docs for the full
ramifications and subtle differences seems to fit the existing
documentation module.

Ross
--
Ross Reedstrom, Ph.D. reedstrm@rice.edu
Systems Engineer & Admin, Research Scientist phone: 713-348-6166
The Connexions Project http://cnx.org fax: 713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE

#63Ross J. Reedstrom
reedstrm@rice.edu
In reply to: Ross J. Reedstrom (#62)
Re: MySQL-ism help patch for psql

On Mon, Jan 25, 2010 at 10:49:55AM -0600, Ross J. Reedstrom wrote:

On Mon, Jan 25, 2010 at 06:06:53PM +0200, Alastair Bell Turner wrote:
<..>

without having to add a switch to their command lines. It's not going
to have anything to say to experienced psql users anyway so it would
probably not bug anyone enough to turn it off.

I would so use this feature going the other way: fire up comfortable
psql and see what mysql command I need to type ... Having it in the
interface (behind \help [mysql|oracle|firebird|mssql|..] seems reasonable
to me, given how much info we already have in \help. I find the basic

BNF help for SQL syntax still useful reminder, and know to go to the

Well, behind \migrate or some other word as others have, since I see
\help is just the SQL help I so praised.

Ross
--
Ross Reedstrom, Ph.D. reedstrm@rice.edu
Systems Engineer & Admin, Research Scientist phone: 713-348-6166
The Connexions Project http://cnx.org fax: 713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE

#64Greg Smith
greg@2ndquadrant.com
In reply to: Ross J. Reedstrom (#62)
Re: MySQL-ism help patch for psql

Ross J. Reedstrom wrote:

So a quick mapping of most-needed commands, and a pointer to the docs for the full
ramifications and subtle differences seems to fit the existing
documentation module.

And that's been done at least twice already:

http://blog.endpoint.com/2009/12/mysql-and-postgres-command-equivalents.html
http://en.wikibooks.org/wiki/Converting_MySQL_to_PostgreSQL

--
Greg Smith 2ndQuadrant Baltimore, MD
PostgreSQL Training, Services and Support
greg@2ndQuadrant.com www.2ndQuadrant.com

#65Bruce Momjian
bruce@momjian.us
In reply to: Ross J. Reedstrom (#62)
Re: MySQL-ism help patch for psql

Ross J. Reedstrom wrote:

On Mon, Jan 25, 2010 at 06:06:53PM +0200, Alastair Bell Turner wrote:
<..>

without having to add a switch to their command lines. It's not going
to have anything to say to experienced psql users anyway so it would
probably not bug anyone enough to turn it off.

I would so use this feature going the other way: fire up comfortable
psql and see what mysql command I need to type ... Having it in the
interface (behind \help [mysql|oracle|firebird|mssql|..] seems reasonable
to me, given how much info we already have in \help. I find the basic
BNF help for SQL syntax still useful reminder, and know to go to the
actual docs when there's not enough there. So a quick mapping of
most-needed commands, and a pointer to the docs for the full
ramifications and subtle differences seems to fit the existing
documentation module.

It would be interesting to implement \help mysql, and then have commands
like SHOW TABLE trigger a message suggesting they do \help mysql.

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

+ If your life is a hard drive, Christ can be your backup. +

#66Baron Schwartz
baron@xaprb.com
In reply to: Robert Haas (#61)
Re: MySQL-ism help patch for psql

Hi Robert,

On Mon, Jan 25, 2010 at 11:41 AM, Robert Haas <robertmhaas@gmail.com> wrote:

Maybe instead of (or in addition to) providing MySQL-specific help, we
should find a way to emphasize the "\d" and "\d table" commands,

Right, it's like "cd" and "ls" at the shell prompt. It's like walking
into a dark room and not knowing where the light switch is. I'll
think of more metaphors later.

What if the text you see upon starting psql says something like "Type
\dt to ... type \h for more help" ?

#67Robert Haas
robertmhaas@gmail.com
In reply to: Baron Schwartz (#66)
Re: MySQL-ism help patch for psql

On Mon, Jan 25, 2010 at 1:05 PM, Baron Schwartz <baron@xaprb.com> wrote:

Hi Robert,

On Mon, Jan 25, 2010 at 11:41 AM, Robert Haas <robertmhaas@gmail.com> wrote:

Maybe instead of (or in addition to) providing MySQL-specific help, we
should find a way to emphasize the "\d" and "\d table" commands,

Right, it's like "cd" and "ls" at the shell prompt.  It's like walking
into a dark room and not knowing where the light switch is.  I'll
think of more metaphors later.

What if the text you see upon starting psql says something like "Type
\dt to ... type \h for more help" ?

Well, we used to display this banner when psql started up:

Welcome to psql 8.3.8, the PostgreSQL interactive terminal.

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

But it got changed, so now it just tells you to type help and if you
do then you get that banner. But maybe that's OK. Since the banner
isn't being printed on every startup, it might be OK for it to be a
bit longer, like, I dunno:

Type: \copyright for distribution terms
\h for help with SQL commands
\d for a list of tables, views, and sequences in the current database
\d name for more details on the named table, view, index, or sequence
\? for further help with psql commands
\g or terminate with semicolon to execute query
\q to quit

That might be just enough of a push to get people pointed in the right
direction.

...Robert

#68Josh Berkus
josh@agliodbs.com
In reply to: Robert Haas (#61)
Re: MySQL-ism help patch for psql

My problem with this whole idea is that it seems to be very MySQL-specific.
Why aren't we providing help for users migrating from Oracle, Sybase,
Informix, Ingres, DB2, SQLServer and Firebird, to name but a few? And if we
turn all those on by default, we'll have a pretty horrible banner when
starting psql.

We should do all of those. However, we have to start somewhere.

Therefore, I like the idea of having a switch, like:
\advice mysql
\advice db2
etc.

ALSO, I'll point out that a page in our official documentation with
extensive docs on commands and migration issues would be far more
helpful than any amount of psql messages. Just sayin'.

--Josh Berkus

#69Baron Schwartz
baron@xaprb.com
In reply to: Josh Berkus (#68)
Re: MySQL-ism help patch for psql

Josh,

On Mon, Jan 25, 2010 at 1:47 PM, Josh Berkus <josh@agliodbs.com> wrote:

My problem with this whole idea is that it seems to be very MySQL-specific.
Why aren't we providing help for users migrating from Oracle, Sybase,
Informix, Ingres, DB2, SQLServer and Firebird, to name but a few? And if we
turn all those on by default, we'll have a pretty horrible banner when
starting psql.

We should do all of those.  However, we have to start somewhere.

Therefore, I like the idea of having a switch, like:
\advice mysql
\advice db2
etc.

ALSO, I'll point out that a page in our official documentation with
extensive docs on commands and migration issues would be far more
helpful than any amount of psql messages.  Just sayin'.

Hypothetically, if I had time to help with something like that, is
there a wiki or something where I could help draft it, without needing
to get all elbows-deep into the documentation itself?

Baron

#70Josh Berkus
josh@agliodbs.com
In reply to: Baron Schwartz (#69)
Re: MySQL-ism help patch for psql

Baron,

Hypothetically, if I had time to help with something like that, is
there a wiki or something where I could help draft it, without needing
to get all elbows-deep into the documentation itself?

wiki.postgresql.org.

--Josh

#71Bruce Momjian
bruce@momjian.us
In reply to: Josh Berkus (#68)
Re: MySQL-ism help patch for psql

Josh Berkus wrote:

My problem with this whole idea is that it seems to be very MySQL-specific.
Why aren't we providing help for users migrating from Oracle, Sybase,
Informix, Ingres, DB2, SQLServer and Firebird, to name but a few? And if we
turn all those on by default, we'll have a pretty horrible banner when
starting psql.

We should do all of those. However, we have to start somewhere.

Therefore, I like the idea of having a switch, like:
\advice mysql
\advice db2
etc.

ALSO, I'll point out that a page in our official documentation with
extensive docs on commands and migration issues would be far more
helpful than any amount of psql messages. Just sayin'.

I don't think we came to any firm conclusion in this thread, so I have
added a TODO item:

Add option to print advice for people familiar with other databases

* http://archives.postgresql.org/pgsql-hackers/2010-01/msg01845.php

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

+ If your life is a hard drive, Christ can be your backup. +