Re: psql: backslash fix - Mailing list pgsql-patches

From Bruce Momjian
Subject Re: psql: backslash fix
Date
Msg-id 200203112244.g2BMiQn23931@candle.pha.pa.us
Whole thread Raw
In response to psql: backslash fix  (nconway@klamath.dyndns.org (Neil Conway))
Responses Re: psql: backslash fix
List pgsql-patches
Is this change required:


                        &end_of_cmd);

!                               success = slashCmdStatus != CMD_ERROR;

                                if ((slashCmdStatus == CMD_SEND || slashCmdStatus == CMD_NEWEDIT) &&
                                        query_buf->len == 0)
--- 467,473 ----
                                                   query_buf->len > 0 ? query_buf : previous_buf,

                        &end_of_cmd);

!                               success = (slashCmdStatus != CMD_ERROR);


I thought != was done before =, and my associativity chart shows that:

    Operator                        Associativity
    -----------------------------------------------
    () [] -> .                      left to right
    ! ~ ++ -- - (type) * & sizeof   right to left
    * / %                           left to right
    + -                             left to right
    << >>                           left to right
    < <= > >=                       left to right
    == !=                           left to right
    &                               left to right
    ^                               left to right
    |                               left to right
    &&                              left to right
    ||                              left to right
    ?:                              right to left
    = += -= etc.                    right to left
    ,                               left to right


---------------------------------------------------------------------------

Neil Conway wrote:
> Hi all,
>
> Recently, I reported on -hackers a strange case where psql wouldn't
> reset it's query buffer properly on a malformed backslash command, which
> would mean that the next query wouldn't be parsed properly. For
> instance:
>
> nconway=> select foo\\bar;
> Invalid command \. Try \? for help.
> nconway-> select 1;
> ERROR:  parser: parse error at or near "select"
>
> I've attached a patch which fixes this. I'm not sure if it is the
> "right" way to fix it, but it resolves the situation discribed above, at
> least. The new behavior is:
>
> nconway=> select foo\\bar;
> Invalid command \. Try \? for help.
> ERROR:  Attribute 'foo' not found
> nconway=> select 1;
>  ?column?
>  ----------
>          1
> (1 row)
>
> Unless anyone sees any problems, please apply.
>
> Cheers,
>
> Neil
>
> --
> Neil Conway <neilconway@rogers.com>
> PGP Key ID: DB3C29FC

[ Attachment, skipping... ]

>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
>     (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)

--
  Bruce Momjian                        |  http://candle.pha.pa.us
  pgman@candle.pha.pa.us               |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

pgsql-patches by date:

Previous
From: Paul Eggert
Date:
Subject: Re: support for POSIX 1003.1-2001 hosts
Next
From: Neil Conway
Date:
Subject: Re: psql: backslash fix