Re: [PATCHES] dollar quoting

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [PATCHES] dollar quoting
Date: 2004-02-16 16:15:50
Message-ID: 4030ECB6.1000505@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

Bruce Momjian wrote:

>Tom Lane wrote:
>
>
>>Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>>
>>
>>>>No, it won't. The problem is that it should, because the backend will
>>>>see that as '42' followed by a $foo$ quote start.
>>>>
>>>>
>>>Ok, I see what you are saying. This mismatch would only happen on
>>>invalid input, though. I believe that what I did will work on all legal
>>>input.
>>>
>>>
>>I'm unconvinced. Even if there are not any current syntaxes in which a
>>numeric literal can be adjacent to a string literal (I'm not totally
>>sure about that), what of the future? We should solve the problem
>>rather than assuming it won't bite us.
>>
>>
>>
>>>I think that this might be cured by having psql recognise a legal
>>>identifier or keyword and eating it as a word, rather than treating it
>>>as just another set of bytes in the stream.
>>>
>>>
>>Hm, might work ... will think about it ...
>>
>>
>
>I am a little concerned about adding the overhead of lex to psql. Right
>now, some folks have reported that lex/yacc take a considerable amount
>of processing time in the backend as part of a query, and adding that to
>psql just to do $$ seems questionable. Of course, we can alway test and
>see what the overhead shows.
>
>
>

I think Tom's point is that the custom lexical recognition done by psql
is approaching the point of being unmaintainable, and if we have to bite
the bullet then maybe we might as well do so now.

I'd be surprised if using a flex lexer instead made a huge speed
difference, but maybe I'm wrong. I'm more concerned that it will be
difficult to write and maintain and keep in sync with the backend's
lexical structure - but those are just gut feelings, and I could be way
off base. Right now psql does just enough recognition to enable it to
work. Making it recognise the whole sql lexical structure instead
strikes me as being somewhat redundant - that's what the backend does.
Maybe we could do a flex lexer somewhat along the lines of the
minimalist approach that psql currently employs.

Anyway - I did put forward a possible non-flex way to handle the problem
Tom saw with $$ quoting - let's see what his verdict is on that first
;-) If he thinks it won't work, I can't see much alternative to using a
flex-based lexer.

cheers

andrew

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2004-02-16 16:16:16 Re: No Timeout in SELECT..FOR UPDATE
Previous Message Tom Lane 2004-02-16 16:07:46 Re: [HACKERS] dollar quoting

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2004-02-16 18:18:30 Re: [PATCHES] dollar quoting
Previous Message Tom Lane 2004-02-16 16:07:46 Re: [HACKERS] dollar quoting