[PATCH v3 04/13] lib: Database version 3: Introduce fine-grained "features"

Austin Clements amdragon at mit.edu
Sat Aug 23 17:58:50 PDT 2014


On Sat, 23 Aug 2014, David Bremner <david at tethera.net> wrote:
> Austin Clements <amdragon at MIT.EDU> writes:
>>  
>> +    /* Bit mask of features used by this database.  Features are
>> +     * named, independent aspects of the database schema.  This is a
>> +     * bitwise-OR of NOTMUCH_FEATURE_* values (below). */
>> +    unsigned int features;
>
> Should we be using a fixed size integer (uint_32t or whatever) for
> features? iirc the metadata in the database is actually a string, so I
> guess arbitrary precision there.

Right; this doesn't matter for the on-disk format because these don't
appear on disk.  But you're right that in principle we could overflow
this, leading to subtle bugs.  I moved the enum above struct
_notmuch_database, gave it a name and bitwise operators for C++, and
used that enum name everywhere, so precision should never be a problem.

>> +/* Bit masks for _notmuch_database::features. */
>> +enum {
>> +    /* If set, file names are stored in "file-direntry" terms.  If
>> +     * unset, file names are stored in document data.
>> +     *
>> +     * Introduced: version 1.  Implementation support: both for read;
>> +     * required for write. */
>> +    NOTMUCH_FEATURE_FILE_TERMS = 1 << 0,
>
> I agree with Jani that the Implementation support: part is a bit
> mystifying without the commit message. Maybe part of the commit message
> could migrate here? Or maybe just add a pointer to the comment in database.cc.

I stripped these out because I don't think they're maintainable.  See my
reply to Jani.

>> +		if (! *incompat_out)
>
> Should we support passing NULL for incompat_out? or at least check for
> it?

Added a guard so it's safe to pass NULL.

>> @@ -1048,7 +1164,8 @@ notmuch_database_get_version (notmuch_database_t *notmuch)
>>  notmuch_bool_t
>>  notmuch_database_needs_upgrade (notmuch_database_t *notmuch)
>>  {
>> -    return notmuch->needs_upgrade;
>> +    return notmuch->mode == NOTMUCH_DATABASE_MODE_READ_WRITE &&
>> +	(NOTMUCH_FEATURES_CURRENT & ~notmuch->features);
>>  }
>
> Maybe I'm not thinking hard enough here, but how does this deal with a
> feature that is needed to open a database in read only mode? Maybe it
> needs a comment for people not as clever as Austin ;).

I'm not quite sure what you mean.  notmuch_database_needs_upgrade
returns false for read-only databases because you can't upgrade a
read-only database.  This was true before this patch, too, though it was
less obvious.  (Maybe that's not what you're asking?)


More information about the notmuch mailing list