FAQ
I'm running psql version 8.1.11 on a Linux server from the command line. It
gives me absolutely no feedback from SQL commands and all SQL commands fail,
but the internal psql commands such as /d or /echo all work. I am not
running it in silent mode; the command I use to start it is just the
standard "psql -d database -U user". It tells me that I'm connected, I can
examine the tables, but it won't execute SQL.



Has anyone had similar issues?



Thanks,



John

Search Discussions

  • Tom Lane at Apr 28, 2011 at 1:29 pm

    "John Payne" <drjohnpayne@gmail.com> writes:
    I'm running psql version 8.1.11 on a Linux server from the command line. It
    gives me absolutely no feedback from SQL commands and all SQL commands fail,
    but the internal psql commands such as /d or /echo all work. I am not
    running it in silent mode; the command I use to start it is just the
    standard "psql -d database -U user". It tells me that I'm connected, I can
    examine the tables, but it won't execute SQL.
    It would be easier to tell what was going on if you showed us a concrete
    example (ie cut and paste from your terminal window) ... but I'm going
    to take a stab in the dark and guess that maybe you're forgetting to
    terminate your SQL commands with semicolons?

    regards, tom lane
  • Lew at Apr 28, 2011 at 2:08 pm

    Tom Lane wrote:
    "John Payne"<drjohnpayne@gmail.com> writes:
    I'm running psql version 8.1.11 on a Linux server from the command line. It
    gives me absolutely no feedback from SQL commands and all SQL commands fail,
    but the internal psql commands such as /d or /echo all work. I am not
    running it in silent mode; the command I use to start it is just the
    standard "psql -d database -U user". It tells me that I'm connected, I can
    examine the tables, but it won't execute SQL.
    It would be easier to tell what was going on if you showed us a concrete
    example (ie cut and paste from your terminal window) ... but I'm going
    to take a stab in the dark and guess that maybe you're forgetting to
    terminate your SQL commands with semicolons?
    That's my first guess, too. But OP, your problem description is rather
    imprecise. Tom's suggestion to use copy-and-paste to give details is an
    excellent one if you find out that semicolons (a normal part of any SQL
    command) don't fix your issue.

    Let's look at the manual where it first introduces SQL syntax:
    <http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html>

    "4.1. Lexical Structure

    "SQL input consists of a sequence of commands. A command is composed of a
    sequence of tokens, terminated by a semicolon (";")."
  • John Payne at Apr 28, 2011 at 5:28 pm
    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
  • Leif Biberg Kristensen at Apr 28, 2011 at 5:40 pm

    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.
  • Robert Poor at Apr 28, 2011 at 5:51 pm

    On Thu, Apr 28, 2011 at 10:40, Leif Biberg Kristensen wrote:
    Your suggestion is, frankly said, ridiculous.
    Gosh, Leif, where's the love? We were all novices once upon a time.
  • Leif Biberg Kristensen at Apr 28, 2011 at 6:03 pm

    On Thursday 28 April 2011 19:50:59 Robert Poor wrote:
    On Thu, Apr 28, 2011 at 10:40, Leif Biberg Kristensen

    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
  • Tom Lane at Apr 28, 2011 at 6:30 pm

    Robert Poor writes:
    On Thu, Apr 28, 2011 at 10:40, Leif Biberg Kristensen
    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
  • Leif Biberg Kristensen at Apr 28, 2011 at 6:41 pm

    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

    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.
  • Robert Poor at Apr 28, 2011 at 7:23 pm
    @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
  • Michael Swierczek at Apr 28, 2011 at 6:04 pm

    On Thu, Apr 28, 2011 at 1: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.
    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
  • Lew at Apr 28, 2011 at 8:38 pm

    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.
  • John Payne at Apr 28, 2011 at 7:50 pm
    In my own defense: The function of any user interface should be to help the
    user perform a task. In this case, the user interface is clearly not
    helpful. I maintain that to some degree "the customer is always right".
    The change from -> to => was so subtle that I didn't notice it. I'm sure
    that a very close reading of the documentation would have eventually solved
    my problem, but the syntax is really not obvious here. It took me a while
    to realize that there are two kinds of commands: internal commands and SQL
    commands - the documentation helped me there. But then the fact that
    internal commands must start with a backslash and end without a semicolon,
    whereas SQL commands must start without a backslash and end with a semicolon
    was not immediately clear. No matter how stupid Leif or others may think I
    am, I guarantee you that there will be other people in my shoes in the
    future. Any really great user interface makes it possible for the user to
    figure out how to get the behavior he or she wants, *without* reading the
    manual.



    Again, I do thank you all for your help.



    John



    John Payne
    POST Staff Scientist and US Coordinator
    www.postcoml.org

    Tel. (206) 463-3404
  • Leif Biberg Kristensen at Apr 28, 2011 at 8:23 pm

    On Thursday 28 April 2011 21:28:12 John Payne wrote:
    In my own defense: The function of any user interface should be to help the
    user perform a task. In this case, the user interface is clearly not
    helpful. I maintain that to some degree "the customer is always right".
    The change from -> to => was so subtle that I didn't notice it. I'm sure
    that a very close reading of the documentation would have eventually solved
    my problem, but the syntax is really not obvious here. It took me a while
    to realize that there are two kinds of commands: internal commands and SQL
    commands - the documentation helped me there. But then the fact that
    internal commands must start with a backslash and end without a semicolon,
    whereas SQL commands must start without a backslash and end with a
    semicolon was not immediately clear. No matter how stupid Leif or others
    may think I am, I guarantee you that there will be other people in my
    shoes in the future. Any really great user interface makes it possible
    for the user to figure out how to get the behavior he or she wants,
    *without* reading the manual.
    psql is an incredibly powerful tool, but like most command line utilities of
    the Unix tradition, the interface *will* appear terse to a novice. We've all
    been there, and have invariably been told to RTFM. Calling that tradition
    "pathological" is not a good way to make friends ;)

    Yes, the change from => to -> is subtle. That's the way most of us prefer it,
    once we're past the initial learning curve. In addition, the prompt may change
    to (> whenever you have an open parenthesis carry over to the next line. I find
    that very helpful.

    Ending an SQL query with a semicolon is per the SQL standard, and the reason
    is quite obvious; it would be very hard to enter multiline queries unless you
    have an unequivocal way of telling the parser that you're finished. It will
    soon become second nature as you grow aquainted with psql.

    regards, Leif.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedApr 28, '11 at 3:03a
activeApr 28, '11 at 8:38p
posts14
users7
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2021 Grokbase