Insert queries on the watchdog table fail for entries with data that exceeds the varchar lengths on particular fields - failing to insert the data into the table, as would be expected.
For example visiting the following url, and then clicking on a link will generate an error when the referer varchar limit is exceeded:
http://www.example.com/drupal/node?param001=1¶m002=2¶m003=3¶...
Amusingly it will then try and record another watchdog entry for that failed error, but it will also fail.
The following errors were generated in the error_log file:
PHP Warning: pg_query() [<a href='function.pg-query'>function.pg-query</a>]: Query failed: ERROR: value too long for type character varying(128) in /drupal/includes/database.pgsql.inc on line 155
PHP Warning: ERROR: value too long for type character varying(128)\nquery: INSERT INTO watchdog\n (uid, type, message, variables, severity, link, location, referer, hostname, timestamp)\n VALUES\n (79580, 'php', '%message in %file on line %line.', 'a:4:{s:6:"%error";s:7:"warning";s:8:"%message";s:132:"pg_query() [<a href=''function.pg-query''>function.pg-query</a>]: Query failed: ERROR: value too long for type character varying(128)";s:5:"%file";s:78:"/drupal/includes/database.pgsql.inc";s:5:"%line";i:155;}', 3, '', 'http://dev.example.com/drupal/www.example.com/www/node', 'http://dev.example.com/drupal/www.example.com/www/index.php?param001=1&param002=1&param003=3&param004=4&param005=5&param006=6&param007=7', '192.168.100.179', 1202361484) in /drupal/includes/database.pgsql.inc on line 176
The attached patch truncates the data to fit the fields. Alternatively one could change the varchars to text, or increase their lengths.
| Comment | File | Size | Author |
|---|---|---|---|
| dblog_watchdog_truncate.200802071620.patch | 868 bytes | triclops |
Comments
Comment #1
triclops commentederr, forgot to mention that to generate a failure on the referer field, the page you click on from a link like the one above must generate a message that gets logged by watchdog.
Comment #2
cburschkaCould be worse, it could loop and die. ;)
Why is the IP column 128 long? Does this have something to do with IPv6?
Comment #3
andypostsubstr() should be replaced by drupal_substr()
Suppose better backport #223298: Change {dblog}.type VARCHAR limit from 16 to 64
and referer column should be TEXT #107824: Convert {watchdog}.referer and {accesslog}.url from VARCHAR to TEXT
Comment #4
dave reidMarking as duplicate because this problem will be fixed in the two patches specified in #3.
Comment #5
verikami commentedsubscribing :-)
Comment #6
dave reidPlease subscribe to the two issues provided in #3. This is now a duplicate.
Comment #7
verikami commentedthx :-) I have just started D6 @ pg and there are so many errors...
I'm changing referer to txt & going to #107824: Convert {watchdog}.referer and {accesslog}.url from VARCHAR to TEXT
I thought issues from #3 are D7 specyfic