From: | Andrew Dunstan <andrew(at)dunslane(dot)net> |
---|---|
To: | PostgreSQL Patches <pgsql-patches(at)postgresql(dot)org> |
Subject: | Re: Dollar quoting docs, round 1 |
Date: | 2004-04-28 17:04:27 |
Message-ID: | 408FE41B.1060503@dunslane.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
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? And there is no way of escaping that, right? They have to choose
>a different quote characters sequence.
>
>
>
The string inside $x$ is totally opaque and unescaped. The restriction
on markers is that the string mustn't contain $x$, and mustn't end with
$x, i.e., the scanners see $x$ and simply accumulate all the characters
in the string until they see $x$ again - all 3 scanners (postgres, psql,
plpgsql) work the same way on this.
Functions with arguments might need to be quoted with something other
than plain $$, and in any case if their bodies make use of $$ they
certainly will. pg_dump's approach to quoting function bodies is to
start with $$ and then generate longer and longer markers until the
marker without trailing $ is not found in the string comprising the
function body. In most cases it ends up using $_$.
I hope that makes things clearer.
cheers
andrew
From | Date | Subject | |
---|---|---|---|
Next Message | Sean Chittenden | 2004-04-28 21:46:58 | Re: SECURITY DEFINER not being propagated... |
Previous Message | David Fetter | 2004-04-28 16:53:56 | Re: Dollar quoting docs, round 1 |