Re: Dollar quoting docs, round 1 - Mailing list pgsql-patches

From David Fetter
Subject Re: Dollar quoting docs, round 1
Date
Msg-id 20040428165356.GK6848@fetter.org
Whole thread Raw
In response to Re: Dollar quoting docs, round 1  (Bruce Momjian <pgman@candle.pha.pa.us>)
List 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@fetter.org http://fetter.org/
phone: +1 510 893 6100   mobile: +1 415 235 3778

Remember to vote!

pgsql-patches by date:

Previous
From: Andrew Dunstan
Date:
Subject: Re: Dollar quoting docs, round 1
Next
From: Andrew Dunstan
Date:
Subject: Re: Dollar quoting docs, round 1