Thread: pltcl - cannot create 'normal' interpreter - Tcl_CreateSlave() fails - A solution

pltcl - cannot create 'normal' interpreter - Tcl_CreateSlave() fails - A solution

From
Patrick Samson
Date:
This proposed patch is related to:
http://archives.postgresql.org/pgsql-cygwin/2004-01/msg00024.php

Add a call to Tcl_FindExecutable() in
pltcl.c - pltcl_init_all(),
just before the call to Tcl_CreateInterp().

It should be called with argv[0] as argument, but I
don't know how to get this piece of information for
pltcl.dll. Anyway, for Windows, it is unused
(see win/tclWinFile.c - TclpFindExecutable()). Just a
value != NULL is OK, so I used an empty string.

[Jan Wieck, I'm only interested in cygwin platform.
I suggest you investigate deeper to make this
"workaround" cleaner, in order to be also compatible
with pure Unix platforms.]

Without this call, and with only the setting of the
TCL_LIBRARY environment variable, Tcl_CreateSlave()
seems to fail somewhere else, with this message:
--------------------------
server closed the connection unexpectedly
   This probably means the server terminated
abnormally
   before or while processing the request.
The connection to the server was lost.
 Attempting reset: Succeeded.
--------------------------
I didn't spend time on this issue, just added the
call.

My proposed patch generated with:
 $ diff -u pltcl.orig pltcl.c
is attached.

__________________________________
Do you Yahoo!?
Yahoo! Hotjobs: Enter the "Signing Bonus" Sweepstakes
http://hotjobs.sweepstakes.yahoo.com/signingbonus--- pltcl.orig  2003-10-30 03:00:44.000000000 +0100
+++ pltcl.c     2004-01-06 13:54:03.937500000 +0100
@@ -35,10 +35,13 @@
  *
  **********************************************************************/

-#include "postgres.h"
-
+//psa: change order of tcl.h and postgres.h
+// http://archives.postgresql.org/pgsql-cygwin/2003-01/msg00080.php
+// http://archives.postgresql.org/pgsql-cygwin/2003-11/msg00074.php
 #include <tcl.h>

+#include "postgres.h"
+
 #include <unistd.h>
 #include <fcntl.h>
 #include <setjmp.h>
@@ -207,6 +210,9 @@
         * Create the dummy hold interpreter to prevent close of
         * stdout and stderr on DeleteInterp
         ************************************************************/
+//psa: argument should be argv[0]. But anyway, it is unused on Windows: just have to be != NULL.
+Tcl_FindExecutable("");
+
        if ((pltcl_hold_interp = Tcl_CreateInterp()) == NULL)
        {
                elog(ERROR, "pltcl: internal error - cannot create 'hold' "
@@ -219,6 +225,8 @@
        if ((pltcl_norm_interp =
                 Tcl_CreateSlave(pltcl_hold_interp, "norm", 0)) == NULL)
        {
+//psa: tell me more about the fail
+elog(LOG,Tcl_GetStringResult(pltcl_hold_interp));
                elog(ERROR,
                   "pltcl: internal error - cannot create 'normal' interpreter");
        }
@@ -227,6 +235,8 @@
        if ((pltcl_safe_interp =
                 Tcl_CreateSlave(pltcl_hold_interp, "safe", 1)) == NULL)
        {
+//psa: tell me more about the fail
+elog(LOG,Tcl_GetStringResult(pltcl_hold_interp));
                elog(ERROR,
                         "pltcl: internal error - cannot create 'safe' interpreter");
        }

Re: pltcl - cannot create 'normal' interpreter - Tcl_CreateSlave() fails - A solution

From
Peter Eisentraut
Date:
Patrick Samson wrote:
> This proposed patch is related to:
> http://archives.postgresql.org/pgsql-cygwin/2004-01/msg00024.php

First of all, you cannot change the order of postgres.h and tcl.h --
period.

Secondly, no // comments, no "personal" comments, no mailing list
archive references.  Explain the issues in the code.


Patrick Samson <p_samson@yahoo.com> writes:
> Add a call to Tcl_FindExecutable() in
> pltcl.c - pltcl_init_all(),
> just before the call to Tcl_CreateInterp().

> It should be called with argv[0] as argument, but I
> don't know how to get this piece of information for
> pltcl.dll. Anyway, for Windows, it is unused
> (see win/tclWinFile.c - TclpFindExecutable()). Just a
> value != NULL is OK, so I used an empty string.

AFAICS this patch breaks all non-Windows platforms.  Sorry, that
won't do ...

            regards, tom lane