Assertion failure with a subtransaction and cursor - Mailing list pgsql-bugs

From Heikki Linnakangas
Subject Assertion failure with a subtransaction and cursor
Date
Msg-id 4B0912BC.4090803@enterprisedb.com
Whole thread Raw
Responses Re: Assertion failure with a subtransaction and cursor
List pgsql-bugs
On all versions starting from 8.0 where subtransactions were introduced,
this causes an assertion failure:

postgres=# BEGIN;
BEGIN
postgres=# DECLARE foocur CURSOR FOR SELECT a FROM
generate_series(1,500000) a;
DECLARE CURSOR
postgres=# SAVEPOINT sp;
SAVEPOINT
postgres=# FETCH foocur;
 a
───
 1
(1 row)

postgres=# error; -- cause subxact abort
ERROR:  syntax error at or near "error"
LINE 1: error;
        ^
postgres=# ROLLBACK TO SAVEPOINT sp;
ROLLBACK
postgres=# FETCH ALL FROM foocur;
server closed the connection unexpectedly
    This probably means the server terminated abnormally
    before or while processing the request.
The connection to the server was lost. Attempting reset: Failed.

In server log:

TRAP: FailedAssertion("!(((file) > 0 && (file) < (int) SizeVfdCache &&
VfdCache[file].fileName != ((void *)0)))", File: "fd.c", Line: 1101)

When the first row is fetched from the cursor, the function scan is
materialized in a temporaray file. At the error, the temporary file is
deleted. But the FETCH ALL command expects the cursor to be still open,
and the file to exist, so it fails.

If assertions are disabled, you get an "ERROR:  unexpected end of tape"
error instead.

--
  Heikki Linnakangas
  EnterpriseDB   http://www.enterprisedb.com

pgsql-bugs by date:

Previous
From: Hiroshi Inoue
Date:
Subject: Re: BUG #5204: ODBC connection NOT working
Next
From: Tom Lane
Date:
Subject: Re: Assertion failure with a subtransaction and cursor