pgsql: Apply Tcl_Init() to the "hold" interpreter created by pltcl.

From: tgl(at)postgresql(dot)org (Tom Lane)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Apply Tcl_Init() to the "hold" interpreter created by pltcl.
Date: 2010-01-25 01:58:14
Message-ID: 20100125015814.40B1A7541B9@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
Apply Tcl_Init() to the "hold" interpreter created by pltcl.

You might think this is unnecessary since that interpreter is never used
to run code --- but it turns out that's wrong. As of Tcl 8.5, the "clock"
command (alone among builtin Tcl commands) is partially implemented by
loaded-on-demand Tcl code, which means that it fails if there's not
unknown-command support, and also that it's impossible to run it directly
in a safe interpreter. The way they get around the latter is that
Tcl_CreateSlave() automatically sets up an alias command that forwards any
execution of "clock" in a safe slave interpreter to its parent interpreter.
Thus, when attempting to execute "clock" in trusted pltcl, the command
actually executes in the "hold" interpreter, where it will fail if
unknown-command support hasn't been introduced by sourcing the standard
init.tcl script, which is done by Tcl_Init(). (This is a pretty dubious
design decision on the Tcl boys' part, if you ask me ... but they didn't.)

Back-patch all the way. It's not clear that anyone would try to use ancient
versions of pltcl with a recent Tcl, but it's not clear they wouldn't, either.
Also add a regression test using "clock", in branches that have regression
test support for pltcl.

Per recent trouble report from Kyle Bateman.

Modified Files:
--------------
pgsql/src/pl/tcl:
pltcl.c (r1.129 -> r1.130)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/tcl/pltcl.c?r1=1.129&r2=1.130)
pgsql/src/pl/tcl/expected:
pltcl_setup.out (r1.7 -> r1.8)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/tcl/expected/pltcl_setup.out?r1=1.7&r2=1.8)
pgsql/src/pl/tcl/sql:
pltcl_setup.sql (r1.6 -> r1.7)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/pl/tcl/sql/pltcl_setup.sql?r1=1.6&r2=1.7)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2010-01-25 01:58:19 pgsql: Apply Tcl_Init() to the "hold" interpreter created by pltcl.
Previous Message Joe Conway 2010-01-24 22:19:38 pgsql: Rewrite dblink_record_internal() and dblink_fetch() to use a