I've just upgraded to the latest dev version (as of Jan. 18th) and run the db updates. In #6100 of both image and image_attach modules, it partially fails. The error log shows:

image_attach module
Update #6100
ALTER TABLE {image_attach} CHANGE nid `nid` INT unsigned NOT NULL DEFAULT 0
ALTER TABLE {image_attach} CHANGE iid `iid` INT unsigned NOT NULL DEFAULT 0
Failed: ALTER TABLE {image_attach} ADD PRIMARY KEY (nid)
Failed: ALTER TABLE {image_attach} ADD INDEX iid (iid)
image module
Update #6100
ALTER TABLE {image} CHANGE nid `nid` INT unsigned NOT NULL DEFAULT 0
ALTER TABLE {image} CHANGE fid `fid` INT unsigned NOT NULL DEFAULT 0
Failed: ALTER TABLE {image} ADD PRIMARY KEY (nid, image_size)
ALTER TABLE {image} ADD INDEX fid (fid)
Update #6101
No queries
CommentFileSizeAuthor
#5 image-HEAD.indexes.patch1.38 KBsun
#4 image-HEAD.image-indexes.patch642 bytessun

Comments

sun’s picture

Status: Active » Fixed

Hm. This means that your tables somehow already had primary keys and indexes. I don't know how this happened to your tables, but the failing queries do not harm you.

If anyone else experiences those failing queries, please add precise information about the upgrade path you performed so far (i.e. 4.7 -> 5.x-1.x -> 5.x-2.x -> 6.x-1.x, or which parts of that, or no previous version at all?)

gábor hojtsy’s picture

Status: Fixed » Active

Well, it is pretty clear from http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/image/image... why it is broken.

image_update_5200() adds the table with PRIMARY KEY (`nid`, `image_size`), and INDEX image_fid(`fid`) and then image_update_6100() tries to add the two indexes again. So in case you run these two updates in succession it will report these errors. How is this fixed??

gábor hojtsy’s picture

BTW image_attach has the same problem with its indexes with image_attach_update_1() and image_attach_update_6100().

What Drupal core does to my knowledge is to drop indexes before fiddling with fields, and then readd them, and it does not assume that all supported databases will drop indexes on a field, if you change them. Looks like our database does not drop indexes, although the image module code might assume that.

sun’s picture

Status: Active » Needs review
StatusFileSize
new642 bytes

So we just drop the (potentially) existing primary key and index before adding our new.

sun’s picture

StatusFileSize
new1.38 KB

Combined for image and image_attach.

sun’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

rajaito’s picture

how do I run the patch?

rajaito’s picture

Status: Closed (fixed) » Active
rajaito’s picture

Can I reactivate this topic?

Please instruct us how to install your patch. Thank you.

sun’s picture

Status: Active » Closed (fixed)

You don't need to apply the patch. You need to download the latest development snapshot instead.