I'm having a curious warning message appear during updates to one Drupal site:

Drupal database update
user warning: Table 'batch' already exists query: CREATE TABLE talldave_drpl34.batch ( `bid` INT unsigned NOT NULL auto_increment, `token` VARCHAR(64) NOT NULL, `timestamp` INT NOT NULL, `batch` LONGTEXT DEFAULT NULL, PRIMARY KEY (bid), INDEX token (token) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in .../includes/database.inc on line 529.

This is a relatively new site that was installed with Drupal 6.14 and updated this morning to Drupal 6.15. I'm not seeing this error on any of my other Drupal 6.14 or 6.15 sites.

Any ideas as to cause or fix will be appreciated.

[Note to self: atozm]


TallDavid’s picture

After considerable research, and a lucky guess or two, I've solved the problem. I'll document my findings below in the hope that it will help a future traveler to find the way.

This Drupal site is also running CiviCRM v3.03. In order to implement the CiviCRM/Views integration, one must change settings.php file so that the $db_prefix variable is an array. I found documentation on another site which I used to setup my $db_prefix array as follows:

$db_prefix = array(
  'default'             => 'talldave_drpl34.', 
  'civicrm_acl'         => 'talldave_ccrm34.',
  'civicrm_acl_cache'   => 'talldave_ccrm34.',

where talldave_drpl34 is the name of my Drupal database and talldave_ccrm34 is the name of the CiviCRM database.

The configuration above resulted in the warning messages shown in my original post. In my research I found an entry by xarbot in post http://drupal.org/node/493068 which emphasized that the value for default should be empty. Given that tip, I changed the code as follows:

$db_prefix = array(
  'default'             => '', 
  'civicrm_acl'         => 'talldave_ccrm34.',
  'civicrm_acl_cache'   => 'talldave_ccrm34.',

The warning message no longer occurs.

Hope this helps!

JBMK’s picture

Had the same problem - the solution works perfectly well!

2ndmile’s picture

Thanks you very much. Solved my problem!

Yuri’s picture

Yep, that's the solution that worked for me too.

donquixote’s picture

Warning: This can potentially slow down your entire site, on current D6.
Every db_query() has to run through all of the replacements defined in the table.
See #561422: Replace strtr() with str_replace() for db prefixing.