Table 'feeds.watchdog' doesn't exist query: INSERT INTO watchdog (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (1, 'locale', 'Parsed JavaScript file %file.', 'a:1:{s:5:\"%file\";s:14:\"misc/jquery.js\";}', 5, '', 'http://localhost/feed/admin/build/modules', 'http://localhost/feed/admin/build/modules', '127.0.0.1', 1239298936) in C:\root\feed\modules\dblog\dblog.module on line 144.

Comments

Anonymous’s picture

When did you see this and what module(s) were you installing?

haojiang’s picture

drupal native database log

Anonymous’s picture

Priority: Normal » Minor

I can understand how this would happen. The logging becomes active before the DB table is created and so the first logging query fails. Did the watchdog table get created?

haojiang’s picture

no , i can't see a table name "watchdog" in phpmyadmin

Anonymous’s picture

Title: feeds.watchdog' » Watchdog table not installed when watchdog module enabled.
Priority: Minor » Critical

So to get rid of the errors, deactivate the module then go to the Uninstall tab and uninstall the module. You will see errors about the table not being available. After this you can try the activate operation again but my guess it will still fail to create the table. Hmm... me wonders if there is a simpletest test for this?

If the creation of the watchdog table fails again, below is the SQL to create it.

-- 
-- Database: `drupal`
-- 

-- --------------------------------------------------------

-- 
-- Table structure for table `watchdog`
-- 

CREATE TABLE `watchdog` (
  `wid` int(11) NOT NULL auto_increment,
  `uid` int(11) NOT NULL default '0',
  `type` varchar(16) NOT NULL default '',
  `message` longtext NOT NULL,
  `variables` longtext NOT NULL,
  `severity` tinyint(3) unsigned NOT NULL default '0',
  `link` varchar(255) NOT NULL default '',
  `location` text NOT NULL,
  `referer` varchar(128) NOT NULL default '',
  `hostname` varchar(128) NOT NULL default '',
  `timestamp` int(11) NOT NULL default '0',
  PRIMARY KEY  (`wid`),
  KEY `type` (`type`)
) DEFAULT CHARSET=utf8;
haojiang’s picture

thx a lot ,fixed

Anonymous’s picture

I don't know how fixed this issue is. Let's leave it open so I or someone else can look at a watchdog install. It's the default for Drupal to install the watchdog module so I don't know why you didn't have it to begin with.

haojiang’s picture

but after i create the table as the above said so , nothing error show up again and seems that everything goes all right

haojiang’s picture

but after i create the table as the above said so , nothing error show up again and seems that everything goes all right

Anonymous’s picture

But why didn't the table create normally is the issue.

mitchell’s picture

Version: 6.10 » 6.16

Having same issue.

mitchell’s picture

Version: 6.16 » 6.10

Nevermind. Stupid mistake.

cmrsf1’s picture

Version: 6.10 » 5.7
StatusFileSize
new21.58 KB

PLEASE DISREGARD. I WAS ABLE TO PLOD ON THRU THIS AND NO LONGER GET AN ERROR MESSAGE...

I was receiving the error message that watchdog was not installed so I used the syntax, above, to create a new table in my phpadmin. Then, when the loading the home page, I got the message:
Access Denied
user warning: Unknown column 'referer' in 'field list' query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'access denied', 'node', 1, '', 'http://mysite.com/drupal/', 'http://mysite.com/drupal/admin/logs/watchdog?sort=asc&order=User', '174.28.141.124', 1278742535) in /hsphere/local/home/cmrsf1/mysite.com/drupal/includes/database.mysql.inc on line 172.
******************
Line 172 says: trigger_error(check_plain(mysql_error($active_db) ."\nquery: ". $query), E_USER_WARNING);
return FALSE;
so I guess that the error I'm receiving is because of this directive from line 172.
******************
I went back into my database and saw that I had mis-spelled referer (as referrer). I corrected that and saved it and then re-loaded the home page. I now have the error:
Access Denied:
user warning: Duplicate entry '0' for key 1 query: INSERT INTO watchdog (uid, type, message, severity, link, location, referer, hostname, timestamp) VALUES (0, 'access denied', 'logout', 1, '', 'http://mysite.com/drupal/logout', 'http://mysite.com/drupal/admin/logs/watchdog?sort=asc&order=User', '174.28.141.124', 1278749987) in /hsphere/local/home/cmrsf1/mysite.com/drupal/includes/database.mysql.inc on line 172.

