Skip site navigation (1) Skip section navigation (2)

Re: [HACKERS] dollar quoting

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>,"Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] dollar quoting
Date: 2004-02-14 16:54:09
Message-ID: 11715.1076777649@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackerspgsql-patches
Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
> I ended up not using a regex, which seemed to be a little heavy handed, 
> but just writing a small custom recognition function, that should (and I 
> think does) mimic the pattern recognition for these tokens used by the 
> backend lexer.

I looked at this and realized that it still doesn't do very well at
distinguishing $foo$ from other random uses of $.  The problem is that
looking back at just the immediately preceding character isn't enough
context to tell whether a $ is part of an identifier.  Consider the
input
	a42$foo$
This is a legal identifier according to PG 7.4.  But how about
	42$foo$
This is a syntax error in 7.4, and we propose to redefine it as an
integer literal '42' followed by a dollar-quote start symbol.

There's no way to tell these apart with a single-character lookback,
or indeed any fixed number of characters of lookback.

I begin to think that we'll really have to bite the bullet and convert
psql's input parser to use flex.  If we're not scanning with exactly the
same rules as the backend uses, we're going to get the wrong answers.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Tom LaneDate: 2004-02-14 17:00:48
Subject: Re: Persistent main memory Storage Manager
Previous:From: Tom LaneDate: 2004-02-14 16:10:08
Subject: Re: pg_restore problems and suggested resolution

pgsql-patches by date

Next:From: Andrew DunstanDate: 2004-02-14 20:04:31
Subject: Re: [HACKERS] dollar quoting
Previous:From: Nick BarrDate: 2004-02-14 11:57:45
Subject: Re: TODO : Multiple inserts in a single statement

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group