Re: Server process crash - Segmentation fault

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Leif Jensen <leif(at)crysberg(dot)dk>
Cc: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>, pgsql-general <pgsql-general(at)postgresql(dot)org>, pgsql-bugs(at)postgresql(dot)org
Subject: Re: Server process crash - Segmentation fault
Date: 2014-05-07 17:39:43
Message-ID: 31796.1399484383@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-general

Leif Jensen <leif(at)crysberg(dot)dk> writes:
> Could it be related to the OFFSET part of the statement ? I have another query on the same table without OFFSET, which seems to work fine.

Yeah, the specific code path here involves executing a stable (or possibly
immutable) SQL function in a LIMIT or OFFSET clause. I was able to
reproduce the crash like so:

create function foo(int) returns int as 'select $1 limit 1'
language sql stable;

begin;

declare c cursor for select * from int8_tbl limit foo(3);

select * from c;

move backward all in c;

select * from c;

commit;

You might be able to dodge the problem if you can make the SQL function
inline-able (the LIMIT 1 in my example is just to prevent that from
happening). A less appealing alternative is to mark the function
VOLATILE, which I think would also prevent this crash, but might have
negative performance consequences.

If you don't mind building your own PG then you could grab the actual fix
from our git repo; I should have something committed before long.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message arnaud.mouronval 2014-05-07 18:17:02 BUG #10256: COUNT(*) behaves sort of like RANK() when used over a window containing an ORDER BY
Previous Message Leif Jensen 2014-05-07 17:16:56 Re: Server process crash - Segmentation fault

Browse pgsql-general by date

  From Date Subject
Next Message Andrus 2014-05-07 18:26:16 Re: How to fix lost synchronization with server
Previous Message Jeff Janes 2014-05-07 17:26:17 Re: Building Postgres using mingw