Skip to content

Commit 04a7867

Browse files
committed
db_sqlite: Fix interaction with sql_cacher
The .query API endpoint in db/db.h is meant to return 0 on success, yet the current implementation in db_sqlite was returning "number of rows" on success, leading to: ERROR:sql_cacher:load_entire_table: Failure to issue query to SQL DB... ERROR:sql_cacher:cache_init_load: Failed to cache the entire table... (cherry picked from commit 5abc95a)
1 parent 7f4fa3a commit 04a7867

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

modules/db_sqlite/dbase.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,11 @@ int db_sqlite_query(const db_con_t* _h, const db_key_t* _k, const db_op_t* _op,
192192
} else {
193193
/* need to fetch now the total number of rows in query
194194
* because later won't have the query string */
195-
ret = CON_PS_ROWS(_h) = db_sqlite_get_query_rows(_h, &count_str, _v, _n);
195+
ret = db_sqlite_get_query_rows(_h, &count_str, _v, _n);
196+
if (ret >= 0) {
197+
CON_PS_ROWS(_h) = ret;
198+
ret = 0;
199+
}
196200
}
197201
if( ret < 0 && _r ){
198202
db_sqlite_free_result_internal(_h,*_r);
@@ -384,7 +388,11 @@ int db_sqlite_raw_query(const db_con_t* _h, const str* _s, db_res_t** _r)
384388
} else {
385389
/* need to fetch now the total number of rows in query
386390
* because later won't have the query string */
387-
ret = CON_PS_ROWS(_h) = db_sqlite_get_query_rows(_h, &count_str, NULL, 0);
391+
ret = db_sqlite_get_query_rows(_h, &count_str, NULL, 0);
392+
if (ret >= 0) {
393+
CON_PS_ROWS(_h) = ret;
394+
ret = 0;
395+
}
388396
}
389397
if( ret < 0 && _r ){
390398
db_sqlite_free_result_internal(_h,*_r);

0 commit comments

Comments
 (0)