Re: syntax - Mailing list pgsql-hackers
From | Kevin O'Gorman |
---|---|
Subject | Re: syntax |
Date | |
Msg-id | 39FB1F6E.1D12A269@pacbell.net Whole thread Raw |
In response to | Re: [GENERAL] A rare error ("Kevin O'Gorman" <kogorman@pacbell.net>) |
Responses |
Re: syntax
|
List | 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@pacbell.net Permanent e-mail forwarder: mailto:Kevin.O'Gorman.64@Alum.Dartmouth.org At school: mailto:kogorman@cs.ucsb.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
pgsql-hackers by date: