Hi to all!

I have an update problem from Image alpha4 to last alpha6 version.

This is the log file at the end of update process:

user warning: Can't DROP 'PRIMARY'; check that column/key exists query: ALTER TABLE drupal_image_attach DROP PRIMARY KEY in /var/www/drupal/includes/database.mysql-common.inc on line 386.
user warning: Can't DROP 'iid'; check that column/key exists query: ALTER TABLE drupal_image_attach DROP INDEX iid in /var/www/drupal/includes/database.mysql-common.inc on line 448.
user warning: Unknown column 'blocks.module' in 'where clause' query: DELETE FROM drupal_blocks WHERE blocks.module = 'image_attach' AND blocks.delta = 0 in /var/www/drupal/modules/image/contrib/image_attach/image_attach.install on line 123.
user warning: Can't DROP 'PRIMARY'; check that column/key exists query: ALTER TABLE drupal_image DROP PRIMARY KEY in /var/www/drupal/includes/database.mysql-common.inc on line 386.
user warning: Can't DROP 'image_fid'; check that column/key exists query: ALTER TABLE drupal_image DROP INDEX image_fid in /var/www/drupal/includes/database.mysql-common.inc on line 448.
The following queries were executed
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} DROP PRIMARY KEY
ALTER TABLE {image_attach} ADD PRIMARY KEY (nid)
Failed: ALTER TABLE {image_attach} DROP INDEX iid
ALTER TABLE {image_attach} ADD INDEX iid (iid)
Update #6101
Failed: DELETE FROM {blocks} WHERE blocks.module = 'image_attach' AND blocks.delta = 0

Thanks!

CommentFileSizeAuthor
#7 image_6.x-1.0-alpha6_562810.patch1.89 KBdatune
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dret’s picture

Sorry, This post (and the next one) are due to a Submission error, Please erase them.

Thanks!

Dret’s picture

Title: update problem from alpha4 to alpha6 (update 6001) » update problem from alpha4 to alpha6 (update 6100)

Please erase this post.

Thanks!

Borromini’s picture

I can confirm this issue, just did an update from alpha4 to alpha6 on a freshly updated 6.13:

Can't DROP 'PRIMARY'; check that column/key exists query: ALTER TABLE image_attach DROP PRIMARY KEY in /var/www/drupal/includes/database.mysql-common.inc on line 386.

and

Can't DROP 'iid'; check that column/key exists query: ALTER TABLE image_attach DROP INDEX iid in /var/www/drupal/includes/database.mysql-common.inc on line 448.

joachim’s picture

Is there anyone who knows about primary keys and the like who can shed some light on this?

rsvelko’s picture

Status: Active » Closed (duplicate)
joachim’s picture

Assigned: datune » Unassigned
Status: Fixed » Active

OK, so we're figuring this out at the D7 sprint... ;)

The problem is that 6-alpha-1 to alpha-4 don't define primary keys or indexes in hook_schema and yet image_attach_update_1() adds them.
In other words, the schema doesn't agree with the update functions.

So if you started back at version 5 or earlier, you get these added for you when you update.
If you start with one of these alphas, you don't.

Alpha 1-3: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/image/contr...
Alpha 4: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/image/contr...
Alpha 5: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/image/contr...
Alpha 6: http://cvs.drupal.org/viewvc.py/drupal/contributions/modules/image/contr...

So since no subsequent update functions check if the key actually is there before trying to delete it, you get errors.

datune’s picture

Assigned: Unassigned » datune
FileSize
1.89 KB

This should resolve the issue, see comments for more info.

joachim’s picture

Status: Closed (duplicate) » Fixed

Gah, lost wifi ate my comment!

I've seen datune test this myself at the DrupalCon Paris ice cream sprint, so I'm happy that the patch is ready :D
Committed, with huge thanks to datune for figuring this hairy SQL problem.

rsvelko’s picture

Super!

For those that are not in Paris ( :jealous ) tell us - do you eat ice cream fast in these ice cream sprints?

Assigned: Unassigned » datune
Status: Active » Closed (fixed)

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