Re: Convert pltcl from strings to objects

From: Jim Nasby <Jim(dot)Nasby(at)BlueTreble(dot)com>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Victor Wagner <vitus(at)wagner(dot)pp(dot)ru>, <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Convert pltcl from strings to objects
Date: 2016-02-27 20:08:24
Message-ID: 56D20238.1060909@BlueTreble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2/25/16 9:30 AM, Alvaro Herrera wrote:
> Jim Nasby wrote:
>
>>> Here we have another case. prodesc is a global thing. And it is shared
>>> between different operations. Problem was that there is no partcular
>>> owner, and we have to wait when last operation which deals with it
>>> would finish. It looks like perfect job for reference counting.
>>
>> I've just tried to wrap my head around what's going on with prodesc and
>> failed... specifically, I don't understand this claim in the comment:
>>
>> * Add the proc description block to the hashtable. Note we do not
>> * attempt to free any previously existing prodesc block. !!This is
>> * annoying, but necessary since there could be active calls using
>> * the old prodesc.!!
>>
>> What else could be referencing it? I realize it's stored in pltcl_proc_htab,
>> but AFAICT that's backend-local. So I don't understand what else could be
>> referencing it.
>
> Try to open a cursor that uses the function, fetch a few tuples from it;
> then change the function and fetch more rows from the cursor. I suppose
> the open cursor could contain a reference to the function's prodesc.
>
> Refcounting the prodesc would let it live until the cursor's closed,
> then free it.

Hadn't thought about cursors; I suspect you're right about that. I
wounder if other PLs would handle that correctly.

I'm also not sure how the reference would get decremented... via
ResourceOwner somehow?
--
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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jim Nasby 2016-02-27 20:13:48 Re: Sanity checking for ./configure options?
Previous Message Chapman Flack 2016-02-27 19:50:49 Re: PostgreSQL extension API? Documentation?