Re: factorial function/phase out postfix operators? - Mailing list pgsql-hackers
From | Robert Haas |
---|---|
Subject | Re: factorial function/phase out postfix operators? |
Date | |
Msg-id | CA+TgmobK9vVX8rDSzabnTwqu14D+=oDMQHBjLTfRVngVrASZAg@mail.gmail.com Whole thread Raw |
In response to | Re: factorial function/phase out postfix operators? (Tom Lane <tgl@sss.pgh.pa.us>) |
Responses |
Re: factorial function/phase out postfix operators?
|
List | pgsql-hackers |
On Tue, May 19, 2020 at 2:30 PM Tom Lane <tgl@sss.pgh.pa.us> wrote: > Might work. My main concern would be if we have to forbid those keywords > as column names --- for words like "year", in particular, that'd be a > disaster. If the net effect is only that they can't be AS-less col labels, > it won't break any cases that worked before. ISTM that all we have to do to avoid that is switch from a four-way classification to a five-way classification: just split unreserved_keyword into totally_unreserved_keyword and very_slightly_reserved_keyword. > Our existing four-way keyword classification is not something that was > handed down on stone tablets. I wonder whether postfix-ectomy changes > the situation enough that a complete rethinking would be helpful. I don't see that they do, but I might be missing something. I think there's an excellent argument for adding one new category, but it's not clear to me why it should reshape the landscape any more than that. > I also continue to think that more lookahead and token-merging would > be interesting to pursue. It'd hardly surprise anybody if the > token pair "character varying" were always treated as a type name, > for instance. I think that line of attack will not buy very much. The ability to avoid unexpected consequences is entirely contingent on the unlikeliness of the keywords appearing adjacent to each other in some other context, and the only argument for that here is that neither of those words is a terribly likely column name. I think that when you try to solve interesting problems with this, though, you very quickly run into problems where that's not the case, and you'll need a technique that has some knowledge of the parser state to actually do something that works well. I read a paper some years ago that proposed a solution to this problem: if the parser generator sees a shift/reduce conflict, it checks whether the conflict can be resolve by looking ahead one or more additional tokens. If so, it can build a little DFA that gets run when you enter that state, with edges labeled with lookahead tokens, and it runs that DFA whenever you reach the problematic state. Since, hopefully, such states are relatively rarely encountered, the overhead is low, yet it still gives you a way out of conflicts in many practical cases. Unfortunately, the chances of bison implementing such a thing do not seem very good. > Anyway, the bottom-line conclusion remains the same: let's make sure > we know what we'd do after getting rid of postfix ops, before we do > that. Well, I don't think we really need to get too conservative here. I've studied this issue enough over the years to be pretty darn sure that this is a necessary prerequisite to doing something about the "AS unreserved_keyword" issue, and that it is by far the most significant issue in doing something about that problem. Sure, there are other issues, but I think they are basically matters of politics or policy. For example, if some key people DID think that the four-way keyword classification was handed down on stone tablets, that could be quite a problem, but if we're willing to take the view that solving the "AS unreserved_keyword" problem is pretty important and we need to find a way to get it done, then I think we an do that. It seems to me that the first thing that we need to do here is get a deprecation notice out, so that people know that we're planning to break this. I think we should go ahead and make that happen now, or at least pretty soon. I'm still interested in hearing what people think about hard-coding ! as a postfix operator vs. removing postfix operators altogether. I think Vik and Tom are against keeping just !, Kenneth Marshall are for it, and I'm not sure I understand Pavel's position. I'm about +0.3 for keeping just ! myself. Maybe we'll get some other votes. If you're willing to be persuaded that keeping only ! is a sensible thing to consider, I could probably draft a very rough patch showing that it would still be sufficient to get us out from under the "AS unreserved_keyword" problem, but if you and/or enough other people hate that direction with a fiery passion, I won't bother. I'm pretty sure it's technically possible, but the issue is more about what people actually want. -- Robert Haas EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company
pgsql-hackers by date: