Bug 225221 - a primary key for longdescs

Zak Greant zak at sxip.com
Fri Oct 15 17:47:15 UTC 2004


Greetings!

On Oct 15, 2004, at 10:27, David Miller wrote:
> Zak Greant wrote:
>
>> MySQL, in most common use cases, will generate a sequential set of 
>> integers. As rows are deleted, the corresponding integers will not be 
>> re-used. The exceptions to this are multi-column primary keys with 
>> auto_increment fields and some versions of MySQL > 3 years old.
>> Still, why rely on a feature that is only supported by one database? 
>> It seems better to be more independent. <shrug>
>
> This would only be in the upgrade code, and there are no non-MySQL 
> databases that we care about upgrading at the moment (because we don't 
> actually support any others yet).  Assuming this code lands before the 
> database independence stuff does, it won't need to work on anything 
> other than MySQL.

Heh. At least that simplifies things for the now. :)

> The table in question has potentionally a hundred thousand or more 
> rows in it already, with no existing primary key.  There's a bug ID 
> and a datestamp, which are sorted on when it's loaded currently.

Something simple like:
   ALTER TABLE longdescs ORDER BY bug_when, bug_id;
   ALTER TABLE longdescs ADD COLUMN pk INT UNSIGNED NOT NULL 
AUTO_INCREMENT PRIMARY KEY;
... seems like it should do the trick.

Cheers!
--zak




More information about the developers mailing list