Hi all,
I've a problem with reply attributes with postgresql module. I have 3 
records in database but radius fetches only first one. I think the 
problem in sql_fetch_row function:

   

>static int sql_fetch_row(SQLSOCK * sqlsocket, SQL_CONFIG *config) {
>
>       int records, i, len;
>       rlm_sql_postgres_sock *pg_sock = sqlsocket->conn;
>
>       sqlsocket->row = NULL;

     
May be here must be something like loop to fetch the rows one by one instead of this:


>if (pg_sock->cur_row >= PQntuples(pg_sock->result))
>               return 0;



Like:
        while( pg_sock->cur_row <= PQntuples(pg_sock->result)){and remaining code goes 
here}
return 0;

        

>free_result_row(pg_sock);
>
>       records = PQnfields(pg_sock->result);
>       pg_sock->num_fields = records;
>
>       if ((PQntuples(pg_sock->result) > 0) && (records > 0)) {
>               pg_sock->row = (char **)rad_malloc((records+1)*sizeof(char *));
>               memset(pg_sock->row, '\0', (records+1)*sizeof(char *));
>
>               for (i = 0; i < records; i++) {
>                       len = PQgetlength(pg_sock->result, pg_sock->cur_row, i);
>                       pg_sock->row[i] = (char *)rad_malloc(len+1);
>                       memset(pg_sock->row[i], '\0', len+1);
>                       strncpy(pg_sock->row[i], PQgetvalue(pg_sock->result, 
>pg_sock->cur_row,i),len);
>               }
>               pg_sock->cur_row++;
>               sqlsocket->row = pg_sock->row;
>               return 0;
>       } else {
>               return 0;
>       }
>}

Or I something misunderstood???


Best regards, Dinar


- 
List info/subscribe/unsubscribe? See http://www.freeradius.org/list/users.html

Reply via email to