I have attached a gif file of the way my table actually looks if that helps. I am a rookie at working in phpmyadmin and am nervous when making any changes in there...

Thanks!

drumm’s picture

Category: bug » support
Status: Active » Closed (works as designed)

modules/system/system.install creates this table. If for some reason you don't have the table, something went wrong on installation. If you manually deleted the table, we can't anticipate that, don't do it. We even spell referer correctly.

It is the last table to be created, vocabulary_node_types before that. Would be interesting to know if that was created.

pizangdesain’s picture

StatusFileSize
new178.46 KB

same issue with Drupal 6
when enabling module came fail...

redcell’s picture

Component: base system » install system
Category: support » bug
Status: Closed (works as designed) » Active
StatusFileSize
new65.04 KB

I just tried a fresh installation of:
Drupal 7.15
FreeBSD 9.x-RELEASE (x64)
SQLite
PHP 5.4.5
Apache 2.2.22
Type: minimal installation

I can confirm that on the "Install Profile" page of the installer, I get the error "SQLSTATE[HY000]: General error: 1 no such table: watchdog" and am unable to continue. I'll have to manually create the table.

I also get the "Warning: Illegal string offset 'field' in UpdateQuery_sqlite->removeFieldsInCondition()" warning that I will manually patch.

I suspect that this issue only occurs with the minimal installation, because I did a normal installation a couple of weeks ago on the same system that work ok. There were still a handful of warnings and notices that required manual patches, but at least I could get through the installer.

redcell’s picture

Version: 5.7 » 7.15
Status: Active » Needs review

This workaround created the table manually.

sqlite3 <dbname>
CREATE TABLE watchdog (
wid INTEGER PRIMARY KEY AUTOINCREMENT,
uid INTEGER NOT NULL DEFAULT 0,
type VARCHAR(64) NOT NULL DEFAULT '',
message TEXT NOT NULL,
variables BLOB NOT NULL,
severity INTEGER NOT NULL CHECK (severity>= 0) DEFAULT 0,
link VARCHAR(255) NULL DEFAULT '',
location TEXT NOT NULL,
referer TEXT NULL DEFAULT NULL,
hostname VARCHAR(128) NOT NULL DEFAULT '',
timestamp INTEGER NOT NULL DEFAULT 0
);
CREATE INDEX watchdog_type ON watchdog (type);
CREATE INDEX watchdog_uid ON watchdog (uid);
aspilicious’s picture

Priority: Critical » Normal

I don't think this is the case in drupal7.
Why pushing this to drupal 7?

Leeteq’s picture

Category: bug » support
Status: Needs review » Postponed (maintainer needs more info)

Lets treat this as a support request first, until we have more confirmations of such a problem.
(should move it unto 7.x-dev, too, if no confirmations are posted within a couple of days)

#16/@redcell: Have you try installing again in the same environment? Is the behaviour consistent? Any indication of running out of memory or the like just before the last table was created? (how much memory is reported on the status report page?)

Anonymous’s picture

My theory on the issue is that dblog_watchdog hook implementation is firing before the watchdog table exists for some obscure reason. To resolve that issue dblog_watchdog() should check db_table_exists() before inserting into it.

Taxoman’s picture

Version: 7.15 » 7.x-dev
Letharion’s picture

@#20 the idea is that the table should always be there, as it's created by the system module.
That said, I also have stumbled upon this problem several times recently. Could be memory constraints failing to create the tables, but haven't seen any errors during install.

