@@ -396,43 +396,29 @@ static PyObject *
396
396
pysqlite_connection_commit_impl (pysqlite_Connection * self )
397
397
/*[clinic end generated code: output=3da45579e89407f2 input=39c12c04dda276a8]*/
398
398
{
399
- int rc ;
400
- sqlite3_stmt * statement ;
401
-
402
399
if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
403
400
return NULL ;
404
401
}
405
402
406
403
if (!sqlite3_get_autocommit (self -> db )) {
404
+ int rc ;
407
405
408
406
Py_BEGIN_ALLOW_THREADS
407
+ sqlite3_stmt * statement ;
409
408
rc = sqlite3_prepare_v2 (self -> db , "COMMIT" , 7 , & statement , NULL );
410
- Py_END_ALLOW_THREADS
411
- if (rc != SQLITE_OK ) {
412
- _pysqlite_seterror (self -> state , self -> db );
413
- goto error ;
409
+ if (rc == SQLITE_OK ) {
410
+ (void )sqlite3_step (statement );
411
+ rc = sqlite3_finalize (statement );
414
412
}
415
-
416
- rc = pysqlite_step (statement );
417
- if (rc != SQLITE_DONE ) {
418
- _pysqlite_seterror (self -> state , self -> db );
419
- }
420
-
421
- Py_BEGIN_ALLOW_THREADS
422
- rc = sqlite3_finalize (statement );
423
413
Py_END_ALLOW_THREADS
424
- if (rc != SQLITE_OK && !PyErr_Occurred ()) {
425
- _pysqlite_seterror (self -> state , self -> db );
426
- }
427
414
415
+ if (rc != SQLITE_OK ) {
416
+ (void )_pysqlite_seterror (self -> state , self -> db );
417
+ return NULL ;
418
+ }
428
419
}
429
420
430
- error :
431
- if (PyErr_Occurred ()) {
432
- return NULL ;
433
- } else {
434
- Py_RETURN_NONE ;
435
- }
421
+ Py_RETURN_NONE ;
436
422
}
437
423
438
424
/*[clinic input]
@@ -445,44 +431,32 @@ static PyObject *
445
431
pysqlite_connection_rollback_impl (pysqlite_Connection * self )
446
432
/*[clinic end generated code: output=b66fa0d43e7ef305 input=12d4e8d068942830]*/
447
433
{
448
- int rc ;
449
- sqlite3_stmt * statement ;
450
-
451
434
if (!pysqlite_check_thread (self ) || !pysqlite_check_connection (self )) {
452
435
return NULL ;
453
436
}
454
437
455
438
if (!sqlite3_get_autocommit (self -> db )) {
456
439
pysqlite_do_all_statements (self );
457
440
441
+ int rc ;
442
+
458
443
Py_BEGIN_ALLOW_THREADS
444
+ sqlite3_stmt * statement ;
459
445
rc = sqlite3_prepare_v2 (self -> db , "ROLLBACK" , 9 , & statement , NULL );
460
- Py_END_ALLOW_THREADS
461
- if (rc != SQLITE_OK ) {
462
- _pysqlite_seterror (self -> state , self -> db );
463
- goto error ;
464
- }
465
-
466
- rc = pysqlite_step (statement );
467
- if (rc != SQLITE_DONE ) {
468
- _pysqlite_seterror (self -> state , self -> db );
446
+ if (rc == SQLITE_OK ) {
447
+ (void )sqlite3_step (statement );
448
+ rc = sqlite3_finalize (statement );
469
449
}
470
-
471
- Py_BEGIN_ALLOW_THREADS
472
- rc = sqlite3_finalize (statement );
473
450
Py_END_ALLOW_THREADS
474
- if (rc != SQLITE_OK && !PyErr_Occurred ()) {
475
- _pysqlite_seterror (self -> state , self -> db );
451
+
452
+ if (rc != SQLITE_OK ) {
453
+ (void )_pysqlite_seterror (self -> state , self -> db );
454
+ return NULL ;
476
455
}
477
456
478
457
}
479
458
480
- error :
481
- if (PyErr_Occurred ()) {
482
- return NULL ;
483
- } else {
484
- Py_RETURN_NONE ;
485
- }
459
+ Py_RETURN_NONE ;
486
460
}
487
461
488
462
static int
0 commit comments