{
php_pqcopy_object_t *obj = PHP_PQ_OBJ(NULL, o);
#if DBG_GC
- fprintf(stderr, "FREE copy(#%d) %p (conn(#%d): %p)\n", obj->zv.handle, obj, obj->intern->conn->zv.handle, obj->intern->conn);
+ fprintf(stderr, "FREE copy(#%d) %p (conn(#%d): %p)\n", obj->zo.handle, obj, obj->intern->conn->zo.handle, obj->intern->conn);
#endif
if (obj->intern) {
efree(obj->intern->expression);
efree(obj->intern);
obj->intern = NULL;
}
- zend_object_std_dtor(o);
- efree(obj);
+ php_pq_object_dtor(o);
}
php_pqcopy_object_t *php_pqcopy_create_object_ex(zend_class_entry *ce, php_pqcopy_t *intern)
{
- php_pqcopy_object_t *o;
-
- o = ecalloc(1, sizeof(*o) + zend_object_properties_size(ce));
- zend_object_std_init(&o->zo, ce);
- object_properties_init(&o->zo, ce);
- o->prophandler = &php_pqcopy_object_prophandlers;
-
- if (intern) {
- o->intern = intern;
- }
-
- o->zo.handlers = &php_pqcopy_object_handlers;
-
- return o;
+ return php_pq_object_create(ce, intern, sizeof(php_pqcopy_object_t),
+ &php_pqcopy_object_handlers, &php_pqcopy_object_prophandlers);
}
static zend_object *php_pqcopy_create_object(zend_class_entry *class_type)
php_pq_object_to_zval(obj->intern->conn, return_value);
}
+static void php_pqcopy_object_gc_connection(zval *object, void *o, zval *return_value)
+{
+ php_pqcopy_object_t *obj = o;
+ zval zconn;
+
+ php_pq_object_to_zval_no_addref(obj->intern->conn, &zconn);
+ add_next_index_zval(return_value, &zconn);
+}
+
static void php_pqcopy_object_read_direction(zval *object, void *o, zval *return_value)
{
php_pqcopy_object_t *obj = o;
smart_str_appendl(&cmd, opt_str, opt_len);
smart_str_0(&cmd);
- res = PQexec(conn_obj->intern->conn, smart_str_v(&cmd));
+ res = php_pq_exec(conn_obj->intern->conn, smart_str_v(&cmd));
if (!res) {
throw_exce(EX_RUNTIME, "Failed to start %s (%s)", smart_str_v(&cmd), PHP_PQerrorMessage(obj->intern->conn->intern->conn));
php_pq_object_addref(conn_obj);
}
- PHP_PQclear(res);
+ php_pqres_clear(res);
}
smart_str_free(&cmd);
throw_exce(EX_RUNTIME, "Failed to fetch COPY result (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
} else {
php_pqres_success(res);
- PHP_PQclear(res);
+ php_pqres_clear(res);
}
}
ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
- rv = zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zdata);
+ rv = zend_parse_parameters(ZEND_NUM_ARGS(), "z", &zdata);
zend_restore_error_handling(&zeh);
if (SUCCESS == rv) {
throw_exce(EX_RUNTIME, "Failed to fetch COPY result (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
} else {
php_pqres_success(res);
- PHP_PQclear(res);
+ php_pqres_clear(res);
RETVAL_FALSE;
}
break;
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_gc = php_pq_object_get_gc;
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);
+ zend_hash_init(&php_pqcopy_object_prophandlers, 4, NULL, php_pq_object_prophandler_dtor, 1);
zend_declare_property_null(php_pqcopy_class_entry, ZEND_STRL("connection"), ZEND_ACC_PUBLIC);
ph.read = php_pqcopy_object_read_connection;
+ ph.gc = php_pqcopy_object_gc_connection;
zend_hash_str_add_mem(&php_pqcopy_object_prophandlers, "connection", sizeof("connection")-1, (void *) &ph, sizeof(ph));
+ ph.gc = NULL;
zend_declare_property_null(php_pqcopy_class_entry, ZEND_STRL("expression"), ZEND_ACC_PUBLIC);
ph.read = php_pqcopy_object_read_expression;