pltcl: missing close-brace

Jonathan Ellis <jellis@advocast.com>

From: "Jonathan Ellis" <jellis@advocast.com>
To: <pgsql-general@postgresql.org>
Date: 2000-12-01T00:50:47Z
Lists: pgsql-general, pgsql-sql
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.)

The PL/TCL results:

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';

bf2'# bf2'# bf2'# bf2'# bf2'# CREATE

bf2=# select replace2('a b', ' ', 'c');
ERROR:  pltcl: missing close-brace

The plain tcl results:

#!/usr/bin/tcl

proc replace { 1 2 3 } {
    regsub -all {&} "$3" {\\\&} 3
    regsub -all {\\[0-9]} "$3" {\\\0} 3
    eval "regsub -all \{$2\} \{$1\} \{$3\} rval"
    return $rval
}

puts [replace "a b" " " "c"]

$ ./test.tcl
acb

Any idea what this error message means?

-Jonathan