Locking to restrict rowcounts.

Поиск
Список
Период
Сортировка
От Shakil Shaikh
Тема Locking to restrict rowcounts.
Дата
Msg-id BAY117-DS963528810A4240924FAD0AC5B0@phx.gbl
обсуждение исходный текст
Ответы Re: Locking to restrict rowcounts.  (Richard Huxton <dev@archonet.com>)
Re: Locking to restrict rowcounts.  ("Shakil Shaikh" <sshaikh@hotmail.com>)
Список pgsql-general
Hi,

Consider the following scenario:

CREATE FUNCTION test(name)
select into cnt count(id) from items where owner = name;
--suppose someone inserts during this point? then next check will succeed
when it should not.
if (cnt < 10) then
    insert into items values ('new item', name);
end;
end;

What is the best way to stop this function from entering too many items in a
concurrent context? I think a lock is needed, although I'm not sure which
would be most appropriate since the count requires the whole table (or at
least no adds to have occurred I think I read something about predicate
locking which sounds relevant but isn't supported in PostgreSQL. Ideally I
want some kind of lock only relevant to "name" above.

Any strategies to deal with this?

Shak


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

Предыдущее
От: "James B. Byrne"
Дата:
Сообщение: Help with join syntax sought
Следующее
От: Richard Huxton
Дата:
Сообщение: Re: Locking to restrict rowcounts.