Altering table with open cursors

From: Joshua Berry <yoberi(at)gmail(dot)com>
To: PostgreSQL - General <pgsql-general(at)postgresql(dot)org>
Subject: Altering table with open cursors
Date: 2010-11-03 13:40:40
Message-ID: AANLkTimLokP6Az0KaUyqDY-+VuxOHTTwhybwhm4jQhrB@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2010-11-03 14:27:13 Re: timestamps in Australia
Previous Message Raymond O'Donnell 2010-11-03 12:32:49 Re: Running postgres with a different user/group