better checks for json support
[m6w6/ext-pq] / src / php_pqcopy.c
index 89ab68c5037bab7207c37778a4cf93251c6872ab..d652ba6ba6a143785b68652d338a89b27b1ccbf8 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_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)
        ZEND_ARG_INFO(0, expression)
        ZEND_ARG_INFO(0, direction)
        ZEND_ARG_INFO(0, options)
@@ -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) {
                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));
                } 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));
@@ -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) {
                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) {
                } 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));
                } 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));
@@ -308,6 +308,12 @@ static zend_function_entry php_pqcopy_methods[] = {
        {0}
 };
 
        {0}
 };
 
+PHP_MSHUTDOWN_FUNCTION(pqcopy)
+{
+       zend_hash_destroy(&php_pqcopy_object_prophandlers);
+       return SUCCESS;
+}
+
 PHP_MINIT_FUNCTION(pqcopy)
 {
        zend_class_entry ce = {0};
 PHP_MINIT_FUNCTION(pqcopy)
 {
        zend_class_entry ce = {0};
@@ -322,6 +328,8 @@ PHP_MINIT_FUNCTION(pqcopy)
        php_pqcopy_object_handlers.write_property = php_pq_object_write_prop;
        php_pqcopy_object_handlers.clone_obj = NULL;
        php_pqcopy_object_handlers.get_property_ptr_ptr = NULL;
        php_pqcopy_object_handlers.write_property = php_pq_object_write_prop;
        php_pqcopy_object_handlers.clone_obj = NULL;
        php_pqcopy_object_handlers.get_property_ptr_ptr = NULL;
+       php_pqcopy_object_handlers.get_gc = NULL;
+       php_pqcopy_object_handlers.get_properties = php_pq_object_properties;
        php_pqcopy_object_handlers.get_debug_info = php_pq_object_debug_info;
 
        zend_hash_init(&php_pqcopy_object_prophandlers, 4, NULL, NULL, 1);
        php_pqcopy_object_handlers.get_debug_info = php_pq_object_debug_info;
 
        zend_hash_init(&php_pqcopy_object_prophandlers, 4, NULL, NULL, 1);