Re: BUG #6548: NOWAIT does not work in Select statement if table is locked using "Lock " command

From: "Kevin Grittner" <Kevin(dot)Grittner(at)wicourts(dot)gov>
To: <neeraj(dot)punmiya(at)securetogether(dot)com>
Cc: <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: BUG #6548: NOWAIT does not work in Select statement if table is locked using "Lock " command
Date: 2012-03-21 14:54:32
Message-ID: 4F69A55802000025000464E4@gw.wicourts.gov
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

<neeraj(dot)punmiya(at)securetogether(dot)com> wrote:

> Create Table Test (x integer,y integer);
>
> Insert Into Test Values(1,100);
> Insert Into Test Values(2,200);
>
> First database session:
> ---------------------------
> start transaction;
> Lock table Test;
>
> Second database session
> -----------------------
> start transaction;
>
> Select y from Test where x=1 for update nowait;
>
> select query waits until first session releases table lock.
> Nowait does not have any effect in select statement.

That is all functioning as designed and documented. From the docs
at:

http://www.postgresql.org/docs/9.1/interactive/sql-select.html#SQL-FOR-UPDATE-SHARE

| Note that NOWAIT applies only to the row-level lock(s) * the
| required ROW SHARE table-level lock is still taken in the ordinary
| way (see Chapter 13). You can use LOCK with the NOWAIT option
| first, if you need to acquire the table-level lock without waiting.

This is not a bug.

-Kevin

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2012-03-21 15:48:24 Re: BUG #6548: NOWAIT does not work in Select statement if table is locked using "Lock " command
Previous Message c_h_thakar 2012-03-21 12:07:43 Re: [BUGS] Mapping Hibernate boolean to smallint(Postgresql)