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&param002=2&param003=3&para...

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, &#039;php&#039;, &#039;%message in %file on line %line.&#039;, &#039;a:4:{s:6:&quot;%error&quot;;s:7:&quot;warning&quot;;s:8:&quot;%message&quot;;s:132:&quot;pg_query() [&lt;a href=&#039;&#039;function.pg-query&#039;&#039;&gt;function.pg-query&lt;/a&gt;]: Query failed: ERROR:  value too long for type character varying(128)&quot;;s:5:&quot;%file&quot;;s:78:&quot;/drupal/includes/database.pgsql.inc&quot;;s:5:&quot;%line&quot;;i:155;}&#039;, 3, &#039;&#039;, &#039;http://dev.example.com/drupal/www.example.com/www/node&#039;, &#039;http://dev.example.com/drupal/www.example.com/www/index.php?param001=1&amp;param002=1&amp;param003=3&amp;param004=4&amp;param005=5&amp;param006=6&amp;param007=7&#039;, &#039;192.168.100.179&#039;, 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.

Comments

triclops’s picture

err, 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.

cburschka’s picture

Amusingly it will then try and record another watchdog entry for that failed error, but it will also fail.

Could be worse, it could loop and die. ;)

Why is the IP column 128 long? Does this have something to do with IPv6?

andypost’s picture

Status: Needs review » Needs work

substr() 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

dave reid’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs work » Closed (duplicate)

Marking as duplicate because this problem will be fixed in the two patches specified in #3.

verikami’s picture

Version: 7.x-dev » 6.x-dev
Status: Closed (duplicate) » Needs work

subscribing :-)

dave reid’s picture

Version: 6.x-dev » 7.x-dev
Status: Needs work » Closed (duplicate)

Please subscribe to the two issues provided in #3. This is now a duplicate.

verikami’s picture

thx :-) 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