Skip to content

Commit a13d98a

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 412fc4e commit a13d98a

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
@@ -202,7 +202,11 @@ int db_sqlite_query(const db_con_t* _h, const db_key_t* _k, const db_op_t* _op,
202202
} else {
203203
/* need to fetch now the total number of rows in query
204204
* because later won't have the query string */
205-
ret = CON_PS_ROWS(_h) = db_sqlite_get_query_rows(_h, &count_str, _v, _n);
205+
ret = db_sqlite_get_query_rows(_h, &count_str, _v, _n);
206+
if (ret >= 0) {
207+
CON_PS_ROWS(_h) = ret;
208+
ret = 0;
209+
}
206210
}
207211
if( ret < 0 ){
208212
db_sqlite_free_result_internal(_h,*_r);
@@ -397,7 +401,11 @@ int db_sqlite_raw_query(const db_con_t* _h, const str* _s, db_res_t** _r)
397401
} else {
398402
/* need to fetch now the total number of rows in query
399403
* because later won't have the query string */
400-
ret = CON_PS_ROWS(_h) = db_sqlite_get_query_rows(_h, &count_str, NULL, 0);
404+
ret = db_sqlite_get_query_rows(_h, &count_str, NULL, 0);
405+
if (ret >= 0) {
406+
CON_PS_ROWS(_h) = ret;
407+
ret = 0;
408+
}
401409
}
402410
if( ret < 0 ){
403411
db_sqlite_free_result_internal(_h,*_r);

0 commit comments

Comments
 (0)