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

Re: [HACKERS] dollar quoting

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>,"Patches (PostgreSQL)" <pgsql-patches(at)postgresql(dot)org>
Subject: Re: [HACKERS] dollar quoting
Date: 2004-02-08 20:14:11
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackerspgsql-patches

Andrew Dunstan wrote:

> Tom Lane wrote:
>> Andrew Dunstan <andrew(at)dunslane(dot)net> writes:
>>> After staring at the code for a long time, I think I see how to do 
>>> this. It's complicated a bit by the fact that $ is a valid 
>>> identifier character. So my current thinking is to say that if we 
>>> see $ not in a quote and not preceded by a valid identifier char 
>>> then it is the start of a $foo$ sequence. Or have I missed 
>>> something? Can we validly see $ in any other context?

I had missed one, though - numbered params in prepared statements. Fixed 
in attached patch.

>> Right, a $ should be considered to start a quote marker only if it's not
>> part of an identifier.  The backend lexer doesn't have a problem with
>> this because it's written in flex, but I can imagine that getting it
>> right in psql's ad-hoc parser might be tricky.
> I think it's doable, though.  I seem to have a working patch, which I 
> will send out for review soon.

Proof of Concept patch (i.e. not for application) attached for review. 
The scanner changes are based on Tom's original, with some name/comment 
changes and a more liberal pattern. The psql changes are all my own work 

Comments welcome. Reviewers: I am not sure I got multi-byte stuff right 
in psql/mainloop.c - please pay close attention to that.

If I'm not wildly off course I will polish this up and start on docs.



Attachment: dq-amd.patch
Description: text/plain (8.0 KB)

In response to


pgsql-hackers by date

Next:From: Kevin BrownDate: 2004-02-08 21:54:51
Subject: Re: [pgsql-hackers-win32] Sync vs. fsync during checkpoint
Previous:From: Thomas HallgrenDate: 2004-02-08 19:56:24
Subject: Re: session persistent data for plperl

pgsql-patches by date

Next:From: Magnus HaganderDate: 2004-02-08 21:24:25
Subject: Updated win32 readdir patch
Previous:From: David GaramondDate: 2004-02-08 18:30:44
Subject: Re: connectby for BYTEA keys

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