@@ -106,11 +106,7 @@ cursor_clear(pysqlite_Cursor *self)
106
106
Py_CLEAR (self -> row_cast_map );
107
107
Py_CLEAR (self -> lastrowid );
108
108
Py_CLEAR (self -> row_factory );
109
- if (self -> statement ) {
110
- /* Reset the statement if the user has not closed the cursor */
111
- pysqlite_statement_reset (self -> statement );
112
- Py_CLEAR (self -> statement );
113
- }
109
+ Py_CLEAR (self -> statement );
114
110
Py_CLEAR (self -> next_row );
115
111
116
112
return 0 ;
@@ -124,6 +120,9 @@ cursor_dealloc(pysqlite_Cursor *self)
124
120
if (self -> in_weakreflist != NULL ) {
125
121
PyObject_ClearWeakRefs ((PyObject * )self );
126
122
}
123
+ if (self -> statement ) {
124
+ pysqlite_statement_reset (self -> statement );
125
+ }
127
126
tp -> tp_clear ((PyObject * )self );
128
127
tp -> tp_free (self );
129
128
Py_DECREF (tp );
@@ -528,20 +527,11 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
528
527
}
529
528
}
530
529
531
- if (self -> statement != NULL ) {
532
- /* There is an active statement */
533
- pysqlite_statement_reset (self -> statement );
534
- }
535
-
536
530
/* reset description and rowcount */
537
531
Py_INCREF (Py_None );
538
532
Py_SETREF (self -> description , Py_None );
539
533
self -> rowcount = 0L ;
540
534
541
- if (self -> statement ) {
542
- (void )pysqlite_statement_reset (self -> statement );
543
- }
544
-
545
535
PyObject * stmt = get_statement_from_cache (self , operation );
546
536
Py_XSETREF (self -> statement , (pysqlite_Statement * )stmt );
547
537
if (!self -> statement ) {
@@ -555,8 +545,6 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
555
545
goto error ;
556
546
}
557
547
}
558
-
559
- pysqlite_statement_reset (self -> statement );
560
548
pysqlite_statement_mark_dirty (self -> statement );
561
549
562
550
/* We start a transaction implicitly before a DML statement.
@@ -577,6 +565,7 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
577
565
break ;
578
566
}
579
567
568
+ pysqlite_statement_reset (self -> statement );
580
569
pysqlite_statement_mark_dirty (self -> statement );
581
570
582
571
pysqlite_statement_bind_parameters (state , self -> statement , parameters );
@@ -594,7 +583,6 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
594
583
PyErr_Clear ();
595
584
}
596
585
}
597
- (void )pysqlite_statement_reset (self -> statement );
598
586
_pysqlite_seterror (state , self -> connection -> db );
599
587
goto error ;
600
588
}
@@ -664,13 +652,9 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
664
652
if (self -> next_row == NULL )
665
653
goto error ;
666
654
} else if (rc == SQLITE_DONE && !multiple ) {
667
- pysqlite_statement_reset (self -> statement );
668
655
Py_CLEAR (self -> statement );
669
656
}
670
657
671
- if (multiple ) {
672
- pysqlite_statement_reset (self -> statement );
673
- }
674
658
Py_XDECREF (parameters );
675
659
}
676
660
@@ -837,10 +821,7 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self)
837
821
}
838
822
839
823
if (!self -> next_row ) {
840
- if (self -> statement ) {
841
- (void )pysqlite_statement_reset (self -> statement );
842
- Py_CLEAR (self -> statement );
843
- }
824
+ Py_CLEAR (self -> statement );
844
825
return NULL ;
845
826
}
846
827
@@ -862,12 +843,10 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self)
862
843
if (self -> statement ) {
863
844
rc = pysqlite_step (self -> statement -> st );
864
845
if (PyErr_Occurred ()) {
865
- (void )pysqlite_statement_reset (self -> statement );
866
846
Py_DECREF (next_row );
867
847
return NULL ;
868
848
}
869
849
if (rc != SQLITE_DONE && rc != SQLITE_ROW ) {
870
- (void )pysqlite_statement_reset (self -> statement );
871
850
Py_DECREF (next_row );
872
851
_pysqlite_seterror (self -> connection -> state , self -> connection -> db );
873
852
return NULL ;
@@ -876,7 +855,6 @@ pysqlite_cursor_iternext(pysqlite_Cursor *self)
876
855
if (rc == SQLITE_ROW ) {
877
856
self -> next_row = _pysqlite_fetch_one_row (self );
878
857
if (self -> next_row == NULL ) {
879
- (void )pysqlite_statement_reset (self -> statement );
880
858
return NULL ;
881
859
}
882
860
}
@@ -1037,11 +1015,7 @@ pysqlite_cursor_close_impl(pysqlite_Cursor *self, PyTypeObject *cls)
1037
1015
return NULL ;
1038
1016
}
1039
1017
1040
- if (self -> statement ) {
1041
- (void )pysqlite_statement_reset (self -> statement );
1042
- Py_CLEAR (self -> statement );
1043
- }
1044
-
1018
+ Py_CLEAR (self -> statement );
1045
1019
self -> closed = 1 ;
1046
1020
1047
1021
Py_RETURN_NONE ;
0 commit comments