Re: SELECT FOR UPDATE - Mailing list pgsql-general

From Jan Wieck
Subject Re: SELECT FOR UPDATE
Date
Msg-id 200108230101.f7N11Br15817@jupiter.us.greatbridge.com
Whole thread Raw
In response to SELECT FOR UPDATE  (jose <jose@sferacarta.com>)
Responses Re: SELECT FOR UPDATE  (will trillich <will@serensoft.com>)
Re: SELECT FOR UPDATE  ("Oliver Elphick" <olly@lfix.co.uk>)
List pgsql-general
jose wrote:
> Hi all,
>
> I'm trying SELECT FOR UPDATE
> but I have a problem with locks.
>
> example:
> I have two users accessing to the same records, say...
>
> user1:
> DELECT * FROM table WHERE field=value FOR UPDATE
> ---------------------------------------------------------------------------
>
> user2:
> DELECT * FROM table WHERE field=value FOR UPDATE
> at this point user2 can't do nothing except waiting for user1 unlock recors.
>
> My question is:
>
> - Is it possible to know  in advance if the records of a given query are
> locked, to prevent to be locked for ever?

    Well,  first  of  all the scientists are still unsure if this
    universe will exist forever or not. So even if you find a way
    to  let  your system survive the sun becoming a red giant and
    so on, there's still uncertainty if  it'll  take  forever  or
    not.

    Anyway,  the  answer  is  no.  Standard  SQL doesn't have any
    mechanism to check wether a given row is locked or to force a
    query to fail with an error in the case a required lock isn't
    available immediately.

    But the question itself tells that you're about to  implement
    a  major  design  error in your application. Holding database
    locks during user interaction IS A BAD  THING.  Never,  never
    ever  do  it  that  way.   And  anybody telling you something
    different is an overpaid idiot.


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#================================================== JanWieck@Yahoo.com #



_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


pgsql-general by date:

Previous
From: "Oberpriller, Wade D."
Date:
Subject: FW: Re: Dynamically discovering field names in PLPGSQL queries
Next
From: missive@frontiernet.net (Lee Harr)
Date:
Subject: Re: Group by date