@@ -459,43 +459,29 @@ static PyObject *
459
459
pysqlite_connection_commit_impl (pysqlite_Connection * self )
460
460
/*[clinic end generated code: output=3da45579e89407f2 input=39c12c04dda276a8]*/
461
461
{
462
- int rc ;
463
- sqlite3_stmt * statement ;
464
-
465
462
if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
466
463
return NULL ;
467
464
}
468
465
469
466
if (!sqlite3_get_autocommit (self -> db )) {
467
+ int rc ;
470
468
471
469
Py_BEGIN_ALLOW_THREADS
470
+ sqlite3_stmt * statement ;
472
471
rc = sqlite3_prepare_v2 (self -> db , "COMMIT" , 7 , & statement , NULL );
473
- Py_END_ALLOW_THREADS
474
- if (rc != SQLITE_OK ) {
475
- _pysqlite_seterror (self -> state , self -> db );
476
- goto error ;
472
+ if (rc == SQLITE_OK ) {
473
+ (void )sqlite3_step (statement );
474
+ rc = sqlite3_finalize (statement );
477
475
}
478
-
479
- rc = pysqlite_step (statement );
480
- if (rc != SQLITE_DONE ) {
481
- _pysqlite_seterror (self -> state , self -> db );
482
- }
483
-
484
- Py_BEGIN_ALLOW_THREADS
485
- rc = sqlite3_finalize (statement );
486
476
Py_END_ALLOW_THREADS
487
- if (rc != SQLITE_OK && !PyErr_Occurred ()) {
488
- _pysqlite_seterror (self -> state , self -> db );
489
- }
490
477
478
+ if (rc != SQLITE_OK ) {
479
+ (void )_pysqlite_seterror (self -> state , self -> db );
480
+ return NULL ;
481
+ }
491
482
}
492
483
493
- error :
494
- if (PyErr_Occurred ()) {
495
- return NULL ;
496
- } else {
497
- Py_RETURN_NONE ;
498
- }
484
+ Py_RETURN_NONE ;
499
485
}
500
486
501
487
/*[clinic input]
@@ -508,44 +494,32 @@ static PyObject *
508
494
pysqlite_connection_rollback_impl (pysqlite_Connection * self )
509
495
/*[clinic end generated code: output=b66fa0d43e7ef305 input=12d4e8d068942830]*/
510
496
{
511
- int rc ;
512
- sqlite3_stmt * statement ;
513
-
514
497
if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
515
498
return NULL ;
516
499
}
517
500
518
501
if (!sqlite3_get_autocommit (self -> db )) {
519
502
pysqlite_do_all_statements (self );
520
503
504
+ int rc ;
505
+
521
506
Py_BEGIN_ALLOW_THREADS
507
+ sqlite3_stmt * statement ;
522
508
rc = sqlite3_prepare_v2 (self -> db , "ROLLBACK" , 9 , & statement , NULL );
523
- Py_END_ALLOW_THREADS
524
- if (rc != SQLITE_OK ) {
525
- _pysqlite_seterror (self -> state , self -> db );
526
- goto error ;
527
- }
528
-
529
- rc = pysqlite_step (statement );
530
- if (rc != SQLITE_DONE ) {
531
- _pysqlite_seterror (self -> state , self -> db );
509
+ if (rc == SQLITE_OK ) {
510
+ (void )sqlite3_step (statement );
511
+ rc = sqlite3_finalize (statement );
532
512
}
533
-
534
- Py_BEGIN_ALLOW_THREADS
535
- rc = sqlite3_finalize (statement );
536
513
Py_END_ALLOW_THREADS
537
- if (rc != SQLITE_OK && !PyErr_Occurred ()) {
538
- _pysqlite_seterror (self -> state , self -> db );
514
+
515
+ if (rc != SQLITE_OK ) {
516
+ (void )_pysqlite_seterror (self -> state , self -> db );
517
+ return NULL ;
539
518
}
540
519
541
520
}
542
521
543
- error :
544
- if (PyErr_Occurred ()) {
545
- return NULL ;
546
- } else {
547
- Py_RETURN_NONE ;
548
- }
522
+ Py_RETURN_NONE ;
549
523
}
550
524
551
525
static int
0 commit comments