Re: pltcl: missing close-brace - Mailing list pgsql-general

From Tom Lane
Subject Re: pltcl: missing close-brace
Date
Msg-id 415.975645978@sss.pgh.pa.us
Whole thread Raw
In response to pltcl: missing close-brace  ("Jonathan Ellis" <jellis@advocast.com>)
List pgsql-general
"Jonathan Ellis" <jellis@advocast.com> writes:
> I have a pl/tcl function that doesn't work, but the same function in a
> plain-vanilla tcl script does.  (The function emulates Oracle's "replace"
> function.)

> bf2=# create function replace2 (varchar, varchar, varchar) returns varchar
> as '
>     regsub -all {&} "$3" {\\\&} 3
>     regsub -all {\\[0-9]} "$3" {\\\0} 3
>     eval "regsub -all \{$2\} \{$1\} \{$3\} rval"
>     return $rval
> ' language 'pltcl';

Those backslashes all need to be protected by backslashes ...
the SQL parser will strip off one level of backslashing as it parses
the command.

            regards, tom lane

pgsql-general by date:

Previous
From: Bernie Huang
Date:
Subject: a script that queries database periodically
Next
From: GH
Date:
Subject: Re: Reading privileges