Long mysql queries in sqlcounter get truncated.
Luis Zarrabeitia
kyrie at uh.cu
Thu Mar 2 02:51:41 CET 2006
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
More information about the Freeradius-Users
mailing list