From: | "Owen Jacobson" <ojacobson(at)osl(dot)com> |
---|---|
To: | <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Bitfields always atomic? Other way to store attributes? |
Date: | 2006-03-28 21:59:41 |
Message-ID: | 144D12D7DD4EC04F99241498BB4EEDCC274CE8@nelson.osl.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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, but you can't guarantee that another client won't interfere with the results.
From | Date | Subject | |
---|---|---|---|
Next Message | Achilleus Mantzios | 2006-03-29 08:17:33 | Flight numbers data |
Previous Message | TJ O'Donnell | 2006-03-28 21:55:01 | Re: Bitfields always atomic? Other way to store attributes? |