@@ -579,18 +579,18 @@ stmt_step(sqlite3_stmt *statement)
579579 *
580580 * The argument must be already be an adapted value.
581581 *
582+ * The caller is responsible for calling pysqlite_check_connection()
583+ * to ensure that the connection is still valid after the call.
584+ *
582585 * Return an sqlite3 error code.
583586 */
584587static int
585- bind_param (pysqlite_state * state , pysqlite_Connection * conn ,
586- pysqlite_Statement * self , int pos , PyObject * parameter )
588+ bind_param (pysqlite_state * state , pysqlite_Statement * self , int pos , PyObject * parameter )
587589{
588590 int rc = SQLITE_OK ;
589591 const char * string ;
590592 Py_ssize_t buflen ;
591593 parameter_type paramtype ;
592- // Indicate whether 'conn' is safe against conversion's side effects.
593- bool safe = false;
594594
595595 if (parameter == Py_None ) {
596596 rc = sqlite3_bind_null (self -> st , pos );
@@ -599,13 +599,10 @@ bind_param(pysqlite_state *state, pysqlite_Connection *conn,
599599
600600 if (PyLong_CheckExact (parameter )) {
601601 paramtype = TYPE_LONG ;
602- safe = true;
603602 } else if (PyFloat_CheckExact (parameter )) {
604603 paramtype = TYPE_FLOAT ;
605- safe = true;
606604 } else if (PyUnicode_CheckExact (parameter )) {
607605 paramtype = TYPE_UNICODE ;
608- safe = true;
609606 } else if (PyLong_Check (parameter )) {
610607 paramtype = TYPE_LONG ;
611608 } else if (PyFloat_Check (parameter )) {
@@ -616,7 +613,6 @@ bind_param(pysqlite_state *state, pysqlite_Connection *conn,
616613 paramtype = TYPE_BUFFER ;
617614 } else {
618615 paramtype = TYPE_UNKNOWN ;
619- safe = true; // there is no conversion
620616 }
621617
622618 switch (paramtype ) {
@@ -669,7 +665,7 @@ bind_param(pysqlite_state *state, pysqlite_Connection *conn,
669665 }
670666
671667final :
672- return ( safe || pysqlite_check_connection ( conn )) ? rc : SQLITE_ERROR ;
668+ return rc ;
673669}
674670
675671/* returns 0 if the object is one of Python's internal ones that don't need to be adapted */
@@ -781,7 +777,7 @@ bind_parameters(pysqlite_state *state, pysqlite_Connection *conn,
781777 }
782778 }
783779
784- rc = bind_param (state , conn , self , i + 1 , adapted );
780+ rc = bind_param (state , self , i + 1 , adapted );
785781 Py_DECREF (adapted );
786782 if (!pysqlite_check_connection (conn )) {
787783 return -1 ;
@@ -844,7 +840,7 @@ bind_parameters(pysqlite_state *state, pysqlite_Connection *conn,
844840 }
845841 }
846842
847- rc = bind_param (state , conn , self , i , adapted );
843+ rc = bind_param (state , self , i , adapted );
848844 Py_DECREF (adapted );
849845 if (!pysqlite_check_connection (conn )) {
850846 return -1 ;
0 commit comments