Re: [Fwd: [PORTS] Port Bug Report: parse error not detected on unterminated quote]

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: Postgres Porting List <ports(at)postgresql(dot)org>, Bruce Momjian <maillist(at)candle(dot)pha(dot)pa(dot)us>
Subject: Re: [Fwd: [PORTS] Port Bug Report: parse error not detected on unterminated quote]
Date: 1999-11-29 22:43:10
Message-ID: 199911292243.RAA16001@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-ports


Seems this bug still exists.

> (back on list)
>
> Bruce, the problem is revealed with the "single-line input" mode of
> psql. I'm a bit suprised that the backend parser doesn't catch this,
> but I see why now: scan.l goes into a "string accumulate" mode when it
> sees a single quote, and doesn't actually send a token back to gram.y
> until it sees the closing quote. If EOT comes first, then there is no
> flag to tell gram.y (or whatever is the right thing) that there is
> still an active token being worked on.
>
> Not certain yet how to fix this; the "string accumulator" is currently
> local to scan.l and I'm not sure if scan.l can provide code to check
> this after it runs out of characters to process. I do have a lex/yacc
> book, but if anyone has some hints...
>
> - Thomas
>
> --
> Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
> South Pasadena, California

-- Start of included mail From: Kyle Bateman <kyle(at)actarg(dot)com>

> Sender: kyle(at)actarg(dot)com
> Date: Wed, 30 Jun 1999 08:38:10 -0600
> Organization: Action Target Inc
> X-Accept-Language: en
> To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
> Subject: Re: [PORTS] Port Bug Report: parse error not detected on unterminated
> quote
> X-Mozilla-Status2: 00000000

> Thomas Lockhart wrote:
>
> > > Problem Description:
> > > --------------------
> > > If a single quote is left unmatched in the query, the parser
> > > seems to throw away the rest of the line without detecting
> > > an error.
> > > Test Case:
> > > ----------
> > > Enter a select like this:
> > > select * from mytable where id = 1234;
> > > You should get only one record.
> > >
> > > Now put in an errant single quote:
> > > select * from mytable' where id = 1234;
> > > Now you get the whole table. This should really be a
> > > syntax error of some kind.
> >
> > And seems to be:
> >
> > postgres=> select * from mytable' where id = 1234;
> > postgres'> '
> > postgres-> ;
> > ERROR: parser: parse error at or near "'"
> > postgres=>
> >
> > This is on a RH5.2 system with with the cvs distribution of Postgres
> > (rather than v6.5 exactly). But the parsing behavior should be the
> > same. I'm not sure what could be different in our installations...
> >
> > - Thomas
> >
> > --
> > Thomas Lockhart lockhart(at)alumni(dot)caltech(dot)edu
> > South Pasadena, California
>
> Yup, it seems to be OK in psql interactive mode. The problem only shows
> up if I type:
>
> psql mydb -c "select * from mytable' where id = 1234;"
>
> --
> ----------------------------------------------------
> Kyle Bateman President, Action Target Inc.
> "Viva Yo!" kyle(at)actarg(dot)com (801)377-8033x101
> ----------------------------------------------------
>
>
-- End of included mail.

--
Bruce Momjian | http://www.op.net/~candle
maillist(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

Browse pgsql-ports by date

  From Date Subject
Next Message Bruce Momjian 1999-11-29 22:46:02 Re: [PORTS] Re: [HACKERS] RedHat6.0 & Alpha
Previous Message Joe Brenner 1999-11-28 02:07:49 libpq.so.1 is needed by perl-DBD-Pg-0.91-1