Re: pltcl broken on tcl8.5 ?

From: Andrew Dunstan <andrew(at)dunslane(dot)net>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pltcl broken on tcl8.5 ?
Date: 2008-06-17 11:43:37
Message-ID: 4857A369.8050700@dunslane.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew(at)dunslane(dot)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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff 2008-06-17 12:18:54 Re: Reducing overhead for repeat de-TOASTing
Previous Message David E. Wheeler 2008-06-17 03:04:59 Re: Question about Encoding a Custom Type