I get the following errors when running update.php, going from 4.7.0 to 4.7.1
- Incorrect table definition; there can be only one auto column and it must be defined as a key query: ALTER TABLE node DROP PRIMARY KEY
- Multiple primary key defined query: ALTER TABLE node ADD PRIMARY KEY (nid, vid)

system_update_180() has:

$ret[] = update_sql("ALTER TABLE {node} DROP PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");

If I restore the database back to the 4.7.0 version, and I do the intended change under phpmyadmin, it combines the sql into a single ALTER TABLE statement:

ALTER TABLE node DROP PRIMARY KEY, ADD PRIMARY KEY (nid, vid)

Which produces no error.

Database is Mysql 4.1.19

Comments

asimmonds’s picture

If I change the order of the node table changes in update_180, from:

$ret[] = update_sql("ALTER TABLE {node} DROP PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
$ret[] = update_sql("ALTER TABLE {node} ADD UNIQUE (vid)");
$ret[] = update_sql("ALTER TABLE {node} ADD INDEX (nid)");

to: (adding the nid index before dropping the primary key)

$ret[] = update_sql("ALTER TABLE {node} ADD INDEX (nid)");
$ret[] = update_sql("ALTER TABLE {node} DROP PRIMARY KEY");
$ret[] = update_sql("ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)");
$ret[] = update_sql("ALTER TABLE {node} ADD UNIQUE (vid)");

and run the update on a restored 4.7.0 db, then no error is produced.

beginner’s picture

I just upgraded two different sites with mysql 4.0 and I didn't get any error, so your 4.1 version must matter.

Also, we have two mysql files to import during istallation, one 4.0 and one 4.1, but when the site is running, we're only running "mysql" so that the upgrade script doesn't know which version we use...

we currently have:

  switch ($GLOBALS['db_type']) {
    case 'mysql':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYINT(1) NOT NULL AFTER visibility ;");
      break;
    case 'pgsql':
      db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint');
      break;
  }

but we can't have:

  switch ($GLOBALS['db_type']) {
    case 'mysql-4.0':
    case 'mysqli':
      $ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYINT(1) NOT NULL AFTER visibility ;");
      break;
    case 'mysql-4.1':

      // do things differently?
       $ret[] = update_sql("ALTER TABLE {profile_fields} ADD autocomplete TINYINT(1) NOT NULL AFTER visibility ;");
      break;
    case 'pgsql':
      db_add_column($ret, 'profile_fields', 'autocomplete', 'smallint');
      break;
  }

So, your issue is a symptom of a wider issue.

gerhard killesreiter’s picture

I had tried the update on 4.1 and didn't get any errors either.

bwynants’s picture

same errors here

jwilde’s picture

same here

beginner’s picture

@killes: ok, but the limitation I mentionned remains.

@Bert and jwilde: can you give more details, so that we can get a chance of figuring out what's the common denominator between you guys? :)

jwilde’s picture

Simple update from a ten day old cvs version of drupal to 4.7.1. For primary keys in the header I get 'array' for all the prime links.

For each node I get the less than sign '<' for each module link, say bookmarks, email this page, tags, print, etc. on the bottom of the post. I hope this helps.

Jim

jwilde’s picture

my post got cut off.

I was saying, at the bottom of each post, I get the less than sign in place of links for email this page, print, tags, etc.

beginner’s picture

Actually, what I am now wondering is why me, killes, and many others don't have any error: we should have!

The error you're referring to is mysql error:1075
http://dev.mysql.com/doc/refman/4.1/en/error-messages-server.html
and is a legitimate one.

the problem and the fix is the same as reported above and can be also found in the last comment of the following page:
http://dev.mysql.com/doc/refman/4.1/en/alter-table.html

I start to believe that there is a difference in the level of error reporting: developpers should use a stricter level reporting setting in order to avoid such problem (it reminds me of E_ALL). The problem is that I don't know where such settings are situated and how to change them.

Since the beginning of this thread, I have upgraded 3 more sites, the first without the fix, and the other two with the fix. I didn't see any difference. But looking at the table {node} in phpmyadmin for each of the sites I have upgraded, I found out that before the upgrade, they all had:

More than one INDEX key was created for column `status`

and after the upgrade, they all have:

PRIMARY and INDEX keys should not both be set for column `nid`
 More than one INDEX key was created for column `status`
satori1984’s picture

Same error here:

Update #180

  • Failed: ALTER TABLE {node} DROP PRIMARY KEY
  • Failed: ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)

