Re: Bitfields always atomic? Other way to store attributes?

Поиск
Список
Период
Сортировка
От Owen Jacobson
Тема Re: Bitfields always atomic? Other way to store attributes?
Дата
Msg-id 144D12D7DD4EC04F99241498BB4EEDCC274CE8@nelson.osl.com
обсуждение исходный текст
Ответ на Bitfields always atomic? Other way to store attributes?  (Bryce Nesbitt <bryce1@obviously.com>)
Список pgsql-sql
TJ O'Donnell wrote:

> > If I have two threads modifying the same "bit" field:
> >     thread1=> update table set bf=bf | '01000'
> >     thread2=> update table set bf=bf | '10000'
> > Will this operation always be safe (e.g. result in bf='11000')?  Or
>
> Won't this always result in bf='11xxx', depending on the
> original values of bf?

Not even.  Consider:

thread1=> update table set bf=bf | '01000'
thread3=> update table set bf=bf & '10111'
thread2=> update table set bf=bf | '10000'

Now you get bf=10xxx.

They're thread safe in that all transformations will be applied as-if serially, so no bit sets or unsets will be lost,
butyou can't guarantee that another client won't interfere with the results. 


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

Предыдущее
От: "TJ O'Donnell"
Дата:
Сообщение: Re: Bitfields always atomic? Other way to store attributes?
Следующее
От: Achilleus Mantzios
Дата:
Сообщение: Flight numbers data