Skip to content

Commit 2034459

Browse files
committed
sqlite: Fix DataUse query
I used the wrong index for timestamp, causing update to fail. Broken when I added support for IPv6.
1 parent 8ab9442 commit 2034459

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

metadata_writer_inventory_conn.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ static int32_t md_inventory_execute_update_usage(struct md_writer_sqlite *mws,
292292
if (sqlite3_bind_int64(stmt, 1, mce->rx_bytes) ||
293293
sqlite3_bind_int64(stmt, 2, mce->tx_bytes) ||
294294
sqlite3_bind_int(stmt, 4, mce->network_address_family) ||
295-
sqlite3_bind_int64(stmt, 6, date_start)) {
295+
sqlite3_bind_int64(stmt, 7, date_start)) {
296296
META_PRINT_SYSLOG(mws->parent, LOG_ERR, "Failed to bind values to UPDATE usage query\n");
297297
return SQLITE_ERROR;
298298
}
@@ -319,6 +319,8 @@ static int32_t md_inventory_execute_update_usage(struct md_writer_sqlite *mws,
319319
}
320320
}
321321

322+
META_PRINT_SYSLOG(mws->parent, LOG_ERR, "Update query: %s\n", sqlite3_expanded_sql(stmt));
323+
322324
return sqlite3_step(stmt);
323325
}
324326

@@ -531,6 +533,8 @@ static uint8_t md_inventory_handle_usage_update(struct md_writer_sqlite *mws,
531533

532534
date_start = (uint64_t) timegm(&tm_tmp);
533535

536+
META_PRINT_SYSLOG(mws->parent, LOG_ERR, "DATE START %lu\n", date_start);
537+
534538
retval = md_inventory_execute_update_usage(mws, mce, date_start);
535539

536540
if (retval == SQLITE_DONE && sqlite3_changes(mws->db_handle)) {

0 commit comments

Comments
 (0)