Running Drupal 4.7 on PHP5 / MySQL 4.0.24

satori1984’s picture

I did a dbase-restore, edited database/updates.inc as mentioned in asimmonds' post, and re-ran update.php, and this time no more errors...

rjleigh’s picture

I had the same error using mySQL v4.1.12a and PHP v4.4.2. This on a vanilla (basically empty, just one page and admin account) 4.7.0 db.

Made the change suggested in #1 submitted by asimmonds, and no error.

So, I guess it's ok?

pwolanin’s picture

Even before upgrading to 4.7.1, I'm seeing in phpmyadmin lots of error messages as described in #9 above. Where, the primary key is (nid,vid) but each of these is also set to be an index. Why do these need to be separately indexed if they are part of the primary index?

pwolanin’s picture

With mysql 4.1.18, PHP 4.4.2 I do not get any error messages upgrading to 4.7.1.

Same with a different site with mysql 4.0.27, PHP Version 4.4.2

Comparing version numbers with posts above, are their relevant differences from mysql 4.1.1 to mysql 4.1.18 or from 4.0.24 to 4.0.27?

asimmonds’s picture

After some more experimenting, I'm pretty certain the problem is with Mysql table types.
The Drupal instance that I initially had the error with, has had it's tables converted to the InnoDB engine for some performance testing.

Created two Drupal 4.7.0 instances, one MyISAM, the other InnoDB based. Then upgraded both to 4.7.1. The MyISAM-based one upgraded without errors, while the InnoDB-based one produced the primary key error.

Testing environment: Win32 / Mysql 4.1.19 / PHP 5.1.4
Initial problem environment was: Linux / Mysql 4.1.19 / PHP 4.4.2

Kitchen’s picture

Reading the comments, I'm wondering is this is an error or not. The message I got was similar, but did not say 'failure.' If this is an error, is there a fix? Other than the message below, things seem to be functioning properly (so far).

The following queries were executed

system module

Update #180

ALTER TABLE {node} DROP PRIMARY KEY
ALTER TABLE {node} ADD PRIMARY KEY (nid, vid)
ALTER TABLE {node} ADD UNIQUE (vid)
ALTER TABLE {node} ADD INDEX (nid)
ALTER TABLE {node_counter} CHANGE nid nid INT(10) NOT NULL DEFAULT '0'

Update #181

ALTER TABLE {profile_fields} ADD autocomplete TINYINT(1) NOT NULL AFTER visibility ;

Update #182

No queries

gregoryo’s picture

See: http://drupal.org/node/63785
Same problem reported May 15, 2006 as
"system_update_180 error - upgrading from 4.5 to 4.7 - Can't DROP 'vid'."
Apache 2.0.51, php 4.3.11, and mysql 3.23.58

edited updates.inc with changes in item #1 above
reloaded database applied updates.php
with no problems now.

gtcaz’s picture

I see these errors even though I installed from the current CVS.

Problems with indexes of table `node`
PRIMARY and INDEX keys should not both be set for column `nid`
More than one INDEX key was created for column `status`
Problems with indexes of table `term_hierarchy`
PRIMARY and INDEX keys should not both be set for column `tid`
Problems with indexes of table `term_node`
PRIMARY and INDEX keys should not both be set for column `tid`

Should this be fixed?

beginner’s picture

Title: primary key error in update.php when updating from 4.7.0 to 4.7.1 » primary key error in update.php when updating
Version: 4.7.1 » x.y.z
magico’s picture

Category: bug » support

Support request until further development, with a concise identification and problem reproduction.

magico’s picture

Version: x.y.z » 5.x-dev
Status: Active » Closed (duplicate)