return &php_pqconn_resource_factory_ops;
}
-static void php_pqconn_wakeup(php_persistent_handle_factory_t *f, void **handle TSRMLS_DC)
+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);
return res;
}
-static int apply_unlisten(void *p TSRMLS_DC, int argc, va_list argv, zend_hash_key *key)
+static int apply_unlisten(zval *p, int argc, va_list argv, zend_hash_key *key)
{
php_pqconn_object_t *obj = va_arg(argv, php_pqconn_object_t *);
- PGresult *res = unlisten(obj->intern->conn, key->arKey, key->nKeyLength - 1 TSRMLS_CC);
+ 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;
{
zend_error_handling zeh;
char *channel_str;
- int channel_len;
+ size_t channel_len;
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", &channel_str, &channel_len);
- zend_restore_error_handling(&zeh TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh);
+ rv = zend_parse_parameters(ZEND_NUM_ARGS(), "s", &channel_str, &channel_len);
+ zend_restore_error_handling(&zeh);
if (SUCCESS == rv) {
- php_pqconn_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC);
+ php_pqconn_object_t *obj = PHP_PQ_OBJ(getThis(), NULL);
if (!obj->intern) {
- throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized");
- } else if (SUCCESS == zend_hash_del(&obj->intern->listeners, channel_str, channel_len + 1)) {
- PGresult *res = unlisten(obj->intern->conn, channel_str, channel_len TSRMLS_CC);
+ throw_exce(EX_UNINITIALIZED, "pq\\Connection not initialized");
+ } else if (SUCCESS == zend_hash_str_del(&obj->intern->listeners, channel_str, channel_len)) {
+ PGresult *res = unlisten(obj->intern->conn, channel_str, channel_len);
if (res) {
- php_pqres_success(res TSRMLS_CC);
+ php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
}
}
PQfreemem(quoted_channel);
if (!res) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to install listener (%s)", PHP_PQerrorMessage(obj->intern->conn));
+ throw_exce(EX_RUNTIME, "Failed to install listener (%s)", PHP_PQerrorMessage(obj->intern->conn));
} else {
- if (SUCCESS == php_pqres_success(res TSRMLS_CC)) {
+ if (SUCCESS == php_pqres_success(res)) {
obj->intern->poller = PQconsumeInput;
- php_pqconn_add_listener(obj, channel_str, channel_len, &listener TSRMLS_CC);
+ php_pqconn_add_listener(obj, channel_str, channel_len, &listener);
}
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
- php_pqconn_notify_listeners(obj TSRMLS_CC);
+ php_pqconn_notify_listeners(obj);
}
}
}
res = PQexecParams(obj->intern->conn, "select pg_notify($1, $2)", 2, NULL, (const char *const*) params, NULL, NULL, 0);
if (!res) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to notify listeners (%s)", PHP_PQerrorMessage(obj->intern->conn));
+ throw_exce(EX_RUNTIME, "Failed to notify listeners (%s)", PHP_PQerrorMessage(obj->intern->conn));
} else {
- php_pqres_success(res TSRMLS_CC);
+ php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
- php_pqconn_notify_listeners(obj TSRMLS_CC);
+ php_pqconn_notify_listeners(obj);
}
}
}
PGresult *res = php_pq_exec(obj->intern->conn, query_str);
if (!res) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to execute query (%s)", PHP_PQerrorMessage(obj->intern->conn));
- } else if (SUCCESS == php_pqres_success(res TSRMLS_CC)) {
- php_pq_object_to_zval_no_addref(PQresultInstanceData(res, php_pqconn_event), &return_value TSRMLS_CC);
+ throw_exce(EX_RUNTIME, "Failed to execute query (%s)", PHP_PQerrorMessage(obj->intern->conn));
+ } 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 TSRMLS_CC);
+ php_pqconn_notify_listeners(obj);
}
}
}
php_pq_params_free(¶ms);
if (!res) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to execute query (%s)", PHP_PQerrorMessage(obj->intern->conn));
+ throw_exce(EX_RUNTIME, "Failed to execute query (%s)", PHP_PQerrorMessage(obj->intern->conn));
} else {
- if (SUCCESS == php_pqres_success(res TSRMLS_CC)) {
- php_pq_object_to_zval_no_addref(PQresultInstanceData(res, php_pqconn_event), &return_value TSRMLS_CC);
+ 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 TSRMLS_CC);
+ php_pqconn_notify_listeners(obj);
}
}
}
if (!res) {
rv = FAILURE;
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to prepare statement (%s)", PHP_PQerrorMessage(obj->intern->conn));
+ throw_exce(EX_RUNTIME, "Failed to prepare statement (%s)", PHP_PQerrorMessage(obj->intern->conn));
} else {
- rv = php_pqres_success(res TSRMLS_CC);
+ rv = php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
- php_pqconn_notify_listeners(obj TSRMLS_CC);
+ php_pqconn_notify_listeners(obj);
}
return rv;
if (!res) {
rv = FAILURE;
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to declare cursor (%s)", PHP_PQerrorMessage(obj->intern->conn));
+ throw_exce(EX_RUNTIME, "Failed to declare cursor (%s)", PHP_PQerrorMessage(obj->intern->conn));
} else {
- rv = php_pqres_success(res TSRMLS_CC);
+ rv = php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
- php_pqconn_notify_listeners(obj TSRMLS_CC);
+ php_pqconn_notify_listeners(obj);
}
return rv;
smart_str_appends(&cmd, " DEFERRABLE");
smart_str_0(&cmd);
- res = php_pq_exec(conn_obj->intern->conn, cmd.c);
+ res = php_pq_exec(conn_obj->intern->conn, smart_str_v(&cmd));
if (!res) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to start transaction (%s)", PHP_PQerrorMessage(conn_obj->intern->conn));
+ throw_exce(EX_RUNTIME, "Failed to start transaction (%s)", PHP_PQerrorMessage(conn_obj->intern->conn));
} else {
- rv = php_pqres_success(res TSRMLS_CC);
+ rv = php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
- php_pqconn_notify_listeners(conn_obj TSRMLS_CC);
+ php_pqconn_notify_listeners(conn_obj);
}
smart_str_free(&cmd);
PGresult *res = php_pq_exec(obj->intern->conn->intern->conn, "ROLLBACK");
if (res) {
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
}
- php_pq_object_delref(obj->intern->conn TSRMLS_CC);
+ php_pq_object_delref(obj->intern->conn);
efree(obj->intern);
obj->intern = NULL;
}
break;
}
- if (zisolation != value) {
- zval_ptr_dtor(&zisolation);
- }
-
if (res) {
- php_pqres_success(res TSRMLS_CC);
+ php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
}
}
if (res) {
- php_pqres_success(res TSRMLS_CC);
+ php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
}
}
if (res) {
- php_pqres_success(res TSRMLS_CC);
+ php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
}
smart_str_appends(&cmd, "\"");
smart_str_0(&cmd);
- res = php_pq_exec(obj->intern->conn->intern->conn, cmd.c);
+ res = php_pq_exec(obj->intern->conn->intern->conn, smart_str_v(&cmd));
if (!res) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to create %s (%s)", cmd.c, PHP_PQerrorMessage(obj->intern->conn->intern->conn));
+ throw_exce(EX_RUNTIME, "Failed to create %s (%s)", smart_str_v(&cmd), PHP_PQerrorMessage(obj->intern->conn->intern->conn));
} else {
- php_pqres_success(res TSRMLS_CC);
+ php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
smart_str_free(&cmd);
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));
+ throw_exce(EX_RUNTIME, "Failed to export transaction snapshot (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
} else {
- if (SUCCESS == php_pqres_success(res TSRMLS_CC)) {
- RETVAL_STRING(PQgetvalue(res, 0, 0), 1);
+ if (SUCCESS == php_pqres_success(res)) {
+ RETVAL_STRING(PQgetvalue(res, 0, 0));
}
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
- php_pqconn_notify_listeners(obj->intern->conn TSRMLS_CC);
+ php_pqconn_notify_listeners(obj->intern->conn);
}
}
}
smart_str_appends(&cmd, sid);
smart_str_0(&cmd);
- res = php_pq_exec(obj->intern->conn->intern->conn, cmd.c);
+ res = php_pq_exec(obj->intern->conn->intern->conn, smart_str_v(&cmd));
if (!res) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to import transaction snapshot (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
+ throw_exce(EX_RUNTIME, "Failed to import transaction snapshot (%s)", PHP_PQerrorMessage(obj->intern->conn->intern->conn));
} else {
- php_pqres_success(res TSRMLS_CC);
+ php_pqres_success(res);
- php_pq_clear_res(res);
+ php_pqres_clear(res);
}
smart_str_free(&cmd);