fix issue #9 @github: execAsync - gets another result
[m6w6/ext-pq] / src / php_pqtxn.c
index e0574e8a23467c7b7b56e7d6c54242ab35b6fca2..423026634fd2247607a344c12daa6ec6b546dc1e 100644 (file)
@@ -55,10 +55,10 @@ static void php_pqtxn_object_free(void *o TSRMLS_DC)
 #endif
        if (obj->intern) {
                if (obj->intern->open && obj->intern->conn->intern) {
-                       PGresult *res = PQexec(obj->intern->conn->intern->conn, "ROLLBACK");
+                       PGresult *res = php_pq_exec(obj->intern->conn->intern->conn, "ROLLBACK");
 
                        if (res) {
-                               PHP_PQclear(res);
+                               php_pq_clear_res(res);
                        }
                }
                php_pq_object_delref(obj->intern->conn TSRMLS_CC);
@@ -146,13 +146,13 @@ static void php_pqtxn_object_write_isolation(zval *object, void *o, zval *value
 
        switch ((obj->intern->isolation = Z_LVAL_P(zisolation))) {
        case PHP_PQTXN_READ_COMMITTED:
-               res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION ISOLATION LEVEL READ COMMITED");
+               res = php_pq_exec(obj->intern->conn->intern->conn, "SET TRANSACTION ISOLATION LEVEL READ COMMITED");
                break;
        case PHP_PQTXN_REPEATABLE_READ:
-               res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ");
+               res = php_pq_exec(obj->intern->conn->intern->conn, "SET TRANSACTION ISOLATION LEVEL REPEATABLE READ");
                break;
        case PHP_PQTXN_SERIALIZABLE:
-               res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
+               res = php_pq_exec(obj->intern->conn->intern->conn, "SET TRANSACTION ISOLATION LEVEL SERIALIZABLE");
                break;
        default:
                obj->intern->isolation = orig;
@@ -166,7 +166,7 @@ static void php_pqtxn_object_write_isolation(zval *object, void *o, zval *value
 
        if (res) {
                php_pqres_success(res TSRMLS_CC);
-               PHP_PQclear(res);
+               php_pq_clear_res(res);
        }
 }
 
@@ -176,14 +176,14 @@ static void php_pqtxn_object_write_readonly(zval *object, void *o, zval *value T
        PGresult *res;
 
        if ((obj->intern->readonly = z_is_true(value))) {
-               res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION READ ONLY");
+               res = php_pq_exec(obj->intern->conn->intern->conn, "SET TRANSACTION READ ONLY");
        } else {
-               res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION READ WRITE");
+               res = php_pq_exec(obj->intern->conn->intern->conn, "SET TRANSACTION READ WRITE");
        }
 
        if (res) {
                php_pqres_success(res TSRMLS_CC);
-               PHP_PQclear(res);
+               php_pq_clear_res(res);
        }
 }
 
@@ -193,14 +193,14 @@ static void php_pqtxn_object_write_deferrable(zval *object, void *o, zval *value
        PGresult *res;
 
        if ((obj->intern->deferrable = z_is_true(value))) {
-               res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION DEFERRABLE");
+               res = php_pq_exec(obj->intern->conn->intern->conn, "SET TRANSACTION DEFERRABLE");
        } else {
-               res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION NOT DEFERRABLE");
+               res = php_pq_exec(obj->intern->conn->intern->conn, "SET TRANSACTION NOT DEFERRABLE");
        }
 
        if (res) {
                php_pqres_success(res TSRMLS_CC);
-               PHP_PQclear(res);
+               php_pq_clear_res(res);
        }
 }
 
@@ -291,13 +291,13 @@ static PHP_METHOD(pqtxn, savepoint) {
                        smart_str_appends(&cmd, "\"");
                        smart_str_0(&cmd);
 
-                       res = PQexec(obj->intern->conn->intern->conn, cmd.c);
+                       res = php_pq_exec(obj->intern->conn->intern->conn, cmd.c);
 
                        if (!res) {
                                throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to create %s (%s)", cmd.c, PHP_PQerrorMessage(obj->intern->conn->intern->conn));
                        } else {
                                php_pqres_success(res TSRMLS_CC);
-                               PHP_PQclear(res);
+                               php_pq_clear_res(res);
                        }
 
                        smart_str_free(&cmd);
@@ -361,14 +361,14 @@ static PHP_METHOD(pqtxn, commit) {
                        smart_str cmd = {0};
 
                        if (!obj->intern->savepoint) {
-                               res = PQexec(obj->intern->conn->intern->conn, "COMMIT");
+                               res = php_pq_exec(obj->intern->conn->intern->conn, "COMMIT");
                        } else {
                                smart_str_appends(&cmd, "RELEASE SAVEPOINT \"");
                                smart_str_append_unsigned(&cmd, obj->intern->savepoint--);
                                smart_str_appends(&cmd, "\"");
                                smart_str_0(&cmd);
 
-                               res = PQexec(obj->intern->conn->intern->conn, cmd.c);
+                               res = php_pq_exec(obj->intern->conn->intern->conn, cmd.c);
                        }
 
                        if (!res) {
@@ -379,7 +379,7 @@ static PHP_METHOD(pqtxn, commit) {
                                                obj->intern->open = 0;
                                        }
                                }
-                               PHP_PQclear(res);
+                               php_pq_clear_res(res);
                        }
 
                        smart_str_free(&cmd);
@@ -457,14 +457,14 @@ static PHP_METHOD(pqtxn, rollback) {
                        smart_str cmd = {0};
 
                        if (!obj->intern->savepoint) {
-                               res = PQexec(obj->intern->conn->intern->conn, "ROLLBACK");
+                               res = php_pq_exec(obj->intern->conn->intern->conn, "ROLLBACK");
                        } else {
                                smart_str_appends(&cmd, "ROLLBACK TO SAVEPOINT \"");
                                smart_str_append_unsigned(&cmd, obj->intern->savepoint--);
                                smart_str_appends(&cmd, "\"");
                                smart_str_0(&cmd);
 
-                               res = PQexec(obj->intern->conn->intern->conn, cmd.c);
+                               res = php_pq_exec(obj->intern->conn->intern->conn, cmd.c);
                        }
 
                        if (!res) {
@@ -475,7 +475,7 @@ static PHP_METHOD(pqtxn, rollback) {
                                                obj->intern->open = 0;
                                        }
                                }
-                               PHP_PQclear(res);
+                               php_pq_clear_res(res);
                        }
 
                        smart_str_free(&cmd);
@@ -547,7 +547,7 @@ static PHP_METHOD(pqtxn, exportSnapshot) {
                if (!obj->intern) {
                        throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Transaction not initialized");
                } else {
-                       PGresult *res = PQexec(obj->intern->conn->intern->conn, "SELECT pg_export_snapshot()");
+                       PGresult *res = php_pq_exec(obj->intern->conn->intern->conn, "SELECT pg_export_snapshot()");
 
                        if (!res) {
                                throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to export transaction snapshot (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
@@ -556,7 +556,7 @@ static PHP_METHOD(pqtxn, exportSnapshot) {
                                        RETVAL_STRING(PQgetvalue(res, 0, 0), 1);
                                }
 
-                               PHP_PQclear(res);
+                               php_pq_clear_res(res);
                        }
 
                        php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC);
@@ -621,13 +621,13 @@ static PHP_METHOD(pqtxn, importSnapshot) {
                                smart_str_appends(&cmd, sid);
                                smart_str_0(&cmd);
 
-                               res = PQexec(obj->intern->conn->intern->conn, cmd.c);
+                               res = php_pq_exec(obj->intern->conn->intern->conn, cmd.c);
 
                                if (!res) {
                                        throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to import transaction snapshot (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
                                } else {
                                        php_pqres_success(res TSRMLS_CC);
-                                       PHP_PQclear(res);
+                                       php_pq_clear_res(res);
                                }
 
                                smart_str_free(&cmd);