From: Owen Jacobson <ojacobson@osl.com>
To: pgsql-sql@postgresql.org
Subject: Re: Bitfields always atomic? Other way to store attributes?
Date: Tue, 28 Mar 2006 13:59:41 -0800
Message-ID: <144D12D7DD4EC04F99241498BB4EEDCC274CE8@nelson.osl.com> (raw)
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.
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: ojacobson@osl.com
Subject: Re: Bitfields always atomic? Other way to store attributes?
In-Reply-To: <144D12D7DD4EC04F99241498BB4EEDCC274CE8@nelson.osl.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox