Re: SELECT FOR UPDATE
От | Jan Wieck |
---|---|
Тема | Re: SELECT FOR UPDATE |
Дата | |
Msg-id | 200108230101.f7N11Br15817@jupiter.us.greatbridge.com обсуждение исходный текст |
Ответ на | SELECT FOR UPDATE (jose <jose@sferacarta.com>) |
Ответы |
Re: SELECT FOR UPDATE
Re: SELECT FOR UPDATE |
Список | 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 по дате отправления: