Long mysql queries in sqlcounter get truncated.

Gunther freeradius at caribsms.com
Thu Mar 2 05:49:05 CET 2006


Had the same trouble with long SQL queries. It seems the RADIUS standard
only allows
up to 253 characters or so. I ended up modifying my table column names to a
shorter name.
Not nice, but it works. I also 'merged' some tables information to shorten
the queries.

Initially I changed the max string length within the code, but the main
disadvantage
is that every upgrade you have to do the same. Now I use 100% unmodified
FreeRadius
code and the upgrade to 1.1.0 went without any problems.

Gunther

> -----Original Message-----
> From: 
> freeradius-users-bounces+freeradius=caribsms.com at lists.freerad
> ius.org 
> [mailto:freeradius-users-bounces+freeradius=caribsms.com at lists
> .freeradius.org] On Behalf Of Luis Zarrabeitia
> Sent: Wednesday, March 01, 2006 9:52 PM
> To: freeradius-users at lists.freeradius.org
> Subject: Long mysql queries in sqlcounter get truncated.
> 
> 
> Hi. I'm trying to configure a freeradius 1.1.0 [Debian 
> testing] server with mysql backend, and I'm having trouble 
> with the "sql counter" module. When trying to customize the 
> query to obtain the remaining time (the default query does 
> not reflect my enviroment), I find mysql syntax errors. 
> Apparently, it is not processing the full query.
> 
> Output of "freeradius -X". Note that I changed the actual 
> query for brevity, as anything [valid] that I put in there 
> seem to get me the same result.
> 
> -------
> rlm_sql_mysql: query:  SELECT <pretty big and boring query> 
> AND UNIX_TIMESTAMP(AcctStartT
> rlm_sql_mysql: MYSQL check_error: 1064 received rlm_sql 
> (sql): database query error, SELECT <pretty big and boring query> AND
> UNIX_TIMESTAMP(AcctStartT: You have an error in your SQL 
> syntax; check the manual that corresponds to your MySQL 
> server version for the right syntax to use near '' at line 1 
> rlm_sql (sql): Released sql socket id: 2
> radius_xlat:  'ime)+AcctSessionTime>'1138766400''
> ---------
> 
> (the original query on my radiusd.conf file is: 
> SELECT <pretty big and boring query> AND
> UNIX_TIMESTAMP(AcctStartTime)+AcctSessionTime>'%b')
> 
> Notice how the first line in the log is truncated to the "T" 
> of "AcctStartT", that is, the first 251 characters of the 
> query after applying the parameter expansion (%b, %k). (the 
> length is always 251, regardless of the query - if I strip 
> spaces from it I can fit more, but it is still not enough). 
> Also notice how the end of the query is continued on the next 
> "radius_xlat:" line.
> 
> The query works perfectly with the command line mysql client 
> (after %b and %k expansions).
> 
> Glancing at the source I see a line "#define MAX_QUERY_LEN 
> 1024" in rlm_sqlcounter.c, far greater than 251, wich makes 
> me doubt that the problem lies in that size, and seems to 
> confirm my suspicion that it might be a configuration 
> parameter that I'm missing somewhere.
> 
> Can you suggest either a solution or a workaround? (other 
> than storing the query in a mysql5.0 'stored procedure', 
> because I do not wish to add Debian Unstable to my production servers)
> 
> Regards,
> 
>           Zarrabeitia
> -
> List info/subscribe/unsubscribe? See 
> http://www.freeradius.org/list/users.html





More information about the Freeradius-Users mailing list