Navigation


Changeset 292:a77ed0e30ac9 in freeDiameter


Ignore:
Timestamp:
May 10, 2010, 2:26:42 PM (14 years ago)
Author:
Sebastien Decugis <sdecugis@nict.go.jp>
Branch:
default
Phase:
public
Message:

Fix non-working timestamp field

File:
1 edited

Legend:

Unmodified
Added
Removed
  • extensions/app_acct/acct_db.c

    r285 r292  
    158158       
    159159        if (acct_config->tsfield) {
    160                 ADD_EXTEND("'now', ");
     160                ADD_EXTEND("$%d, ", ++idx);
    161161        }
    162162       
    163163        for (li = emptyrecords.all.next; li != &emptyrecords.all; li = li->next) {
    164164                struct acct_record_item * i = (struct acct_record_item *)(li->o);
    165                 idx += 1;
    166                 ADD_EXTEND("$%d::%s", idx, diam2db_types_mapping[i->param->avptype]);
     165                ADD_EXTEND("$%d::%s", ++idx, diam2db_types_mapping[i->param->avptype]);
    167166               
    168167                if (li->next != &emptyrecords.all) {
     
    207206        int      *val_isbin;
    208207        int       idx = 0;
     208        int       size = 0;
    209209        PGresult *res;
    210210        struct fd_list *li;
     
    224224        }
    225225       
     226        size =  acct_config->tsfield ? records->nball + 1 : records->nball;
     227       
    226228        /* Alloc the arrays of parameters */
    227         CHECK_MALLOC( val       = calloc(records->nball, sizeof(const char *)) );
    228         CHECK_MALLOC( val_len   = calloc(records->nball, sizeof(const int)) );
    229         CHECK_MALLOC( val_isbin = calloc(records->nball, sizeof(const int)) );
     229        CHECK_MALLOC( val       = calloc(size, sizeof(const char *)) );
     230        CHECK_MALLOC( val_len   = calloc(size, sizeof(const int)) );
     231        CHECK_MALLOC( val_isbin = calloc(size, sizeof(const int)) );
     232       
     233        if (acct_config->tsfield) {
     234                val[idx] = "now";
     235                val_len[idx] = 3;
     236                val_isbin[idx] = 0;
     237                idx++;
     238        }
    230239       
    231240        /* Now write all the map'd records in these arrays */
     
    265274       
    266275        /* OK, now execute the SQL statement */
    267         res = PQexecPrepared(conn, stmt, records->nball, (const char * const *)val, val_len, val_isbin, 1 /* We actually don't care here */);
     276        res = PQexecPrepared(conn, stmt, size, (const char * const *)val, val_len, val_isbin, 1 /* We actually don't care here */);
    268277       
    269278        /* Done with the parameters */
Note: See TracChangeset for help on using the changeset viewer.