Re: pltcl broken on tcl8.5 ? - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: pltcl broken on tcl8.5 ?
Date
Msg-id 4857A369.8050700@dunslane.net
Whole thread Raw
In response to Re: pltcl broken on tcl8.5 ?  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>   
>> Tom Lane wrote:
>>     
>>> Hoo, nasty.  Tcl_GetVar() is resetting interp->result.
>>>       
>
>   
>> According to the manual page that's only supposed to happen if the 
>> TCL_LEAVE_ERR_MSG flag is used:
>>     
>
>   
>> TCL_LEAVE_ERR_MSG
>> If an error is returned and this bit is set in flags, then an
>> error message will be left in the interpreter’s result, where it
>> can be retrieved with Tcl_GetObjResult or Tcl_GetStringResult.
>> If this flag bit isn’t set then no error message is left and the
>> interpreter’s result will not be modified.
>>     
>
> But notice that they specify using Tcl_GetObjResult or
> Tcl_GetStringResult, rather than touching the field directly.
> I suspect they'd regard this as not-a-bug.  In any case I found
> the responsible code: Tcl_SaveInterpState/Tcl_RestoreInterpState
> restore the result as an object not a string.  I see no such
> routines in 8.4.
>
> As I look at this, I think it's got even more problems: it's assuming
> that interp->result is in the database encoding, which seems a pretty
> faulty assumption considering it came from Tcl.  pltcl_elog converts
> to the database encoding before calling Tcl_SetResult, which makes
> that path all right as long as Tcl doesn't do anything with the string
> before exiting, but I don't particularly trust that assumption either.
> All in all this is really quite broken.
>
>             
>   

Yes. At any rate, your fix has worked on my test bed.

cheers

andrew


pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: Question about Encoding a Custom Type
Next
From: Robert Treat
Date:
Subject: Re: Crash in pgCrypto?