Anonymous’s picture

I know it's supposed to exist already. The unknown here is what is causing the dblog_watchdog hook implementation to execute before the table is created. Something is causing an out-of-order sequence of events; what is that something? We don't know but perhaps someone experiencing the problem could debug it by adding the output of debug_backtrace() to the message in dblog_watchdog(). Something like
drupal_set_message('<pre>'.print_r(debug_backtrace(),true).'</pre>'); We can't use devel because we won't be able to get it installed.

Letharion’s picture

@#23 that's not what I said, but regardless, it seems my statement was wrong anyway. In D7, the dblog module takes care of creating the table, which implies your assessment is correct.

A backtrace on the error should be very helpful in nailing down what goes wrong.

jonhattan’s picture

Status: Postponed (maintainer needs more info) » Fixed
Letharion’s picture

Status: Fixed » Postponed (maintainer needs more info)

#1542186: PHP 5.4 "Illegal string offset" warning when install is a sqlite specific problem. I don't see how this issue has anything to do with it.

jonhattan’s picture

Status: Postponed (maintainer needs more info) » Fixed

It's sqlite specific since #16.

Anonymous’s picture

Category: support » bug
Status: Fixed » Active

The issue of dblog_watchdog firing before the table exists is not fixed. The dblog_watchdog function needs to determine if the table exists before trying to insert into it. I agree that the sqlite issue may have caused the function to execute before the table exists, it is not though a fix for the issue since the issue could still occur for some other reason.

damien tournoud’s picture

Status: Active » Closed (fixed)

Please don't hijack an old bug report.

We should catch and ignore any PDO exception trigger in dblog_watchdog(). I just opened #1784548: DB Log is missing watchdog table after enabling - Need to catch and ignore exceptions thrown in dblog_watchdog().

pingwin4eg’s picture

Component: install system » dblog.module
Status: Closed (fixed) » Active

Wait!
I've stumbled across this issue for a 2 days trying to create my custom installation profile. (Then I found out that the problem exists even if uninstalling Dblog module and installing it again.)
And the problem is not in DB driver (I work with MySQL) and {watchdog} table is really not created by the moment when error occurs.

So here's how it is when installing Dblog.
Function module_enable contains such code:

function module_enable(...) {
  ...
  db_update('system')->fields(array('status' => 1))->condition('type', 'module')->condition('name', $module)->execute();
  // Refresh the module list to include it.
  system_list_reset();
  module_list(TRUE);
  module_implements('', FALSE, TRUE);
  _system_update_bootstrap_status();
  // So the Dblog 'officialy' activated by now.

  registry_update(); // And here is where I've catched error.
  ...
  // Now install the module if necessary.
  if (drupal_get_installed_schema_version($module, TRUE) == SCHEMA_UNINSTALLED) {
    drupal_install_schema($module);
    ...
  }
  ...
}

Function registry_update() calls
drupal_alter('registry_files', $files, $modules) which in turn calls
ctools_registry_files_alter(&$files, $indexed_modules) which (in case of some errors - my case) calls
watchdog('ctools', '...nonexistent file for class handler', $args) which calls
foreach (module_implements('watchdog') as $module) {module_invoke($module, 'watchdog', $log_entry);} and here Dblog is in list of modules but without schema installed yet.

Yes Ctools in my case installed before Dblog but it could be any other module to make some alters and to send the errors.
So I think @earnie is right, dblog_watchdog() should check db_table_exists().

elijah lynn’s picture

Status: Active » Needs review
StatusFileSize
new1.59 KB

Here is a patch against dblog (7.22) to add the if(db_table_exists('watchdog')) to dblog_watchdog(). It now creates the table on install and performs as expected in my brief testing.

zayed-jat’s picture

hi, I run the installer of drupal 7.23 and not found the table watchdog.
now i will try the patch

thanx

deetergp’s picture

