warning: pg_query() [function.pg-query]: Query failed: ERROR: missing FROM-clause entry for table "blocks" in /home/BPM/docs/includes/database.pgsql.inc on line 139.
user warning: query: DELETE FROM drupal_blocks WHERE blocks.module = 'image_attach' AND blocks.delta = 0 in /home/BPM/docs/sites/all/modules/image/contrib/image_attach/image_attach.install on line 123.

image_attach module
Update #6101
Failed: DELETE FROM {blocks} WHERE blocks.module = 'image_attach' AND blocks.delta = 0

This occurs because of drupal_ table name prefix. Should be:
DELETE FROM {blocks} WHERE {blocks}.module = 'image_attach' AND {blocks}.delta = 0
or simply:
DELETE FROM {blocks} WHERE module = 'image_attach' AND delta = 0

Comments

jandd’s picture

Status: Active » Needs review

The following patch fixes the issue:

--- a/image/contrib/image_attach/image_attach.install
+++ b/image/contrib/image_attach/image_attach.install
@@ -120,7 +120,7 @@ function image_attach_update_6100() {
  */
 function image_attach_update_6101() {
   $ret = array();
-  $ret[] = update_sql("DELETE FROM {blocks} WHERE blocks.module = 'image_attach' AND blocks.delta = 0");
+  $ret[] = update_sql("DELETE FROM {blocks} WHERE {blocks}.module = 'image_attach' AND {blocks}.delta = 0");

   return $ret;
 }
Dret’s picture

A similar problem appear upgrading from alpha4 to alpha6.

This patch resolve also this one??

This is the log file:

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!

joachim’s picture

Title: alpha5 -> alpha6 database update error » alpha5 -> alpha6 database update 6101 error

I don't understand why the {image_attach are failing. Could you file a new issue for that please? mention the update number in the title.

@jandd: your patch looks fine. Will commit when I am able to.

Dret’s picture

Sorry, I don't understand your request.

Please can you explain me better what i have to do?

Thanks a lot!
Bye!

joachim’s picture

@Dret: your bug is a different problem, please file new issue. Mention "update 6100" in the title please.

Dret’s picture

Ok, i'll do it!
Thanks!
;)

Ps. now you are talking about: in my log file there's indications for a failure in update 6100 and 6010 too.

rsvelko’s picture

I prefer the simpler method:
DELETE FROM {blocks} WHERE module = 'image_attach' AND delta = 0

Has this already been patched?

joachim’s picture

Not yet; this issue will get marked 'fixed' once it's fixed ;)
I have little net access until conference, sun has none I think.

joachim’s picture

Status: Needs review » Fixed

Fixed image_attach_update_6101.

This means that anyone who has installed alpha 6 will need to re-run 6101 when they install the next release.

rsvelko’s picture

If it is safe - you can paste 6101 into the header of the next one... If it runs twice it wont hurt? Sorry if I have said sth very stupid - I am tired right now and somewhere in the back of my mind there is this thought that this can be fixed for all users by re-running it twice - to cover users that had the un-patched version on a next update... while still not creating problems to others..

joachim’s picture

Hmm, I'd rather not put the same query into another update function, especially as alpha 6 has had a shelflife of only 6-7 days!

Will put a note in the release notes for beta 1.

Basically, if you still haven't got the attached images block you can either:
1. in the exec PHP block, include the image_attach.install file and run image_attach_update_6101().
2. run the query from image_attach_update_6101() in code.
3. kill that row yourself in the database.

rsvelko’s picture

I killed it with mysql

2noame’s picture

I don't understand how to do any of these options. Is there anything else I can do? Will future releases fix this or do I have no choice but to do one of these at some point because I installed Alpha6? Can I rerun something with update.php?

joachim’s picture

Running update.php will rerun functions you don't want to rerun: don't do this.

To fix:

1. Enable the Execute PHP block.
2. Run this line of code in the block:

update_sql("DELETE FROM {blocks} WHERE module = 'image_attach' AND delta = 0");
2noame’s picture

Thank you, that's very handy to know for future use.

roderik’s picture

Status: Fixed » Needs review

Database strictness police reporting ;-)

The 'delta' column is a VARCHAR, so strict databases (like PostgreSQL) fail. Patch below.

=== modified file 'sites/all/modules/image/contrib/image_attach/image_attach.install'
--- sites/all/modules/image/contrib/image_attach/image_attach.install	2009-09-05 22:32:31 +0000
+++ sites/all/modules/image/contrib/image_attach/image_attach.install	2009-09-05 23:51:18 +0000
@@ -131,7 +131,7 @@
  */
 function image_attach_update_6101() {
   $ret = array();
-  $ret[] = update_sql("DELETE FROM {blocks} WHERE module = 'image_attach' AND delta = 0");
+  $ret[] = update_sql("DELETE FROM {blocks} WHERE module = 'image_attach' AND delta = '0'");
 
   return $ret;  
 }
patryk’s picture

Status: Needs review » Reviewed & tested by the community
joachim’s picture

Status: Reviewed & tested by the community » Fixed

Committed.
Thanks for the fix!

Status: Fixed » Closed (fixed)

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

libre fan’s picture

DELETE FROM {blocks} WHERE module = 'image_attach' AND delta = 0
I'd like to make sure: Do you run this command this within Mysql (or PHPMyAdmin)?

Hey guys, think not all of us are experts. Please explain things as if some of us were dumb (which none of us is of course) ;-)

Kill that thing in a row

Quite, and how do you achieve that?

Cheers

joachim’s picture

Yes. It's a query, it runs within SQL. Either of those will do.

> Kill that thing in a row

PHPMyAdmin has a clicky X icon next to each table row it lists. That just deletes the row.