Page 1 of 1

"value too long" in serendipity_suppress

Posted: Sun Mar 28, 2010 10:01 pm
by ads
I found the following error in my logfile:
2010-03-28 21:53:58 CEST ERROR: value too long for type character varying(255)
2010-03-28 21:53:58 CEST STATEMENT: INSERT INTO serendipity_suppress
(ip, last, scheme, host, port, path, query)
VALUES (
'xxx.xxx.xxx.xxx',
NOW(),
'http',
'suche.t-online.de',
'',
'/fast-cgi/tsc',
'portallanguage=de&dia=portal&suchraum=1&userlanguage=de&more=variante0x&moreold=variante0x&y=0&x=0&q=tischschmuck&device=html&classification=internet-tab_internet_std&mandant=toi&wo=&context=internet-tab&tpc=internet&ptl=std&adpage=3&www_start=20&www_num=10'
)
What is the reason for having the "query" column limited to 255 characters? In PostgreSQL (my database) there is no such limit. In MySQL this should be a column type with more than 255 chars.


I modified this column to "TEXT" in my database:

Code: Select all

ALTER TABLE serendipity_suppress ALTER COLUMN query TYPE TEXT;

Re: "value too long" in serendipity_suppress

Posted: Mon Mar 29, 2010 9:44 am
by garvinhicking
Hi!

The 255 char limit is more a table size/query speed issue... While your solution should work pretty fine, it also increases the overhead of every data row on the table, and very often longer URLs are from spammers and when large URLs would be displayed in the output of the plugin they could much impact the layout. I'm a bit undecissive whether to change this in the core s9y structure, or to leave it at only supporting "smaller" URLs...?

Regards,
GArvin

Re: "value too long" in serendipity_suppress

Posted: Mon Mar 29, 2010 12:30 pm
by ads
In PostgreSQL there is no difference in data types between VARCHAR(255) and VARCHAR(256) and VARCHAR(500).

I know that MySQL just throws away anything after the 255th byte ;-) and as usual PostgreSQL is more picky and throws an error, because the text does not fit into the column.

So one possible solution could be: just insert the first 255 bytes of the query string, cut them in PHP using the substr() function.

Re: "value too long" in serendipity_suppress

Posted: Tue Mar 30, 2010 12:47 pm
by garvinhicking
Hi!

A patch for the substr() truncation is committed:

Code: Select all

Index: include/functions.inc.php
===================================================================
--- include/functions.inc.php   (revision 2646)
+++ include/functions.inc.php   (working copy)
@@ -739,6 +739,8 @@

         $ts       = serendipity_db_get_interval('ts');
         $interval = serendipity_db_get_interval('interval', 900);
+
+        $url_parts['query'] = substr($url_parts['query'], 0, 255);

         $suppressq = "SELECT count(1)
                       FROM $serendipity[dbPrefix]suppress
Thanks!

Regards,
Garvin

Re: "value too long" in serendipity_suppress

Posted: Tue Mar 30, 2010 1:08 pm
by ads
Applied. Should work, it's simple.

A quick search in this file shows another function which uses the same functionality: serendipity_track_url()
Should'nt this one also get a substr() call?

Re: "value too long" in serendipity_suppress

Posted: Tue Mar 30, 2010 1:24 pm
by garvinhicking
Hi!

True that! Thanks for mentioning :)

Regards,
Garvin

Re: "value too long" in serendipity_suppress

Posted: Thu Apr 01, 2010 12:36 pm
by ads
Another table with the same problem: "serendipity_exits", the "query" column again.