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

Re: Dollar quoting docs, round 1

From: David Fetter <david(at)fetter(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Peter Eisentraut <peter_e(at)gmx(dot)net>,PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org>
Subject: Re: Dollar quoting docs, round 1
Date: 2004-04-28 16:53:56
Message-ID: 20040428165356.GK6848@fetter.org (view raw or flat)
Thread:
Lists: pgsql-patches
On Wed, Apr 28, 2004 at 12:30:06PM -0400, Bruce Momjian wrote:
> Peter Eisentraut wrote:
> > David Fetter wrote:
> > > Kind people,
> > >
> > > Please find attached a diff to the SGML docs that attempts to go over
> > > the new dollar quoting feature.
> > 
> > I think we should just use $$ in each case.  Otherwise it might look 
> > more complicated than before.
> 
> Agreed.  I was worried about dollar arguments in functions, e.g. $1:
> 	
> 	test=> select $$$1$$;
> 	 ?column?
> 	----------
> 	 $1
> 	(1 row)
> 
> but that seems to be OK.  Is our only problem actual $$ in a
> function body?

This is a design feature, as I understand it.

> And there is no way of escaping that, right?

Right.

> They have to choose a different quote characters sequence.

Yes.  Here is a short, but (IMHO) useful example.  Incidentally, I
have not yet found a way to get it working in versions prior to CVS
HEAD.

CREATE OR REPLACE FUNCTION has_bad_chars(TEXT) RETURNS BOOLEAN AS
$function$
BEGIN
    RETURN ($1 ~ $q$[\t\r\n\v|\\]$q$);
END;
$function$ LANGUAGE plpgsql;

Cheers,
D
-- 
David Fetter david(at)fetter(dot)org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

In response to

pgsql-patches by date

Next:From: Andrew DunstanDate: 2004-04-28 17:04:27
Subject: Re: Dollar quoting docs, round 1
Previous:From: Andrew DunstanDate: 2004-04-28 16:52:34
Subject: Re: Dollar quoting docs, round 1

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