pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
R: Help lock record
2+ messages / 2 participants
[nested] [flat]

* R: Help lock record
@ 2006-05-24 05:12  bitrunner <bitrunner@katamail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: bitrunner @ 2006-05-24 05:12 UTC (permalink / raw)
  To: pgsql-jdbc


On 23-May-06, at 1:37 PM, bitrunner wrote:

 > For lock the record I use:
 > select * from orders where id = 17 for update
 >
 > in this way lock the record with id = 17.
 > If an other user demands the same record as I can understand that it 
is lock?

 > yes as long as autocommit is false this is true. In other words as
 > long as you do this inside a transaction/


sorry but I dont have to understand.
How I can understand that there is an other user who lock the record?

Thanks.



^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: R: Help lock record
@ 2006-05-24 11:31  Dave Cramer <pg@fastcrypt.com>
  parent: bitrunner <bitrunner@katamail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Cramer @ 2006-05-24 11:31 UTC (permalink / raw)
  To: bitrunner <bitrunner@katamail.com>; +Cc: pgsql-jdbc


On 24-May-06, at 1:12 AM, bitrunner wrote:

>
> On 23-May-06, at 1:37 PM, bitrunner wrote:
>
> > For lock the record I use:
> > select * from orders where id = 17 for update
> >
> > in this way lock the record with id = 17.
> > If an other user demands the same record as I can understand that  
> it is lock?
>
> > yes as long as autocommit is false this is true. In other words as
> > long as you do this inside a transaction/
>
>
> sorry but I dont have to understand.
> How I can understand that there is an other user who lock the record?

I think I understand the question. You want to know how to determine  
if the record is locked.

As far as I know there isn't a way. If process A locks the record,  
then process B attempts to lock the record it will block until  
process A releases the record.

If you have statement_timeout set to some value other than -1 then  
process B will timeout after waiting for the statement_timeout.  
Otherwise it will block until process A is finished with the record.

Dave
>
> Thanks.
>
> ---------------------------(end of  
> broadcast)---------------------------
> TIP 3: Have you checked our extensive FAQ?
>
>               http://www.postgresql.org/docs/faq
>




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2006-05-24 11:31 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-05-24 05:12 R: Help lock record bitrunner <bitrunner@katamail.com>
2006-05-24 11:31 ` Dave Cramer <pg@fastcrypt.com>

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