Re: [INTERFACES] Bug in parser?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu>
Cc: Axel at ansonic <goddyna(at)ansonic(dot)com(dot)au>, pgsql-interfaces(at)postgreSQL(dot)org, "Ross J(dot) Reedstrom" <reedstrm(at)wallace(dot)ece(dot)rice(dot)edu>, blackw(at)sfu(dot)ca
Subject: Re: [INTERFACES] Bug in parser?
Date: 2000-02-08 06:42:13
Message-ID: 405.949992133@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-interfaces

Thomas Lockhart <lockhart(at)alumni(dot)caltech(dot)edu> writes:
> Pretty sure that the SQL92 rules for the "string across lines" is more
> restrictive than just allowing spaces between double quotes; you
> actually need something close to a line break.
>
> select * from "T1" "A1";
>
> would do horrible things if I interpret your suggestion correctly.

No, because we're talking about string literals (single quotes) not
double-quoted names. Is there harm in interpreting
select 'a string' ' literal';
as
select 'a string literal';
? And if so, why does it suddenly become OK if I write it as
select 'a string'
' literal';

The SQL92 spec isn't particularly transparent about this, but if I am
looking at the right syntax items, we have

<character string literal> ::=
[ <introducer><character set specification> ]
<quote> [ <character representation>... ] <quote>
[ { <separator>... <quote> [ <character representation>... ] <quote> }... ]

<separator> ::= { <comment> | <space> | <newline> }...

which sure as heck looks like you can write either newline or just
plain space between 'a string' and ' literal' and get the same answer.

A couple other items:

* I see why xqdouble has to be separate from xqcat; the former
produces a single quote in the represented string, the latter doesn't.
So xqcat must at least be defined as
xqcat {quote}{space}{space}*{quote}
to allow it to be distinguished from xqdouble.

* I see that the spec allows comments between segments of a string
literal. This works in current code:

regression=# select 'a string' -- zzz
regression-# ' literal';
?column?
------------------
a string literal
(1 row)

but I'm durned if I see where that behavior is implemented.
Do you?

regards, tom lane

In response to

Responses

Browse pgsql-interfaces by date

  From Date Subject
Next Message Tim Kane 2000-02-08 07:06:39 character arrays and quotation
Previous Message Thomas Lockhart 2000-02-08 06:06:51 Re: [INTERFACES] Bug in parser?