File tree Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Expand file tree Collapse file tree 1 file changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -362,20 +362,28 @@ pysqlite_statement_bind_parameters(pysqlite_state *state,
362
362
363
363
int pysqlite_statement_reset (pysqlite_Statement * self )
364
364
{
365
- int rc ;
365
+ sqlite3_stmt * stmt = self -> st ;
366
+ if (stmt == NULL || self -> in_use == 0 ) {
367
+ return SQLITE_OK ;
368
+ }
366
369
367
- rc = SQLITE_OK ;
370
+ #if SQLITE_VERSION_NUMBER > 3020000
371
+ /* Check if the statement has been run (that is, sqlite3_step() has been
372
+ * called at least once). Third parameter is non-zero in order to reset the
373
+ * run count. */
374
+ if (sqlite3_stmt_status (stmt , SQLITE_STMTSTATUS_RUN , 1 ) == 0 ) {
375
+ return SQLITE_OK ;
376
+ }
377
+ #endif
368
378
369
- if ( self -> in_use && self -> st ) {
370
- Py_BEGIN_ALLOW_THREADS
371
- rc = sqlite3_reset (self -> st );
372
- Py_END_ALLOW_THREADS
379
+ int rc ;
380
+ Py_BEGIN_ALLOW_THREADS
381
+ rc = sqlite3_reset (self -> st );
382
+ Py_END_ALLOW_THREADS
373
383
374
- if (rc == SQLITE_OK ) {
375
- self -> in_use = 0 ;
376
- }
384
+ if (rc == SQLITE_OK ) {
385
+ self -> in_use = 0 ;
377
386
}
378
-
379
387
return rc ;
380
388
}
381
389
You can’t perform that action at this time.
0 commit comments