Обсуждение: failure and silence of SQL commands

Поиск
Список
Период
Сортировка

failure and silence of SQL commands

От
"John Payne"
Дата:

Thank you both very much for your help; that was the problem.  Stupid of me (the answer came to me in the shower this morning as well).  If anyone out there in the developer community is listening, may I respectfully suggest that PSQL’s behavior --- to return nothing when Enter is hit – is pathological.  It would be so simple to return a message like ”Waiting for the end of the statement…” and it would save novices like me a lot of very unhappy hours. 

 

Cheers,

 

John

 

Re: failure and silence of SQL commands

От
Leif Biberg Kristensen
Дата:
On Thursday 28 April 2011 19:21:39 John Payne wrote:
> Thank you both very much for your help; that was the problem.  Stupid of me
> (the answer came to me in the shower this morning as well).  If anyone out
> there in the developer community is listening, may I respectfully suggest
> that PSQL's behavior --- to return nothing when Enter is hit - is
> pathological.  It would be so simple to return a message like "Waiting for
> the end of the statement." and it would save novices like me a lot of very
> unhappy hours.

If you enter a line in psql without a final ; and then hit Enter, you should
notice that the prompt changes from a => to a ->. There's your "Waiting for
the end of the statement" message.

Your suggestion is, frankly said, ridiculous.

regards, Leif.

Re: failure and silence of SQL commands

От
Robert Poor
Дата:
On Thu, Apr 28, 2011 at 10:40, Leif Biberg Kristensen
<leif@solumslekt.org> wrote:
> Your suggestion is, frankly said, ridiculous.

Gosh, Leif, where's the love?   We were all novices once upon a time.

Re: failure and silence of SQL commands

От
Leif Biberg Kristensen
Дата:
On Thursday 28 April 2011 19:50:59 Robert Poor wrote:
> On Thu, Apr 28, 2011 at 10:40, Leif Biberg Kristensen
>
> <leif@solumslekt.org> wrote:
> > Your suggestion is, frankly said, ridiculous.
>
> Gosh, Leif, where's the love?   We were all novices once upon a time.

Perhaps I was a bit harsh, but it was a reflex to the word "pathological" about
psql's behaviour. Coming from a novice, that's quite a mouthful.

regards, Leif

Re: failure and silence of SQL commands

От
Michael Swierczek
Дата:
On Thu, Apr 28, 2011 at 1:21 PM, John Payne <jcpayne@uw.edu> wrote:
> Thank you both very much for your help; that was the problem.  Stupid of me
> (the answer came to me in the shower this morning as well).  If anyone out
> there in the developer community is listening, may I respectfully suggest
> that PSQL’s behavior --- to return nothing when Enter is hit – is
> pathological.  It would be so simple to return a message like ”Waiting for
> the end of the statement…” and it would save novices like me a lot of very
> unhappy hours.
>

You're more ambitious than I was.  When I started using PostgreSQL I
found psql intimidating so I used pgAdmin3 whenever possible.
pgAdmin3 is excellent and in my opinion much more friendly to us
novices than psql.  Good luck.

Regards,
Mike

Re: failure and silence of SQL commands

От
Tom Lane
Дата:
Robert Poor <rdpoor@gmail.com> writes:
> On Thu, Apr 28, 2011 at 10:40, Leif Biberg Kristensen
> <leif@solumslekt.org> wrote:
>> Your suggestion is, frankly said, ridiculous.

> Gosh, Leif, where's the love?   We were all novices once upon a time.

Yeah, and John's not exactly the first person to forget a semicolon.
I don't much like his proposed solution, because it would degrade from
"useful" to "incredibly irritating" after just a few minutes, or at
least it would as soon as you knew enough SQL to be entering multiline
queries.  But it's worth thinking about how to respond to the problem.

In recent versions of psql, if you type "help" as the startup prompt
suggests, it will mention use of a semicolon:

$ psql postgres
psql (9.1devel)
Type "help" for help.

postgres=# help
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
postgres=#

Now the first question is whether the "terminate with semicolon"
bit is clear enough for a novice.  Some comments on this message
from someone who's just seen it for the first time might be useful.

The other thing that strikes me is that in order to make sure that
we don't accidentally take part of a SQL command as a help request,
"help" is only recognized as the very first word of input.  So if
you'd put in some text and then started to wonder why you're not
getting an answer, "help" doesn't help:

postgres=# select 2+2
postgres-# help
postgres-#

Maybe we should be a little looser there?  I mean, in theory the word
"help" alone on a line could be an intended part of a larger SQL
command, but in practice what are the odds?

            regards, tom lane

Re: failure and silence of SQL commands

От
Leif Biberg Kristensen
Дата:
On Thursday 28 April 2011 20:30:24 Tom Lane wrote:
> Robert Poor <rdpoor@gmail.com> writes:
> > On Thu, Apr 28, 2011 at 10:40, Leif Biberg Kristensen
> >
> > <leif@solumslekt.org> wrote:
> >> Your suggestion is, frankly said, ridiculous.
> >
> > Gosh, Leif, where's the love?   We were all novices once upon a time.
>
> Yeah, and John's not exactly the first person to forget a semicolon.
> I don't much like his proposed solution, because it would degrade from
> "useful" to "incredibly irritating" after just a few minutes, or at
> least it would as soon as you knew enough SQL to be entering multiline
> queries.  But it's worth thinking about how to respond to the problem.

I remember, back in the Stone Age, my first word processor had 4 levels of help
which could be changed by the user as he grew more proficient. Maybe a distinct
"Novice mode" in psql with the proposed kind of chatter could ease the
learning curve for the command-line challenged.

regards, Leif.

Re: failure and silence of SQL commands

От
Robert Poor
Дата:
@Lief, @Tom: Good points (especially 'and John's not exactly the first
person to forget a semicolon.' ;)

Part of the problem may be that 'postgres=#' and 'postgres-#' look
mighty similar.  If so, a simple fix would be to change PROMPT2 from
'%/%R%# ' to '%R%# ', that is, make a toplevel prompt show the
database name:

    postgres=#

and drop the database name in the 'continuation' prompt:

    -#

which would make it a lot more obvious that it's waiting for input.
John (et al) -- what do you think?

- r

Re: failure and silence of SQL commands

От
Lew
Дата:
On 04/28/2011 01:21 PM, John Payne wrote:
> Thank you both very much for your help; that was the problem. Stupid of me
> (the answer came to me in the shower this morning as well). If anyone out
> there in the developer community is listening, may I respectfully suggest that
> PSQL’s behavior --- to return nothing when Enter is hit – is pathological. It
> would be so simple to return a message like ”Waiting for the end of the
> statement…” and it would save novices like me a lot of very unhappy hours.

Terrible idea.  Then you'd be peppered with stupid messages while you're
composing a statement.  It doesn't make sense to alter the system for one user
who refuses to learn it correctly.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedia/commons/c/cf/Friz.jpg