Re: syntax

From: "Kevin O'Gorman" <kogorman(at)pacbell(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PGSQL Hackers List <pgsql-hackers(at)hub(dot)org>
Subject: Re: syntax
Date: 2000-10-28 18:48:14
Message-ID: 39FB1F6E.1D12A269@pacbell.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
>
> > One thing I noticed that may surprise: the "%left UNION" and such that
> > appear in the source don't seem to do anything. I think our syntax
> > doesn't look like operators to yacc, and I suspect it's the opt_all
> > that's doing it. That part of yacc I don't understand.
>
> Hmm, that should work. My reading of the bison manual is that the
> precedence of a production is taken from the rightmost terminal symbol
> in the production, so
>
> | select_clause UNION opt_all select_clause
> | select_clause INTERSECT opt_all select_clause
> | select_clause EXCEPT opt_all select_clause
>
> should have the correct relative precedences.
>
> Don't you get shift/reduce errors if you remove those precedence specs?
> I'd expect the <select_clause> grammar to be ambiguous without operator
> precedence specs ...
>
> regards, tom lane

Yah. I would have thought so too. However, when I comment out the
two %left lines (being careful not to dusturb line numbers) I get the
absolutely identical gram.c output. So at least for those two things
the associativity does nothing at all. I'm inclined to leave them commented
out, so they don't mislead.

Of course, I was pretty sure the syntax there was unambiguous in any
case, so I'm not surprised there's no error; come to think of it, maybe
that's why %left has no effect. There has to be something going on,
because if I comment out the next line (the one with JOIN in it),
I suddenly get 32 shift/reduce errors.

This brings up another point. I'm still very new at reading the
SQL92 spec, so I need help being sure I've got it right. If we're going
to want precedence for these operators, I can do it in the syntax, and
it's only a little work. I don't see precedence in SQL92; set operations
seem to be left associative of equal priority. Be careful what you
ask for, you'll likely get it.

And appropos of another comment you made, when we decide how it's going
to be, we should have a bunch more things put in the regression tests,
not just UNIONs, to make sure it doesn't change unnoticed.

++ kevin

--
Kevin O'Gorman (805) 650-6274 mailto:kogorman(at)pacbell(dot)net
Permanent e-mail forwarder: mailto:Kevin.O'Gorman(dot)64(at)Alum(dot)Dartmouth(dot)org
At school: mailto:kogorman(at)cs(dot)ucsb(dot)edu
Web: http://www.cs.ucsb.edu/~kogorman/index.html
Web: http://trixie.kosman.via.ayuda.com/~kevin/index.html

"There is a freedom lying beyond circumstance,
derived from the direct intuition that life can
be grounded upon its absorption in what is
changeless amid change"
-- Alfred North Whitehead

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Kevin O'Gorman 2000-10-28 19:12:00 Re: Gram.y patches for better parenthesis handling.
Previous Message Vadim Mikheev 2000-10-28 18:40:19 Re: Proposal for DROP TABLE rollback mechanism