From: "Molitor, Stephen L" Date: 2005-03-06T13:02:07+09:00 Subject: Re: plruby bug with postgres 8.0 composite types / ref count leak - FIX? ------_=_NextPart_001_01C52201.39BC1D0F Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable I *might* have a fix. Changing plruby.c lines 892 - 898 from this: if (typeStruct->typrelid !=3D InvalidOid) { prodesc->arg_is_rel[i] =3D 1; ReleaseSysCache(typeTup); } else { prodesc->arg_is_rel[i] =3D 0; }=20 to simply this: prodesc->arg_is_rel[i] =3D 0; makes the problem go away. (In other words, removing the !=3D = InvalidOid check.) =20 It seems that the problem isn't a catcache reference leak, but rather = releasing the same thing more than once. Of course, my 'fix' might just = be introducing a leak in other circumstances, although it does seem to = avoid the double release in my test case. I just started peaking at the = plruby c code today; haven't really grokked it yet. Anyway, maybe this = will help. To Guy Decoux (plruby author) -- thanks for a pretty slick module. I = just started playing with it, but this issue aside, it seems to = integrate pretty darn well with postgresql. Ruby and postgresql seem = like a good fit. Steve -----Original Message----- From: Molitor, Stephen L Sent: Sat 3/5/2005 9:13 PM To: ruby-talk ML Subject: Re: plruby bug with postgres 8.0 composite types / ref count = leak? =20 Sorry, minor typo. I copied and pasted from my psql session and forgot = to remove all the prompts. Without the prompts, running the following = (you can feed it in to psql from the command line) causes the error: create type t as ( name text ); create function f(t) returns integer as '42' language 'plruby'; select f(ROW('a name')); Steve -----Original Message----- From: Molitor, Stephen L Sent: Sat 3/5/2005 9:08 PM To: ruby-talk ML Subject: plruby bug with postgres 8.0 composite types / ref count leak? =20 I tried using the new postgres composite types features as described in = the new manual. With the following versions: plruby 0.4.3 postgresql 8.0.1 ruby 1.8.2 Mac OS X 10.3.8 (panther) when I run the following in psql: create type t as ( name text ); test=3D# create function f(t) returns integer as '42' language 'plruby'; select f(ROW('a name')); I get the following error: ERROR: catcache reference 0x430388 is not owned by resource owner = Portal However, if I use pl/sql, running this works fine: create function f2(t) returns integer as 'select 42' language sql; select f2(ROW('a name')); I get 42 back. =20 The error appears to be thrown on line 609 in the function = ResourceOwnerForgetCatCacheRef in resowner.c in the postgres 8.0.1 = sources. The only place that this method seems to get called is on line = 1293 in the function ReleaseCatCache in catcache.c. This is called = immediately after it decrements the ref count on the catcache. So = maybe there's some sort of reference count leak or something. I have trouble reproducing it, but using the old syntax with postgres = 7.4.7 I would sometimes get warnings about a catcache leak, the error = saying something about 'catcache ref count has reached -1'. So I'm = guessing the leak has always existing but fails hard with 8.0. Anyway, any help would be appreciated! Steve ------_=_NextPart_001_01C52201.39BC1D0F--