@@ -2049,10 +2049,10 @@ bool gravityDB_delFromTable(const enum gravity_list_type listtype, const cJSON*
20492049 return true;
20502050}
20512051
2052- static sqlite3_stmt * read_stmt = NULL ;
20532052bool gravityDB_readTable (const enum gravity_list_type listtype ,
20542053 const char * item , const char * * message ,
2055- const bool exact , const char * ids )
2054+ const bool exact , const char * ids ,
2055+ sqlite3_stmt * * read_stmt_p )
20562056{
20572057 if (gravity_db == NULL )
20582058 {
@@ -2208,7 +2208,8 @@ bool gravityDB_readTable(const enum gravity_list_type listtype,
22082208 }
22092209
22102210 // Prepare SQLite statement
2211- int rc = sqlite3_prepare_v2 (gravity_db , querystr , -1 , & read_stmt , NULL );
2211+ * read_stmt_p = NULL ;
2212+ int rc = sqlite3_prepare_v2 (gravity_db , querystr , -1 , read_stmt_p , NULL );
22122213 if ( rc != SQLITE_OK ){
22132214 * message = sqlite3_errmsg (gravity_db );
22142215 log_err ("gravityDB_readTable(%d => (%s)) - SQL error prepare (%i): %s => %s" ,
@@ -2220,27 +2221,29 @@ bool gravityDB_readTable(const enum gravity_list_type listtype,
22202221 }
22212222
22222223 // Bind item to prepared statement (if requested)
2223- int idx = sqlite3_bind_parameter_index (read_stmt , ":item" );
2224- if (idx > 0 && (rc = sqlite3_bind_text (read_stmt , idx , like_name , -1 , SQLITE_TRANSIENT )) != SQLITE_OK )
2224+ int idx = sqlite3_bind_parameter_index (* read_stmt_p , ":item" );
2225+ if (idx > 0 && (rc = sqlite3_bind_text (* read_stmt_p , idx , like_name , -1 , SQLITE_TRANSIENT )) != SQLITE_OK )
22252226 {
22262227 * message = sqlite3_errmsg (gravity_db );
22272228 log_err ("gravityDB_readTable(%d => (%s), %s): Failed to bind item (error %d) - %s" ,
22282229 listtype , type , like_name , rc , * message );
2229- sqlite3_finalize (read_stmt );
2230+ sqlite3_finalize (* read_stmt_p );
2231+ * read_stmt_p = NULL ;
22302232 if (!exact )
22312233 free (like_name );
22322234 free (querystr );
22332235 return false;
22342236 }
22352237
22362238 // Bind ids to prepared statement (if requested)
2237- idx = sqlite3_bind_parameter_index (read_stmt , ":ids" );
2238- if (idx > 0 && (rc = sqlite3_bind_text (read_stmt , idx , ids , -1 , SQLITE_STATIC )) != SQLITE_OK )
2239+ idx = sqlite3_bind_parameter_index (* read_stmt_p , ":ids" );
2240+ if (idx > 0 && (rc = sqlite3_bind_text (* read_stmt_p , idx , ids , -1 , SQLITE_STATIC )) != SQLITE_OK )
22392241 {
22402242 * message = sqlite3_errmsg (gravity_db );
22412243 log_err ("gravityDB_readTable(%d => (%s), %s): Failed to bind ids (error %d) - %s" ,
22422244 listtype , type , like_name , rc , * message );
2243- sqlite3_finalize (read_stmt );
2245+ sqlite3_finalize (* read_stmt_p );
2246+ * read_stmt_p = NULL ;
22442247 if (!exact )
22452248 free (like_name );
22462249 free (querystr );
@@ -2263,7 +2266,8 @@ bool gravityDB_readTable(const enum gravity_list_type listtype,
22632266 return true;
22642267}
22652268
2266- bool gravityDB_readTableGetRow (const enum gravity_list_type listtype , tablerow * row , const char * * message )
2269+ bool gravityDB_readTableGetRow (const enum gravity_list_type listtype , tablerow * row , const char * * message ,
2270+ sqlite3_stmt * read_stmt )
22672271{
22682272 // Perform step
22692273 const int rc = sqlite3_step (read_stmt );
@@ -2416,7 +2420,7 @@ bool gravityDB_readTableGetRow(const enum gravity_list_type listtype, tablerow *
24162420}
24172421
24182422// Finalize statement of a gravity database transaction
2419- void gravityDB_readTableFinalize (void )
2423+ void gravityDB_readTableFinalize (sqlite3_stmt * read_stmt )
24202424{
24212425 // Finalize statement
24222426 sqlite3_finalize (read_stmt );
0 commit comments