Here's 6003 as an example:

function password_policy_update_6003() {
  $ret = array();
  $ret[] = db_add_unique_key($ret, 'password_policy','name', array('name'));
  return $ret;
}

The basic problem is that db_add_unique_key() doesn't have an explicit return since it is using the pass-by-reference variable $ret to add the result to. Consquently, there will be a NULL added to $ret after the result that db_add_unique_key() put in there.

Later on down the line when Drupal is continuing with the update process, update_results_page() will be called to generate the results details and you'll get something like this:

Update #6003
ALTER TABLE {password_policy} ADD UNIQUE KEY name (name)
Failed:

That NULL array entry that got tacked on results in a blank "Failed:" message, which makes it look like the update didn't work correctly (although it actually did).

All three of those update functions have the same problem. Essentially all that needs to happen is that "$ret[] =" needs to removed in that second line.

Comments

earth1’s picture

Version: 6.x-1.x-dev » 6.x-1.0
Assigned: erikwebb » Unassigned
Status: Needs review » Active
Issue tags: -upgrade

I tried this on: db_change_field(&$ret, 'password_policy', 'policy', 'policy', array(

$ret[] = db_change_field(&$ret, 'password_policy', 'policy', 'policy', array(

but it doesn't work. Please help!

bryan kennedy’s picture

Priority: Normal » Major
Issue tags: +upgrade

I noticed the same issue in upgrading to 6.x-1.0 just now. Since this relates to database integrity, I increased the priority.

LonitaD’s picture

Same problem here.

AlexisWilke’s picture

FYI, I got those after upgrade from a version from last year to April's version:

* warning: pg_query() [function.pg-query]: Query failed: ERROR: syntax error at or near "," LINE 1: update password_policy_role pr, password_policy pp set pr.na... ^ in /usr/clients/www_html/new.m2osw.com/public_html/includes/database.pgsql.inc on line 188.
* user warning: query: update password_policy_role pr, password_policy pp set pr.name = pp.name where pr.pid = pp.pid in /usr/clients/www_html/new.m2osw.com/public_html/sites/all/modules/password_policy/password_policy.install on line 344.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: could not create unique index "password_policy_role_name_key" DETAIL: Table contains duplicated values. in /usr/clients/www_html/new.m2osw.com/public_html/includes/database.pgsql.inc on line 188.
* user warning: query: ALTER TABLE password_policy_role ADD CONSTRAINT password_policy_role_name_key UNIQUE (rid,name) in /usr/clients/www_html/new.m2osw.com/public_html/includes/database.pgsql.inc on line 841.

I'm using PostgreSQL and apparently you have a couple problems with that db...

glenshewchuck’s picture

FYI - still got the error updating from 6.x-1.0-beta1 to 6.x-1.0 (2011-May-19). Error: "Failed" messages on updates 6003, 6004, and 6006

AlexisWilke’s picture

As a side note, that's not going to work in PostgreSQL. You cannot have more than one table in the UPDATE. If you need more, you have to use the FROM parameter.

UPDATE password_policy_role pr, password_policy pp SET pr.name = pp.name WHERE pr.pid = pp.pid

Probably something like this:

UPDATE password_policy_role pr SET pr.name = pp.name FROM password_policy pp WHERE pr.pid = pp.pid

And I'm not so sure it would work with MySQL.

Compatibility

This command conforms to the SQL standard, except that the FROM and RETURNING clauses are PostgreSQL extensions.

Thank you.
Alexis

erikwebb’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Assigned: Unassigned » erikwebb
Priority: Major » Normal
Status: Active » Needs review
StatusFileSize
new2.3 KB

Patch attached that should fix these issues. Please RTBC and I'll commit the changes.

@AlexisWilke - Any thoughts on a PostgreSQL-compliant patch?

(Downgrading priority as this is erroneous output, not broken code.)

ChrisLaFrancis’s picture

I posted a patch in 1129682 back in April for PostgreSQL compatibility in update 6005.

Changing

$ret[] = update_sql("update {password_policy_role} pr, {password_policy} pp set pr.name = pp.name where pr.pid = pp.pid");

to

$ret[] = update_sql("update {password_policy_role} pr set name = (select name from {password_policy} pp where pr.pid = pp.pid)");

works in PostgreSQL 8.4.7. Not sure about MySQL... but from reading the documentation I think it should work there, too.

erikwebb’s picture

StatusFileSize
new2.31 KB

Re-rolled patch with fivefrank's suggested PostgreSQL compatibility change. Any confirmation from the MySQL side?

ezra-g’s picture

Version: 6.x-1.0 » 6.x-1.x-dev
Assigned: Unassigned » erikwebb
Status: Active » Reviewed & tested by the community
Issue tags: +upgrade

I tested this patch on MySQL 5.5.9 and the updates run without error. This seems RTBC.

erikwebb’s picture

Title: Erroneous "Failed" messages on updates 6003, 6004, and 6006 » Erroneous "Failed" messages on updates 6003, 6004, 6005, and 6006
Status: Reviewed & tested by the community » Fixed

Status: Fixed » Closed (fixed)

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

erikwebb’s picture

Issue tags: +PostgreSQL

Tagging