php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #63215
Patch CommitRetaining revision 2012-10-04 00:02 UTC by james at kenjim dot com

Patch CommitRetaining for PDO Firebird Bug #63215

Patch version 2012-10-04 00:02 UTC

Return to Bug #63215 | Download this patch
Patch Revisions:

Developer: james@kenjim.com

diff --git a/ext/pdo_firebird/firebird_driver.c b/ext/pdo_firebird/firebird_driver.c
index e39555f..3d856f6 100644
--- a/ext/pdo_firebird/firebird_driver.c
+++ b/ext/pdo_firebird/firebird_driver.c
@@ -371,9 +371,16 @@ static int firebird_handle_commit(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
 {
        pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;

-       if (isc_commit_transaction(H->isc_status, &H->tr)) {
-               RECORD_ERROR(dbh);
-               return 0;
+       if (H->commit_retaining) {
+               if (isc_commit_retaining(H->isc_status, &H->tr)) {
+                       RECORD_ERROR(dbh);
+                       return 0;
+               }
+       } else {
+               if (isc_commit_transaction(H->isc_status, &H->tr)) {
+                       RECORD_ERROR(dbh);
+                       return 0;
+               }
        }
        return 1;
 }
@@ -384,9 +391,16 @@ static int firebird_handle_rollback(pdo_dbh_t *dbh TSRMLS_DC) /* {{{ */
 {
        pdo_firebird_db_handle *H = (pdo_firebird_db_handle *)dbh->driver_data;

-       if (isc_rollback_transaction(H->isc_status, &H->tr)) {
-               RECORD_ERROR(dbh);
-               return 0;
+       if (H->commit_retaining) {
+               if (isc_rollback_retaining(H->isc_status, &H->tr)) {
+                       RECORD_ERROR(dbh);
+                       return 0;
+               }
+       } else {
+               if (isc_rollback_transaction(H->isc_status, &H->tr)) {
+                       RECORD_ERROR(dbh);
+                       return 0;
+               }
        }
        return 1;
 }
@@ -505,6 +519,11 @@ static int firebird_handle_set_attribute(pdo_dbh_t *dbh, long attr, zval *val TS
                        H->fetch_table_names = Z_BVAL_P(val);
                        return 1;

+               case PDO_FB_ATTR_COMMIT_RETAINING:
+                       convert_to_boolean(val);
+                       H->commit_retaining = Z_BVAL_P(val);
+                       return 1;
+
                case PDO_FB_ATTR_DATE_FORMAT:
                        convert_to_string(val);
                        if (H->date_format) {
@@ -656,6 +675,8 @@ static int pdo_firebird_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRM

        pdo_firebird_db_handle *H = dbh->driver_data = pecalloc(1,sizeof(*H),dbh->is_persistent);

+       H->commit_retaining = 0;
+
        php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, 3);

        do {
diff --git a/ext/pdo_firebird/pdo_firebird.c b/ext/pdo_firebird/pdo_firebird.c
index c2bbe37..7d7705d 100644
--- a/ext/pdo_firebird/pdo_firebird.c
+++ b/ext/pdo_firebird/pdo_firebird.c
@@ -70,6 +70,7 @@ ZEND_GET_MODULE(pdo_firebird)

 PHP_MINIT_FUNCTION(pdo_firebird) /* {{{ */
 {
+       REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_COMMIT_RETAINING", (long) PDO_FB_ATTR_COMMIT_RETAINING);
        REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_DATE_FORMAT", (long) PDO_FB_ATTR_DATE_FORMAT);
        REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIME_FORMAT", (long) PDO_FB_ATTR_TIME_FORMAT);
        REGISTER_PDO_CLASS_CONST_LONG("FB_ATTR_TIMESTAMP_FORMAT", (long) PDO_FB_ATTR_TIMESTAMP_FORMAT);
diff --git a/ext/pdo_firebird/php_pdo_firebird_int.h b/ext/pdo_firebird/php_pdo_firebird_int.h
index bb15d54..cbce06b 100644
--- a/ext/pdo_firebird/php_pdo_firebird_int.h
+++ b/ext/pdo_firebird/php_pdo_firebird_int.h
@@ -84,8 +84,10 @@ typedef struct {

        /* prepend table names on column names in fetch */
        unsigned fetch_table_names:1;
+       /* commit retain used to store commit/rollback mode */
+       unsigned commit_retaining:1;

-       unsigned _reserved:31;
+       unsigned _reserved:30;

 } pdo_firebird_db_handle;

@@ -136,6 +138,7 @@ enum {
        PDO_FB_ATTR_DATE_FORMAT = PDO_ATTR_DRIVER_SPECIFIC,
        PDO_FB_ATTR_TIME_FORMAT,
        PDO_FB_ATTR_TIMESTAMP_FORMAT,
+        PDO_FB_ATTR_COMMIT_RETAINING,
 };

 #endif /* PHP_PDO_FIREBIRD_INT_H */
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 03:01:28 2024 UTC