@@ -536,77 +536,48 @@ PyObject* _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject*
536536 goto error ;
537537 }
538538
539- /* Keep trying the SQL statement until the schema stops changing. */
540- while (1 ) {
541- /* Actually execute the SQL statement. */
542- rc = pysqlite_step (self -> statement -> st , self -> connection );
539+ rc = pysqlite_step (self -> statement -> st , self -> connection );
540+ if (rc != SQLITE_DONE && rc != SQLITE_ROW ) {
543541 if (PyErr_Occurred ()) {
544- (void )pysqlite_statement_reset (self -> statement );
545- goto error ;
546- }
547- if (rc == SQLITE_DONE || rc == SQLITE_ROW ) {
548- /* If it worked, let's get out of the loop */
549- break ;
550- }
551- #if SQLITE_VERSION_NUMBER < 3003009
552- /* Something went wrong. Re-set the statement and try again. */
553- rc = pysqlite_statement_reset (self -> statement );
554- #endif
555- if (rc == SQLITE_SCHEMA ) {
556- /* If this was a result of the schema changing, let's try
557- again. */
558- rc = pysqlite_statement_recompile (self -> statement , parameters );
559- if (rc == SQLITE_OK ) {
560- continue ;
542+ /* there was an error that occurred in a user-defined callback */
543+ if (_enable_callback_tracebacks ) {
544+ PyErr_Print ();
561545 } else {
562- /* If the database gave us an error, promote it to Python. */
563- (void )pysqlite_statement_reset (self -> statement );
564- _pysqlite_seterror (self -> connection -> db , NULL );
565- goto error ;
566- }
567- } else {
568- if (PyErr_Occurred ()) {
569- /* there was an error that occurred in a user-defined callback */
570- if (_enable_callback_tracebacks ) {
571- PyErr_Print ();
572- } else {
573- PyErr_Clear ();
574- }
546+ PyErr_Clear ();
575547 }
576- (void )pysqlite_statement_reset (self -> statement );
577- _pysqlite_seterror (self -> connection -> db , NULL );
578- goto error ;
579548 }
549+ (void )pysqlite_statement_reset (self -> statement );
550+ _pysqlite_seterror (self -> connection -> db , NULL );
551+ goto error ;
580552 }
581553
582554 if (pysqlite_build_row_cast_map (self ) != 0 ) {
583555 PyErr_SetString (pysqlite_OperationalError , "Error while building row_cast_map" );
584556 goto error ;
585557 }
586558
587- if (rc == SQLITE_ROW || rc == SQLITE_DONE ) {
588- Py_BEGIN_ALLOW_THREADS
589- numcols = sqlite3_column_count (self -> statement -> st );
590- Py_END_ALLOW_THREADS
591- if (self -> description == Py_None && numcols > 0 ) {
592- Py_SETREF (self -> description , PyTuple_New (numcols ));
593- if (!self -> description ) {
559+ assert (rc == SQLITE_ROW || rc == SQLITE_DONE );
560+ Py_BEGIN_ALLOW_THREADS
561+ numcols = sqlite3_column_count (self -> statement -> st );
562+ Py_END_ALLOW_THREADS
563+ if (self -> description == Py_None && numcols > 0 ) {
564+ Py_SETREF (self -> description , PyTuple_New (numcols ));
565+ if (!self -> description ) {
566+ goto error ;
567+ }
568+ for (i = 0 ; i < numcols ; i ++ ) {
569+ descriptor = PyTuple_New (7 );
570+ if (!descriptor ) {
594571 goto error ;
595572 }
596- for (i = 0 ; i < numcols ; i ++ ) {
597- descriptor = PyTuple_New (7 );
598- if (!descriptor ) {
599- goto error ;
600- }
601- PyTuple_SetItem (descriptor , 0 , _pysqlite_build_column_name (sqlite3_column_name (self -> statement -> st , i )));
602- Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 1 , Py_None );
603- Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 2 , Py_None );
604- Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 3 , Py_None );
605- Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 4 , Py_None );
606- Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 5 , Py_None );
607- Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 6 , Py_None );
608- PyTuple_SetItem (self -> description , i , descriptor );
609- }
573+ PyTuple_SetItem (descriptor , 0 , _pysqlite_build_column_name (sqlite3_column_name (self -> statement -> st , i )));
574+ Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 1 , Py_None );
575+ Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 2 , Py_None );
576+ Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 3 , Py_None );
577+ Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 4 , Py_None );
578+ Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 5 , Py_None );
579+ Py_INCREF (Py_None ); PyTuple_SetItem (descriptor , 6 , Py_None );
580+ PyTuple_SetItem (self -> description , i , descriptor );
610581 }
611582 }
612583
@@ -708,11 +679,11 @@ PyObject* pysqlite_cursor_executescript(pysqlite_Cursor* self, PyObject* args)
708679
709680 while (1 ) {
710681 Py_BEGIN_ALLOW_THREADS
711- rc = SQLITE3_PREPARE (self -> connection -> db ,
712- script_cstr ,
713- -1 ,
714- & statement ,
715- & script_cstr );
682+ rc = sqlite3_prepare_v2 (self -> connection -> db ,
683+ script_cstr ,
684+ -1 ,
685+ & statement ,
686+ & script_cstr );
716687 Py_END_ALLOW_THREADS
717688 if (rc != SQLITE_OK ) {
718689 _pysqlite_seterror (self -> connection -> db , NULL );
0 commit comments