is an explicit lock necessary?

Поиск
Список
Период
Сортировка
От Ash Grove
Тема is an explicit lock necessary?
Дата
Msg-id 20060504181056.14509.qmail@web52510.mail.yahoo.com
обсуждение исходный текст
Ответы Re: is an explicit lock necessary?  (Andrew Sullivan <ajs@crankycanuck.ca>)
Re: is an explicit lock necessary?  (Stephan Szabo <sszabo@megazone.bigpanda.com>)
Re: is an explicit lock necessary?  (Ragnar <gnari@hive.is>)
Список pgsql-sql
Hi,

Does beginning a transaction put locks on the tables
queried within the transaction?

In the example below, is #2 necessary? My thought was
that I would need to use an explicit lock to make sure
that the sequence value I'm selecting in #4 is the
same one that is generated from #3. I'm worried about
another instance of the application doing an insert on
table1 between #3 and #4.

1) From my app, I turn off autocommit.
2) I lock table1 in access exclusive mode
3) I do an insert into table1 which generates a
primary key via nextval on sequence1
4) I grab grab the primary key value via currval on
sequence1
5) I do an insert on table2 which includes table1's
primary key so I can join the records later.
6) I manually commit

Thanks!
Ash

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


В списке pgsql-sql по дате отправления:

Предыдущее
От: Oisin Glynn
Дата:
Сообщение: Re: Connecting to Postgres from other machines (outside localhost)
Следующее
От: Andrew Sullivan
Дата:
Сообщение: Re: is an explicit lock necessary?