Re: psql: backslash fix

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Neil Conway <nconway(at)klamath(dot)dyndns(dot)org>
Cc: pgsql-patches(at)postgresql(dot)org
Subject: Re: psql: backslash fix
Date: 2002-03-11 22:44:26
Message-ID: 200203112244.g2BMiQn23931@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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(at)rogers(dot)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(at)postgresql(dot)org)

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

In response to

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Neil Conway 2002-03-11 22:49:33 Re: psql: backslash fix
Previous Message Paul Eggert 2002-03-11 22:24:56 Re: support for POSIX 1003.1-2001 hosts