table in Drupal database was configured to be optimized but does not exist.

jerome72 - November 17, 2008 - 12:06
Project:DB Maintenance
Version:6.x-2.0-beta2
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

I can't use this module because for each table I selected, when I execute /admin/settings/db_maintenance, Drupal says "Database tables optimized", but When I check table watchdog in phpmyadmin, I can see it has not been optimized at all.

If I check DB_maintenance log, for each table I selected it says :

  • "Optimized tables in Drupal database: dp_cache, dp_watchdog"
  • "dp_watchdog table in Drupal database was configured to be optimized but does not exist."

    Of course, theses tables exist, as DB maintenance retrieves them from my database.

    Thanks for support

  • #1

    jerome72 - November 26, 2008 - 14:27
    Assigned to:jerome72» Anonymous

    #2

    jgraham - November 26, 2008 - 17:44

    I think I know what the issue is, are you using table prefixes?

    #3

    jerome72 - January 21, 2009 - 14:09

    Hi jgraham,

    Thanks for the reply, sorry to be so late!

    Yes I do use table prefixes, is it a problem ?

    #4

    Liliplanet - February 1, 2009 - 21:47

    Hi,

    I seem to be having the same problem. Have selected the tables to run daily, and even if I do it manually, it has not optimized in phpmyadmin .. (:

    Yes, also use table prefixes : drupal_

    Is that perhaps what is causing this please?

    Look forward to any reply.
    Lilian

    #5

    Liliplanet - March 31, 2009 - 07:59

    Hi,

    I updated to latest version, but still receive error logs:

    eg. drupal_views_object_cache table in Drupal database was configured to be optimized but does not exist

    I do use a table prefix : drupal_

    Is there a way to fix this please?

    Look forward to any reply and thank you for your great module.

    Lilian

    #6

    memenoje - June 24, 2009 - 08:35

    When I use database tables without prefix, All tables Optimized OK, but with using any tables prefix for not !!!

    After manually or by cron optimized Dupal says Database tables optimized, but look in Phpadmin optimized no tables.

    #7

    Liliplanet - July 15, 2009 - 10:58

    Any news please? as this is a much needed module ..

    drupal_views_object_cache table in Drupal database was configured to be optimized but does not exist

    Thanks so much!

    #8

    marcus0263 - July 18, 2009 - 16:36

    Yep, having the same issue, example -

    drupal_wlw_blogapi_files table in Drupal database was configured to be optimized but does not exist.,
    drupal_wlw_blogapi_files table in Drupal database was configured to be optimized but does not exist.

    #9

    spamsammy - August 6, 2009 - 13:48
    Version:6.x-1.1» 6.x-2.0-beta2
    Component:Miscellaneous» Code

    I've figured out the issue. If I can figure out how to post a .patch file I will. Here is the offending code section:

    in db_mainenance.module line 155-165

        $config_tables = variable_get('db_maintenance_table_list_'. $db, NULL);
        // Only proceed if tables are selected for this database.
        if (is_array($config_tables) && count($config_tables) > 0) {
          $db_name = $db == 'default' ? 'Drupal' : $db;
          while (list(, $table_name) = each($config_tables)) {
            // Set the database to query.
            $previous = db_set_active($db);
            if (db_table_exists($table_name)) {
              if (_db_maintenance_determine_software() == 'mysql') {
                $result = db_query('OPTIMIZE TABLE %s', $table_name);
                $status = db_fetch_array($result);

    When you are using a drupal database prefix, the code calls 'db_table_exists' with the prefix included (i.e db_table_exists("myprefix_node" ). The correct syntax for this call is to use the raw drupal database name (i.e. db_table_exists("node") )

    The code below needs to be added directly before the _db_maintenance_determine_software call:

    // Setup for database exists check...have to strip out $db_prefix due to db_table_exists expecting non prefixed tablenames.
    global $db_prefix;
    if (strlen($db_prefix)>0) {
    //database has a prefix
    $table_check_name = str_replace($db_prefix,'',$table_name);
    }
                    if (db_table_exists($table_check_name)) {

    So the final code should look like the following:

        $config_tables = variable_get('db_maintenance_table_list_'. $db, NULL);
        // Only proceed if tables are selected for this database.
        if (is_array($config_tables) && count($config_tables) > 0) {
          $db_name = $db == 'default' ? 'Drupal' : $db;
          while (list(, $table_name) = each($config_tables)) {
            // Set the database to query.
            $previous = db_set_active($db);
    // Setup for database exists check...have to strip out $db_prefix due to db_table_exists expecting non prefixed tablenames.
    global $db_prefix;
    if (strlen($db_prefix)>0) {
    //database has a prefix
    $table_check_name = str_replace($db_prefix,'',$table_name);
    }
            if (db_table_exists($table_check_name)) {
              if (_db_maintenance_determine_software() == 'mysql') {
                $result = db_query('OPTIMIZE TABLE %s', $table_name);
                $status = db_fetch_array($result);

    #10

    Kyle Skrinak - August 25, 2009 - 13:44

    I am experiencing the same issue, using db prefixes. I was hoping that spamsammy's patch would work but I'm still getting the same "does not exist" error message (btw, the table name referenced in the "does not exist" is the correct table name.)

     
     

    Drupal is a registered trademark of Dries Buytaert.