fix issue #9 @github: execAsync - gets another result
[m6w6/ext-pq] / src / php_pqcopy.c
index a427f07a869b84e38db781ddd6eb2921366fe717..d4a042a97613cfa1ed426789db68dfe14b4a88fc 100644 (file)
@@ -105,7 +105,7 @@ static void php_pqcopy_object_read_options(zval *object, void *o, zval *return_v
 }
 
 ZEND_BEGIN_ARG_INFO_EX(ai_pqcopy_construct, 0, 0, 3)
-       ZEND_ARG_OBJ_INFO(0, "connection", pq\\Connection, 0)
+       ZEND_ARG_OBJ_INFO(0, connection, pq\\Connection, 0)
        ZEND_ARG_INFO(0, expression)
        ZEND_ARG_INFO(0, direction)
        ZEND_ARG_INFO(0, options)
@@ -116,7 +116,7 @@ static PHP_METHOD(pqcopy, __construct) {
        char *expr_str, *opt_str = "";
        int expr_len, opt_len = 0;
        long direction;
-       STATUS rv;
+       ZEND_RESULT_CODE rv;
 
        zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
        rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Osl|s", &zconn, php_pqconn_class_entry, &expr_str, &expr_len, &direction, &opt_str, &opt_len);
@@ -150,7 +150,7 @@ static PHP_METHOD(pqcopy, __construct) {
                        smart_str_appendl(&cmd, opt_str, opt_len);
                        smart_str_0(&cmd);
 
-                       res = PQexec(conn_obj->intern->conn, cmd.c);
+                       res = php_pq_exec(conn_obj->intern->conn, cmd.c);
 
                        if (!res) {
                                throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to start %s (%s)", cmd.c, PHP_PQerrorMessage(obj->intern->conn->intern->conn));
@@ -164,7 +164,7 @@ static PHP_METHOD(pqcopy, __construct) {
                                        php_pq_object_addref(conn_obj TSRMLS_CC);
                                }
 
-                               PHP_PQclear(res);
+                               php_pq_clear_res(res);
                        }
 
                        smart_str_free(&cmd);
@@ -180,7 +180,7 @@ static PHP_METHOD(pqcopy, put) {
        zend_error_handling zeh;
        char *data_str;
        int data_len;
-       STATUS rv;
+       ZEND_RESULT_CODE rv;
 
        zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
        rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &data_str, &data_len);
@@ -192,7 +192,7 @@ static PHP_METHOD(pqcopy, put) {
                if (!obj->intern) {
                        throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\COPY not initialized");
                } else if (obj->intern->direction != PHP_PQCOPY_FROM_STDIN) {
-                       throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\COPY was not initialized with FROM_STDIN");
+                       throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\COPY was not initialized with FROM_STDIN");
                } else {
                        if (1 != PQputCopyData(obj->intern->conn->intern->conn, data_str, data_len)) {
                                throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to put COPY data (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
@@ -209,7 +209,7 @@ static PHP_METHOD(pqcopy, end) {
        zend_error_handling zeh;
        char *error_str = NULL;
        int error_len = 0;
-       STATUS rv;
+       ZEND_RESULT_CODE rv;
 
        zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
        rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s!", &error_str, &error_len);
@@ -219,9 +219,9 @@ static PHP_METHOD(pqcopy, end) {
                php_pqcopy_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
 
                if (!obj->intern) {
-                       throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\COPY not intitialized");
+                       throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\COPY not intitialized");
                } else if (obj->intern->direction != PHP_PQCOPY_FROM_STDIN) {
-                       throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\COPY was not intitialized with FROM_STDIN");
+                       throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\COPY was not intitialized with FROM_STDIN");
                } else {
                        if (1 != PQputCopyEnd(obj->intern->conn->intern->conn, error_str)) {
                                throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to end COPY (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
@@ -232,7 +232,7 @@ static PHP_METHOD(pqcopy, end) {
                                        throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to fetch COPY result (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
                                } else {
                                        php_pqres_success(res TSRMLS_CC);
-                                       PHP_PQclear(res);
+                                       php_pq_clear_res(res);
                                }
                        }
 
@@ -247,7 +247,7 @@ ZEND_END_ARG_INFO();
 static PHP_METHOD(pqcopy, get) {
        zend_error_handling zeh;
        zval *zdata;
-       STATUS rv;
+       ZEND_RESULT_CODE rv;
 
        zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
        rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zdata);
@@ -277,7 +277,7 @@ static PHP_METHOD(pqcopy, get) {
                                        throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to fetch COPY result (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
                                } else {
                                        php_pqres_success(res TSRMLS_CC);
-                                       PHP_PQclear(res);
+                                       php_pq_clear_res(res);
                                        RETVAL_FALSE;
                                }
                                break;