[Dovecot] expire: mysql table creation error
John Fawcett
john.ml at erba.tv
Fri May 29 09:51:31 EEST 2009
Timo Sirainen wrote:
> On Thu, 2009-05-28 at 08:04 +0200, John Fawcett wrote:
>
>> but maybe that's not such a good primary key,
>> probably better to do:
>>
>> mysql> CREATE TABLE expires (
>> -> id integer not null auto_increment,
>> -> username varchar(100) not null,
>> -> mailbox varchar(255) not null,
>> -> expire_stamp integer not null,
>> -> primary key (id),
>> -> key (username, mailbox(200))
>> -> );
>> Query OK, 0 rows affected (0.00 sec)
>>
>
> Nothing uses the id, so I don't really see a point in having primary key
> at all then. You could instead create a unique index on (username,
> mailbox), unless MySQL disallows that too.
>
>
yes it works without the primary key. It is best to not have a unique
index otherwise there will be insert failures for (the unlikely event)
of mailboxes for the same user with mailbox names longer than 200 chars
and the first 200 chars identical. A non unique index is fine.
CREATE TABLE expires_test (
username varchar(100) not null,
mailbox varchar(255) not null,
expire_stamp integer not null,
key (username, mailbox(200))
);
More information about the dovecot
mailing list