Do I have to lock table in this case?

Поиск
Список
Период
Сортировка
От Ondrej Palkovsky
Тема Do I have to lock table in this case?
Дата
Msg-id Pine.LNX.4.20.0106091746160.2590-100000@ondra.debian.cz
обсуждение исходный текст
Список pgsql-sql
I have a table like this:id primary keyunique

I need to do:- if 'unique' exists in table, return appropriate id
else insert into table new id.
Now doing:
select id where unique=%s 
insert/update 
creates a race condition. The application can theoretically rollback &
redo the whole transaction (not simple in some cases). What is the
preferred solution to this problem (I got about 3 such cases in one simple
application).

Ondrej

--
It is better to remain childless than to father an orphan.



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

Предыдущее
От: david.brown@mviva.net (David Brown)
Дата:
Сообщение: listing foreign keys
Следующее
От: Alex Pilosov
Дата:
Сообщение: Re: PL/PGSQL