Fix issue with stuck readings retrieval
@@ -1081,7 +1081,10 @@ unsigned long rowsCount;
// SQL - union of all the readings tables
string sql_cmd_base;
string sql_cmd_tmp;
- sql_cmd_base = " SELECT id, \"_assetcode_\" asset_code, reading, user_ts, ts FROM _dbname_._tablename_ WHERE id >= " + to_string(id) + " and id <= " + to_string(id) + " + " + to_string(blksize) + " ";
+ // Would like to add a LIMIT on each sub-query in the union all, however SQLITE
+ // does not support this. Note we can not use id + blocksize as this fail if we
+ // have holes in the id space
+ sql_cmd_base = " SELECT id, \"_assetcode_\" asset_code, reading, user_ts, ts FROM _dbname_._tablename_ WHERE id >= " + to_string(id) + " ";
ReadingsCatalogue *readCat = ReadingsCatalogue::getInstance();
sql_cmd_tmp = readCat->sqlConstructMultiDb(sql_cmd_base, asset_codes);
sql_cmd += sql_cmd_tmp;
