Skip to content

Commit 8ab9442

Browse files
committed
sqlite: Update GPS data
We forgot to update the GPS table when node, session or timestamp was updated. Reason this error has not been discovered for, is that in all cases so far all this information is present when we get as far as submitting GPS data.
1 parent 1ef3cb1 commit 8ab9442

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

metadata_writer_sqlite.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,7 @@ static int md_sqlite_configure(struct md_writer_sqlite *mws,
480480

481481
if (mws->node_id && (md_sqlite_update_nodeid_db(mws, UPDATE_EVENT_ID) ||
482482
md_sqlite_update_nodeid_db(mws, UPDATE_UPDATES_ID) ||
483+
md_sqlite_update_nodeid_db(mws, UPDATE_GPS_ID) ||
483484
md_sqlite_update_nodeid_db(mws, UPDATE_SYSTEM_ID))) {
484485
META_PRINT_SYSLOG(mws->parent, LOG_ERR, "Could not update old ements with id 0\n");
485486
return RETVAL_FAILURE;
@@ -615,6 +616,8 @@ static uint8_t md_sqlite_check_valid_tstamp(struct md_writer_sqlite *mws)
615616
md_sqlite_update_timestamp_db(mws, UPDATE_UPDATES_TSTAMP,
616617
mws->orig_boot_time, real_boot_time) ||
617618
md_sqlite_update_timestamp_db(mws, UPDATE_SYSTEM_TSTAMP,
619+
mws->orig_boot_time, real_boot_time) ||
620+
md_sqlite_update_timestamp_db(mws, UPDATE_GPS_TSTAMP,
618621
mws->orig_boot_time, real_boot_time)) {
619622
META_PRINT_SYSLOG(mws->parent, LOG_ERR, "Could not update tstamp in database\n");
620623
return RETVAL_FAILURE;
@@ -636,6 +639,7 @@ static uint8_t md_sqlite_check_session_id(struct md_writer_sqlite *mws)
636639

637640
if (md_sqlite_update_session_id_db(mws, UPDATE_EVENT_SESSION_ID) ||
638641
md_sqlite_update_session_id_db(mws, UPDATE_UPDATES_SESSION_ID) ||
642+
md_sqlite_update_session_id_db(mws, UPDATE_GPS_SESSION_ID) ||
639643
md_sqlite_update_session_id_db(mws, UPDATE_SYSTEM_SESSION_ID)) {
640644
META_PRINT_SYSLOG(mws->parent, LOG_ERR, "Could not update session id in database\n");
641645
mws->timeout_handle->intvl = DEFAULT_TIMEOUT;
@@ -764,6 +768,7 @@ static void md_sqlite_handle_timeout(void *ptr)
764768

765769
if (md_sqlite_update_nodeid_db(mws, UPDATE_EVENT_ID) ||
766770
md_sqlite_update_nodeid_db(mws, UPDATE_UPDATES_ID) ||
771+
md_sqlite_update_nodeid_db(mws, UPDATE_GPS_ID) ||
767772
md_sqlite_update_nodeid_db(mws, UPDATE_SYSTEM_ID)) {
768773
META_PRINT_SYSLOG(mws->parent, LOG_ERR, "Could not update node id in database\n");
769774

metadata_writer_sqlite.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@
201201
"NodeId=? "\
202202
"WHERE NodeId=0"
203203

204+
#define UPDATE_GPS_ID "UPDATE GpsUpdate SET " \
205+
"NodeId=? "\
206+
"WHERE NodeId=0"
207+
204208
#define UPDATE_EVENT_TSTAMP "UPDATE NetworkEvent SET " \
205209
"Timestamp = (Timestamp - ?) + ? "\
206210
"WHERE Timestamp < ?"
@@ -213,6 +217,10 @@
213217
"Timestamp = (Timestamp - ?) + ? "\
214218
"WHERE Timestamp < ?"
215219

220+
#define UPDATE_GPS_TSTAMP "UPDATE GpsUpdate SET " \
221+
"Timestamp = (Timestamp - ?) + ? "\
222+
"WHERE Timestamp < ?"
223+
216224
#define UPDATE_EVENT_SESSION_ID "UPDATE NetworkEvent SET "\
217225
"SessionId=?,SessionIdMultip=? "\
218226
"WHERE SessionId = 0"
@@ -225,6 +233,10 @@
225233
"BootCount=?,BootMultiplier=? "\
226234
"WHERE BootCount = 0"
227235

236+
#define UPDATE_GPS_SESSION_ID "UPDATE GpsUpdate SET "\
237+
"BootCount=?,BootMultiplier=? "\
238+
"WHERE BootCount = 0"
239+
228240
#define DELETE_TABLE "DELETE FROM NetworkEvent"
229241

230242
#define DELETE_NW_UPDATE "DELETE FROM NetworkUpdates WHERE Timestamp < ?"

0 commit comments

Comments
 (0)