Help Regarding SQL Counter

tnt at kalik.net tnt at kalik.net
Fri Dec 19 15:58:05 CET 2008


>sqlcounter_expand:  'SELECT SUM(AcctSessionTime) FROM radacct WHERE
>UserName='%{User-Name}''
>[noresetcounter] 	expand: SELECT SUM(AcctSessionTime) FROM radacct
>WHERE UserName='%{User-Name}' -> SELECT SUM(AcctSessionTime) FROM
>radacct WHERE UserName='jose'
>sqlcounter_expand:  '%{sql:SELECT SUM(AcctSessionTime) FROM radacct
>WHERE UserName='jose'}'
>[noresetcounter] sql_xlat
>[noresetcounter] 	expand: %{User-Name} -> jose
>[noresetcounter] sql_set_user escaped user --> 'jose'
>[noresetcounter] 	expand: SELECT SUM(AcctSessionTime) FROM radacct
>WHERE UserName='jose' -> SELECT SUM(AcctSessionTime) FROM radacct
>WHERE UserName='jose'
>rlm_sql (sql): Reserving sql socket id: 2
>[noresetcounter] row[0] returned NULL
>rlm_sql (sql): Released sql socket id: 2
>[noresetcounter] 	expand: %{sql:SELECT SUM(AcctSessionTime) FROM
>radacct WHERE UserName='jose'} ->
>rlm_sqlcounter: No integer found in string ""
>++[noresetcounter] returns noop

OK, I see the problem. As first aid change the query to:

SELECT COALESCE(SUM(AcctSessionTime) FROM radacct WHERE
>UserName='%{User-Name},0)

For some reason code doesn't treat null as 0.

Ivan Kalik
Kalik Informatika ISP




More information about the Freeradius-Users mailing list