Re: psql misbehaves because of a simple typo

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Peter Eisentraut <peter_e(at)gmx(dot)net>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Serguei Mokhov <sa_mokho(at)alcor(dot)concordia(dot)ca>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql misbehaves because of a simple typo
Date: 2001-12-28 19:33:00
Message-ID: 200112281933.fBSJX0T05480@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> Bruce Momjian writes:
>
> > OK, here is a patch for 7.3. It clears the paren counter only when the
> > buffer is cleared. Forget what I said about recomputing quotes. You
> > can't use backslash commands while you are in quotes.
>
> I don't think this works when the command is \g because you're testing for
> the cleared buffer too early. Look at what happens under "if
> (slashCmdStatus == CMD_SEND)". The test should be after that (around line
> 489 in original copy).

Are you sure?

test=> (select
test(> \g
ERROR: parser: parse error at or near ""
test(>

I now see the next \p kills me:

test(> \p
( select
test=>

Oops, line 489 doesn't work either:

test=> (select
test(> \g
ERROR: parser: parse error at or near ""
test=>

I now remember how confusing the previous_buffer handling is. It is
this line that is tricky:

/* handle backslash command */
slashCmdStatus = HandleSlashCmds(&line[i],
query_buf->len > 0 ? query_buf : previous_buf,
^^^^^^^^^^^^^^^^^^^^^^^^
&end_of_cmd);
It works now:

test=> (select
test(> \g
ERROR: parser: parse error at or near ""
test(> \p
(select

Patch attached.

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

Attachment Content-Type Size
unknown_filename text/plain 1.4 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2001-12-28 19:43:46 Re: Undocumented feature costs a lot of performance in COPY
Previous Message Tom Lane 2001-12-28 18:54:05 Re: [GENERAL] Problem (bug?) with like