Altering table with open cursors - Mailing list pgsql-general

From Joshua Berry
Subject Altering table with open cursors
Date
Msg-id AANLkTimLokP6Az0KaUyqDY-+VuxOHTTwhybwhm4jQhrB@mail.gmail.com
Whole thread Raw
List pgsql-general
Hi Group,

I'm working on a database application which makes heavy use of cursors. pg_stat_activity shows that connected clients are always '<IDLE> in transaction', with a cursor open for a select. The issue that I'm having is that anytime I make changes to the table structures (ALTER TABLE tablename), the attempted operation is blocked by open cursors selecting rows from the same table. My current solution is to only make schema changes when the client applications are all disconnected.

Is there a way to alter the table schema without waiting for declared cursors to be released? Are the caveats to dangerous to deal with that I should not consider it? In general, the only changes I've been making are to add columns, which would not actually modify the result sets that the cursors are selecting anyway. Thanks for any thoughts/suggestions. I'm running PG 8.4.

Kind Regards,
-Joshua

Joshua Berry

pgsql-general by date:

Previous
From: Raymond O'Donnell
Date:
Subject: Re: Running postgres with a different user/group
Next
From: Tom Lane
Date:
Subject: Re: timestamps in Australia