Merge branch 'v1.1.x'
[m6w6/ext-pq] / src / php_pqconn.c
index 07c907f59e117f5d80d81fff5c7b1045adbf93f5..d6cccb533655f091a9ad1cb7717ca047e5bee91e 100644 (file)
@@ -86,6 +86,7 @@ static void php_pqconn_object_free(zend_object *o)
                php_resource_factory_handle_dtor(&obj->intern->factory, obj->intern->conn);
                php_resource_factory_dtor(&obj->intern->factory);
                zend_hash_destroy(&obj->intern->listeners);
+               zend_hash_destroy(&obj->intern->statements);
                zend_hash_destroy(&obj->intern->converters);
                zend_hash_destroy(&obj->intern->eventhandlers);
                efree(obj->intern);
@@ -552,7 +553,7 @@ php_resource_factory_ops_t *php_pqconn_get_resource_factory_ops(void)
 static void php_pqconn_wakeup(php_persistent_handle_factory_t *f, void **handle)
 {
        PGresult *res = PQexec(*handle, "");
-       php_pq_clear_res(res);
+       php_pqres_clear(res);
 
        if (CONNECTION_OK != PQstatus(*handle)) {
                PQreset(*handle);
@@ -586,7 +587,7 @@ static int apply_unlisten(zval *p, int argc, va_list argv, zend_hash_key *key)
        PGresult *res = unlisten(obj->intern->conn, key->key->val, key->key->len);
 
        if (res) {
-               php_pq_clear_res(res);
+               php_pqres_clear(res);
        }
 
        return ZEND_HASH_APPLY_REMOVE;
@@ -613,7 +614,7 @@ static void php_pqconn_retire(php_persistent_handle_factory_t *f, void **handle)
        }
        /* clean up async results */
        while ((res = PQgetResult(*handle))) {
-               php_pq_clear_res(res);
+               php_pqres_clear(res);
        }
 
        /* clean up transaction & session */
@@ -627,7 +628,7 @@ static void php_pqconn_retire(php_persistent_handle_factory_t *f, void **handle)
        }
 
        if (res) {
-               php_pq_clear_res(res);
+               php_pqres_clear(res);
        }
 
        if (evdata) {
@@ -668,6 +669,7 @@ static PHP_METHOD(pqconn, __construct) {
                        obj->intern->default_auto_convert = PHP_PQRES_CONV_ALL;
 
                        zend_hash_init(&obj->intern->listeners, 0, NULL, ZVAL_PTR_DTOR, 0);
+                       zend_hash_init(&obj->intern->statements, 0, NULL, NULL, 0);
                        zend_hash_init(&obj->intern->converters, 0, NULL, ZVAL_PTR_DTOR, 0);
                        zend_hash_init(&obj->intern->eventhandlers, 0, NULL, ZVAL_PTR_DTOR, 0);
 
@@ -774,7 +776,7 @@ static PHP_METHOD(pqconn, unlisten)
 
                        if (res) {
                                php_pqres_success(res);
-                               php_pq_clear_res(res);
+                               php_pqres_clear(res);
                        }
                }
        }
@@ -891,7 +893,7 @@ static PHP_METHOD(pqconn, listen) {
                                                obj->intern->poller = PQconsumeInput;
                                                php_pqconn_add_listener(obj, channel_str, channel_len, &listener);
                                        }
-                                       php_pq_clear_res(res);
+                                       php_pqres_clear(res);
                                }
 
                                php_pqconn_notify_listeners(obj);
@@ -976,7 +978,7 @@ static PHP_METHOD(pqconn, notify) {
                                throw_exce(EX_RUNTIME, "Failed to notify listeners (%s)", PHP_PQerrorMessage(obj->intern->conn));
                        } else {
                                php_pqres_success(res);
-                               php_pq_clear_res(res);
+                               php_pqres_clear(res);
                        }
 
                        php_pqconn_notify_listeners(obj);
@@ -1071,7 +1073,7 @@ static PHP_METHOD(pqconn, exec) {
                        } else if (SUCCESS == php_pqres_success(res)) {
                                php_pq_object_to_zval_no_addref(PQresultInstanceData(res, php_pqconn_event), return_value);
                        } else {
-                               php_pq_clear_res(res);
+                               php_pqres_clear(res);
                        }
 
                        php_pqconn_notify_listeners(obj);
@@ -1178,7 +1180,7 @@ static PHP_METHOD(pqconn, execParams) {
                                if (SUCCESS == php_pqres_success(res)) {
                                        php_pq_object_to_zval_no_addref(PQresultInstanceData(res, php_pqconn_event), return_value);
                                } else {
-                                       php_pq_clear_res(res);
+                                       php_pqres_clear(res);
                                }
 
                                php_pqconn_notify_listeners(obj);
@@ -1251,7 +1253,7 @@ ZEND_RESULT_CODE php_pqconn_prepare(zval *object, php_pqconn_object_t *obj, cons
                throw_exce(EX_RUNTIME, "Failed to prepare statement (%s)", PHP_PQerrorMessage(obj->intern->conn));
        } else {
                rv = php_pqres_success(res);
-               php_pq_clear_res(res);
+               php_pqres_clear(res);
                php_pqconn_notify_listeners(obj);
        }
 
@@ -1364,7 +1366,7 @@ ZEND_RESULT_CODE php_pqconn_declare(zval *object, php_pqconn_object_t *obj, cons
                throw_exce(EX_RUNTIME, "Failed to declare cursor (%s)", PHP_PQerrorMessage(obj->intern->conn));
        } else {
                rv = php_pqres_success(res);
-               php_pq_clear_res(res);
+               php_pqres_clear(res);
                php_pqconn_notify_listeners(obj);
        }
 
@@ -1599,7 +1601,7 @@ ZEND_RESULT_CODE php_pqconn_start_transaction(zval *zconn, php_pqconn_object_t *
                        throw_exce(EX_RUNTIME, "Failed to start transaction (%s)", PHP_PQerrorMessage(conn_obj->intern->conn));
                } else {
                        rv = php_pqres_success(res);
-                       php_pq_clear_res(res);
+                       php_pqres_clear(res);
                        php_pqconn_notify_listeners(conn_obj);
                }