Re: Increase pltcl test coverage

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>, Karl Lehenbauer <karl(at)flightaware(dot)com>
Subject: Re: Increase pltcl test coverage
Date: 2017-01-09 23:05:48
Message-ID: 8b774ba6-8690-e0ec-fa8b-12f3f6f6165d@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 1/9/17 4:23 PM, Tom Lane wrote:
> Jim Nasby <Jim(dot)Nasby(at)bluetreble(dot)com> writes:
>> Got a stack trace. The abort happens in TclObjLookupVar:
>
> Yeah, I found the problem: pltcl_returnnext calls pltcl_build_tuple_result
> which may throw elog(ERROR), leaving the Tcl interpreter's state all
> screwed up, so that later functions go south. It seems quite accidental
> that this is only failing with 8.4. We need pltcl_returnnext to use a
> subtransction, like the other pltcl statements that can call into generic
> PG code. Working on a fix now.

Hmm... I suspect there's more places where this could be a problem. For
example, pltcl_quote calls palloc, which could ereport as well.

Perhaps all of the internal commands should be wrapped in the
pltcl_subtrans_begin() construct. The subtrans overhead would be
unfortunate though. But AFAIK the only reason we need the subtrans is if
we're underneath a TCL catch command, and there's probably a way to
determine if that's the case.

BTW, now that I've seen this pattern in pltcl and plpythonu, I'm
wondering if there might be some easier way to handle it through our
error callbacks.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com
855-TREBLE2 (855-873-2532)

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Merlin Moncure 2017-01-09 23:12:54 Re: merging some features from plpgsql2 project
Previous Message David Fetter 2017-01-09 22:54:05 Re: PoC: Make it possible to disallow WHERE-less UPDATE and DELETE