Skip site navigation (1) Skip section navigation (2)

Re: BUG #1592: "with hold" cursor problem

From: Andrew - Supernews <andrew+nonews(at)supernews(dot)com>
To: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1592: "with hold" cursor problem
Date: 2005-04-11 15:10:12
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-bugs
On 2005-04-10, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> "Gabor Berenyi" <ber_(at)freemail(dot)hu> writes:
>> begin; 
>> declare t cursor with hold for select function() as x from R; 
>> commit;
>> Documentation says that the rows represented by a held cursor are copied
>> into a temporary file or memory area, but they are not, if they are results
>> of a function call. Instead, "commit" aborts the connection.
> Works for me.  Could we see a complete, self-contained example?
> In particular I suppose that the details of function() might be
> relevant.

Someone mentioned this on IRC; I was going to post an analysis but I got
sidetracked with other stuff. The critical detail is that function()
has to be an SQL function declared stable (or possibly immutable, not
sure) and it must invoke a volatile function such as timeofday(). The
crash happens in CopySnapshot trying to copy a null snapshot.

Obviously the function definition is in itself illegal, so the workaround
is "don't do that", but the backend should probably do something more
useful than segfaulting.

Complete example:

test=# create function crashme() returns text as 'select timeofday()'
test-#   language sql stable;
test=# begin;
test=# declare t cursor with hold for select crashme() as x from pg_class;
test=# commit;
server closed the connection unexpectedly

Andrew, Supernews - individual and corporate NNTP services

In response to


pgsql-bugs by date

Next:From: Michael FuhrDate: 2005-04-11 15:29:06
Subject: Re: BUG #1547: CREATE TYPE AS error
Previous:From: Tom LaneDate: 2005-04-11 14:54:43
Subject: Re: BUG #1547: CREATE TYPE AS error

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group