Re: BUG #1459: Connection hangs when other connection is not - Mailing list pgsql-bugs

From Rainer Frey
Subject Re: BUG #1459: Connection hangs when other connection is not
Date
Msg-id 42035480.2060707@inxmail.de
Whole thread Raw
In response to Re: BUG #1459: Connection hangs when other connection is not committed  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-bugs
Peter Eisentraut schrieb:
> Am Donnerstag, 3. Februar 2005 16:11 schrieb Rainer Frey:
>
>>A select should not lock a table even when it is not committed.
>
>
> The SELECT obtains a read (shared) lock on the table, but the ALTER TABLE
> requires a write (exclusive) lock.  This is certainly necessary because you
> don't want the structure of the table to be changed while you are reading it.
> Additionally, the locking protocol requires that all locks once obtained need
> to be held until the end of the transaction.  Both of these issues together
> explain the problem you are seeing.  There is nothing that can be done about
> it.

Thanks for the explanation, though I don't really get the necessity of a
commit for a read-only statement. Can't a SELECT release its lock after
it received the response?
Is there any possibility to set a timeout for the lock, after which the
ALTER TABLE statement fails, instead of remaining in wait status (when
calling with JDBC?

Rainer Frey

pgsql-bugs by date:

Previous
From: Rolf Sponsel
Date:
Subject: Re: [Feed-back] Installing PostgreSQL 8.0.0 on SPARC/Solaris.
Next
From: rob
Date:
Subject: SELECT returning too many rows (?)