Re: [SQL] 'locking' the SELECTs based on indices...

2006-02-23 Thread Mario Splivalo
On Thu, 2006-02-23 at 17:35 +0100, PFC wrote: > > > Now, If some other user want's his prize, when checking his code, if he > > sends code for some other service then service 1, that's ok. If he's > > sends code for the service 1 the PERFORM will wait untill I'm finished > > with previous user. >

Re: [SQL] 'locking' the SELECTs based on indices...

2006-02-23 Thread PFC
Now, If some other user want's his prize, when checking his code, if he sends code for some other service then service 1, that's ok. If he's sends code for the service 1 the PERFORM will wait untill I'm finished with previous user. Sorry for the double post. If the rows in your tabl

Re: [SQL] 'locking' the SELECTs based on indices...

2006-02-23 Thread PFC
I lock just that particular row, which is no good. I need to have all the codes for the service 1 locked, so if it happens that two users send the very same code, one has to fail. Therefore, from within plpgsql I first do: I'm a bit tired tonight so I'll simplify your example : CREAT

Re: [SQL] 'locking' the SELECTs based on indices...

2006-02-23 Thread Mario Splivalo
On Thu, 2006-02-23 at 13:56 +0200, Achilleus Mantzios wrote: > The intersection of rows that satisfy BOTH > "code_id = 1 AND code_value = 'abla'" > and > "code_id = 1 AND code_value = 'eble'" > is ZERO!!! > > Why would you want irrelevant rows to wait for one another?? It was a bit silly repre

Re: [SQL] 'locking' the SELECTs based on indices...

2006-02-23 Thread Mario Splivalo
On Wed, 2006-02-22 at 13:58 -0500, Tom Lane wrote: > Mario Splivalo <[EMAIL PROTECTED]> 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

Re: [SQL] 'locking' the SELECTs based on indices...

2006-02-22 Thread Tom Lane
Mario Splivalo <[EMAIL PROTECTED]> 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 SELEC

[SQL] 'locking' the SELECTs based on indices...

2006-02-22 Thread Mario Splivalo
I have a table, like this: CREATE TABLE bla (id int4, code_id int4, code_value varchar, CONSTRAINT bla_pk PRIMARY KEY (id)) And, i have index on the table: CREATE INDEX bla_idx1 ON bla(code_id) Now, when I do this from one connection (psql shell, for instance): [A]BEGIN TRANSACTION; [A]SELECT