I just wanted to add that I was experiencing this very same issue in 7.24, in a custom distribution and the patch in post #31 applied correctly and resolved my issue. I was able to continue on with the install and can hopefully now start building SimpleTests for my distribution and custom modules.

Thanks, Elijah!

mimes’s picture

Elijah Lynn's patch in comment #31 also works with Drupal 7.24 and 7.x.

ianthomas_uk’s picture

Issue summary: View changes
Status: Needs review » Closed (duplicate)

#29 still applies. If you want to see this fixed, help out on #1784548: DB Log is missing watchdog table after enabling - Need to catch and ignore exceptions thrown in dblog_watchdog(). If you think this issue should be reopened, then please explain how it differs from #1784548.

Marking this as a duplicate of #1542186: PHP 5.4 "Illegal string offset" warning when install and / or #1784548.

dmitry.kazberovich’s picture

Updated the patch

deanflory’s picture

I'm just running into this error on D7.42 after disabling and uninstalling the following modules which deleted my watchdog table (as I guess it should):

  • Database Logging (dblog)
  • DBLog Pager
  • Statistics Blocks
  • Page Not Found Reports
  • Tiny-IDS

When I reload the Modules page and attempt to enable Database Logging I get this nasty error:

PDOException: SQLSTATE[XXXXX]: Base table or view not found: XXXX Table 'XXXXXXX.watchdog' doesn't exist: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => ctools [:db_insert_placeholder_2] => Plugin @plugin of plugin type @owner:@type points to nonexistent file @file for class handler @class. [:db_insert_placeholder_3] => a:5:{s:7:"@plugin";s:8:"views_ui";s:6:"@owner";s:6:"ctools";s:5:"@type";s:9:"export_ui";s:5:"@file";s:74:"sites/all/modules/views/plugins/export_ui/views_docket_export_ui.class.php";s:6:"@class";s:7:"handler";} [:db_insert_placeholder_4] => 5 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => XXXXXXXXXXXXX/admin/modules/list/confirm [:db_insert_placeholder_7] => XXXXXXXXXXXXXXXX/admin/modules [:db_insert_placeholder_8] => XXXXXXXXXXXXXX [:db_insert_placeholder_9] => XXXXXXXXXXX ) in dblog_watchdog() (line 163 of /.../modules/dblog/dblog.module).

And again, when I reloaded the Modules page and only Database Logging seems to have installed, or partially, I get this error when trying to disable it:

PDOException: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'XXXXXXXX.watchdog' doesn't exist: INSERT INTO {watchdog} (uid, type, message, variables, severity, link, location, referer, hostname, timestamp) VALUES (:db_insert_placeholder_0, :db_insert_placeholder_1, :db_insert_placeholder_2, :db_insert_placeholder_3, :db_insert_placeholder_4, :db_insert_placeholder_5, :db_insert_placeholder_6, :db_insert_placeholder_7, :db_insert_placeholder_8, :db_insert_placeholder_9); Array ( [:db_insert_placeholder_0] => 1 [:db_insert_placeholder_1] => system [:db_insert_placeholder_2] => %module module disabled. [:db_insert_placeholder_3] => a:1:{s:7:"%module";s:5:"dblog";} [:db_insert_placeholder_4] => 6 [:db_insert_placeholder_5] => [:db_insert_placeholder_6] => XXXXXXXXXXXX/admin/modules/list/confirm [:db_insert_placeholder_7] => XXXXXXXXXXXX/admin/modules [:db_insert_placeholder_8] => XXXXXXXXXXX [:db_insert_placeholder_9] => XXXXXXXXXXXX ) in dblog_watchdog() (line 163 of /.../modules/dblog/dblog.module).

So, disabling and uninstalling the dblog module deletes the watchdog table from the db, but re-enabling it doesn't create the watchdog table...or it fails/errors before it's created. Not cool. I can't imagine how this has gone unfixed for an entire version cycle.

The patch "drupal-dblog-watchdog-table-not-created-install-429188-32.patch" in #36 fixed the problem for me. Thanks!