Re: massive quotes? - Mailing list pgsql-hackers
From | Bruce Momjian |
---|---|
Subject | Re: massive quotes? |
Date | |
Msg-id | 200309111640.h8BGelf16785@candle.pha.pa.us Whole thread Raw |
In response to | Re: massive quotes? (Andreas Pflug <pgadmin@pse-consulting.de>) |
Responses |
Re: massive quotes?
|
List | pgsql-hackers |
Andreas Pflug wrote: > Bruce Momjian wrote: > > >Tom Lane wrote: > > > > > >>The discussion so far today seems to be entirely a rehash of arguments > >>already made (and in many cases already rebutted). Rather than wasting > >>list bandwidth with this, I think each camp ought to go off and do their > >>homework. Give us *details* of how your solution would work. > >> > >> > > > >Another idea would be to enable another set of quoting characters, like: > > > > CREATE FUNCTION xx ... > > <-- > > x = 'fred'; > > ... > > --> > > > >and have the lexer understand those new quoting characters. We just use > >'' too much in function bodies to use that also for quoting the function > >text. Of course, '<--' would have no special meaning inside a quoted > >string, so we are only eliminating their use as custom operators, and I > >think that is reasonable. > > > >Having heard all the other proposals, I think this will be the clearest. > > > > > > > This looks quite similar to my proposal. I called it "function body is > enclosed in keywords", while Bruce will enclose it in new quote strings. > This is obviously very different for the lexer/parser, while identical > for the user. Sounds good to me. > The quoting strings seem a bit suspicious to me, I can imagine comments > like this "converting abc --> def", which would certainly break the > function definition (I scanned a part of my sources, I found two > occurrences of "-->", one of them in SQL code...) > > How about quoting strings that look like keywords, e.g. FUNCTIONBODY and > ENDFUNCTIONBODY? > > CREATE FUNCTION foo() RETURNS int4 AS > FUNCTIONBODY > DECLARE bar int4; > BEGIN > RETURN bar; > END; > ENDFUNCTIONBODY > LANGUAGE 'plpgsql'; Uh, the problem with long keywords is that you are then requiring the _parser_ to identify those keywords, and at that point, the entire text between the keywords has been sliced up by the lexer, which will certainly make it a mess. I might be wrong that we can even use more then two characters for the start of quote string because I don't think flex supports more than one character of look-ahead. Again, lookahead is the key because you have to flag that text as a quoted string before it gets processed by the lexer. I was picking <-- --> out of the air. We would have to choose other character sequences, and probably only two-character ones. However, looking at scan.l, it seems you could try putting a literal keyword in there. Of course, it would also match 'identifier' code, but if it is earlier, I think it gets matched first. -- Bruce Momjian | http://candle.pha.pa.us pgman@candle.pha.pa.us | (610) 359-1001+ If your life is a hard drive, | 13 Roberts Road + Christ can be your backup. | Newtown Square, Pennsylvania19073
pgsql-hackers by date: