From: Tom Lane <tgl@sss.pgh.pa.us>
To: mario.splivalo@mobart.hr
Cc: pgsql-sql@postgresql.org
Subject: Re: 'locking' the SELECTs based on indices...
Date: Wed, 22 Feb 2006 13:58:24 -0500
Message-ID: <14024.1140634704@sss.pgh.pa.us> (raw)
In-Reply-To: <1140631350.14229.8.camel@localhost.localdomain>
References: <1140631350.14229.8.camel@localhost.localdomain>
Mario Splivalo <mario.splivalo@mobart.hr> writes:
> Now, when I do this from one connection (psql shell, for instance):
> [A]BEGIN TRANSACTION;
> [A]SELECT * FROM bla WHERE code_id = 1 FOR UPDATE;
> and then, from another psql i do:
> [B]SELECT * FROM bla WHERE code_id = 1 FOR UPDATE
> the second SELECT will wait untill I rollback or commit first
> transaction. That is cool.
> But, if I do second SELECT like this:
> [C]SELECT * FROM bla WHERE code_id = 2 FOR UPDATE
> I will get the rows.
Well, of course. Why would you want something different? Why do you
think the table's indexes should have anything to do with it?
If you want a full-table lock then some form of LOCK TABLE seems like
the proper answer. SELECT FOR UPDATE is designed to lock the specified
rows, no more.
> If I erase the index bla_idx1, then [C] select will wait, same as [B]
> select will wait.
I don't think so. If it does, it's a bug; please provide a reproducible
test case.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, mario.splivalo@mobart.hr
Subject: Re: 'locking' the SELECTs based on indices...
In-Reply-To: <14024.1140634704@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox