Skip to content

Commit f0ca8ff

Browse files
committed
refacter
1 parent 10b02c5 commit f0ca8ff

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

ext/pdo_firebird/firebird_driver.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@
3232
#include "php_pdo_firebird_int.h"
3333

3434
static int firebird_alloc_prepare_stmt(pdo_dbh_t*, const zend_string*, XSQLDA*, isc_stmt_handle*, HashTable*);
35-
static bool _firebird_commit_transaction(pdo_dbh_t *dbh, bool retain);
36-
static bool _firebird_rollback_transaction(pdo_dbh_t *dbh, bool retain);
3735

3836
const char CHR_LETTER = 1;
3937
const char CHR_DIGIT = 2;
@@ -478,9 +476,9 @@ static void firebird_handle_closer(pdo_dbh_t *dbh) /* {{{ */
478476

479477
if (H->tr) {
480478
if (dbh->auto_commit) {
481-
_firebird_commit_transaction(dbh, false);
479+
firebird_commit_transaction(dbh, false);
482480
} else {
483-
_firebird_rollback_transaction(dbh, false);
481+
firebird_rollback_transaction(dbh, false);
484482
}
485483
}
486484
H->in_manually_txn = 0;
@@ -646,7 +644,7 @@ static zend_long firebird_handle_doer(pdo_dbh_t *dbh, const zend_string *sql) /*
646644

647645
/* commit if we're in auto_commit mode */
648646
if (dbh->auto_commit && !H->in_manually_txn) {
649-
_firebird_commit_transaction(dbh, true);
647+
firebird_commit_transaction(dbh, true);
650648
}
651649

652650
free_statement:
@@ -756,7 +754,7 @@ static bool firebird_handle_manually_begin(pdo_dbh_t *dbh) /* {{{ */
756754
{
757755
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
758756

759-
if (dbh->auto_commit && H->tr && !_firebird_commit_transaction(dbh, false)) {
757+
if (dbh->auto_commit && H->tr && !firebird_commit_transaction(dbh, false)) {
760758
return false;
761759
}
762760

@@ -769,8 +767,8 @@ static bool firebird_handle_manually_begin(pdo_dbh_t *dbh) /* {{{ */
769767
}
770768
/* }}} */
771769

772-
/* _firebird_commit_transaction */
773-
static bool _firebird_commit_transaction(pdo_dbh_t *dbh, bool retain) /* {{{ */
770+
/* firebird_commit_transaction */
771+
bool _firebird_commit_transaction(pdo_dbh_t *dbh, bool retain) /* {{{ */
774772
{
775773
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
776774

@@ -795,7 +793,7 @@ static bool firebird_handle_manually_commit(pdo_dbh_t *dbh) /* {{{ */
795793
{
796794
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
797795

798-
if (!_firebird_commit_transaction(dbh, dbh->auto_commit)) {
796+
if (!firebird_commit_transaction(dbh, dbh->auto_commit)) {
799797
return false;
800798
}
801799

@@ -804,8 +802,8 @@ static bool firebird_handle_manually_commit(pdo_dbh_t *dbh) /* {{{ */
804802
}
805803
/* }}} */
806804

807-
/* _firebird_rollback_transaction */
808-
static bool _firebird_rollback_transaction(pdo_dbh_t *dbh, bool retain) /* {{{ */
805+
/* firebird_rollback_transaction */
806+
bool _firebird_rollback_transaction(pdo_dbh_t *dbh, bool retain) /* {{{ */
809807
{
810808
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
811809

@@ -830,7 +828,7 @@ static bool firebird_handle_manually_rollback(pdo_dbh_t *dbh) /* {{{ */
830828
{
831829
pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;
832830

833-
if (!_firebird_rollback_transaction(dbh, dbh->auto_commit)) {
831+
if (!firebird_rollback_transaction(dbh, dbh->auto_commit)) {
834832
return false;
835833
}
836834

@@ -906,7 +904,7 @@ static bool firebird_handle_set_attribute(pdo_dbh_t *dbh, zend_long attr, zval *
906904
}
907905
} else {
908906
/* close the transaction */
909-
if (H->tr && !_firebird_commit_transaction(dbh, false)) {
907+
if (H->tr && !firebird_commit_transaction(dbh, false)) {
910908
return false;
911909
}
912910
H->in_manually_txn = 0;

ext/pdo_firebird/firebird_statement.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,8 @@ static int firebird_stmt_execute(pdo_stmt_t *stmt) /* {{{ */
177177
;
178178
}
179179

180-
if (stmt->dbh->auto_commit && !S->H->in_manually_txn) {
181-
if (isc_commit_retaining(H->isc_status, &H->tr)) {
182-
break;
183-
}
180+
if (stmt->dbh->auto_commit && !S->H->in_manually_txn && !firebird_commit_transaction(stmt->dbh, true)) {
181+
break;
184182
}
185183

186184
*S->name = 0;

ext/pdo_firebird/php_pdo_firebird_int.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,12 @@ typedef void (*info_func_t)(char*);
5959
# define PDO_FIREBIRD_HANDLE_INITIALIZER NULL
6060
#endif
6161

62+
extern bool _firebird_commit_transaction(pdo_dbh_t *dbh, bool retain);
63+
#define firebird_commit_transaction(d, r) _firebird_commit_transaction(d, r)
64+
65+
extern bool _firebird_rollback_transaction(pdo_dbh_t *dbh, bool retain);
66+
#define firebird_rollback_transaction(d, r) _firebird_rollback_transaction(d, r)
67+
6268
typedef struct {
6369

6470
/* the result of the last API call */

0 commit comments

Comments
 (0)