static zend_object_handlers php_pqtxn_object_handlers;
static HashTable php_pqtxn_object_prophandlers;
-const char *isolation_level(long *isolation)
+const char *php_pq_isolation_level(long *isolation)
{
switch (*isolation) {
case PHP_PQTXN_SERIALIZABLE:
fprintf(stderr, "FREE txn(#%d) %p (conn(#%d): %p)\n", obj->zv.handle, obj, obj->intern->conn->zv.handle, obj->intern->conn);
#endif
if (obj->intern) {
- if (obj->intern->open) {
+ if (obj->intern->open && obj->intern->conn->intern) {
PGresult *res = PQexec(obj->intern->conn->intern->conn, "ROLLBACK");
if (res) {
php_pqtxn_object_t *obj = o;
PGresult *res;
- if ((obj->intern->readonly = zend_is_true(value))) {
+ if ((obj->intern->readonly = z_is_true(value))) {
res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION READ ONLY");
} else {
res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION READ WRITE");
php_pqtxn_object_t *obj = o;
PGresult *res;
- if ((obj->intern->deferrable = zend_is_true(value))) {
+ if ((obj->intern->deferrable = z_is_true(value))) {
res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION DEFERRABLE");
} else {
res = PQexec(obj->intern->conn->intern->conn, "SET TRANSACTION NOT DEFERRABLE");
zval *zconn;
long isolation = PHP_PQTXN_READ_COMMITTED;
zend_bool async = 0, readonly = 0, deferrable = 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, "O|blbb", &zconn, php_pqconn_class_entry, &async, &isolation, &readonly, &deferrable);
if (!conn_obj->intern) {
throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized");
} else {
+
+ switch (ZEND_NUM_ARGS()) {
+ case 1:
+ case 2:
+ isolation = conn_obj->intern->default_txn_isolation;
+ /* no break */
+ case 3:
+ readonly = conn_obj->intern->default_txn_readonly;
+ /* no break */
+ case 4:
+ deferrable = conn_obj->intern->default_txn_deferrable;
+ break;
+ }
+
if (async) {
rv = php_pqconn_start_transaction_async(zconn, conn_obj, isolation, readonly, deferrable TSRMLS_CC);
} else {
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, savepoint) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, savepointAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, commit) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
if (!obj->intern) {
throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Transacation not initialized");
} else if (!obj->intern->open) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\Transacation already closed");
+ throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\Transaction already closed");
} else {
PGresult *res;
smart_str cmd = {0};
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, commitAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, rollback) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, rollbackAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, exportSnapshot) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
ZEND_END_ARG_INFO();
static PHP_METHOD(pqtxn, exportSnapshotAsync) {
zend_error_handling zeh;
- STATUS rv;
+ ZEND_RESULT_CODE rv;
zend_replace_error_handling(EH_THROW, exce(EX_INVALID_ARGUMENT), &zeh TSRMLS_CC);
rv = zend_parse_parameters_none();
zend_error_handling zeh;
char *snapshot_str;
int snapshot_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", &snapshot_str, &snapshot_len);
zend_error_handling zeh;
char *snapshot_str;
int snapshot_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", &snapshot_str, &snapshot_len);
static PHP_METHOD(pqtxn, openLOB) {
zend_error_handling zeh;
long mode = INV_WRITE|INV_READ, loid;
- 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, "l|l", &loid, &mode);
int lofd = lo_open(obj->intern->conn->intern->conn, loid, mode);
if (lofd < 0) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to open large object with oid=%u with mode '%s' (%s)", loid, strmode(mode), PHP_PQerrorMessage(obj->intern->conn->intern->conn));
+ throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to open large object with oid=%u with mode '%s' (%s)", loid, php_pq_strmode(mode), PHP_PQerrorMessage(obj->intern->conn->intern->conn));
} else {
php_pqlob_t *lob = ecalloc(1, sizeof(*lob));
static PHP_METHOD(pqtxn, createLOB) {
zend_error_handling zeh;
long mode = INV_WRITE|INV_READ;
- 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, "|l", &mode);
Oid loid = lo_creat(obj->intern->conn->intern->conn, mode);
if (loid == InvalidOid) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to create large object with mode '%s' (%s)", strmode(mode), PHP_PQerrorMessage(obj->intern->conn->intern->conn));
+ throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to create large object with mode '%s' (%s)", php_pq_strmode(mode), PHP_PQerrorMessage(obj->intern->conn->intern->conn));
} else {
int lofd = lo_open(obj->intern->conn->intern->conn, loid, mode);
if (lofd < 0) {
- throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to open large object with oid=%u with mode '%s': %s", loid, strmode(mode), PHP_PQerrorMessage(obj->intern->conn->intern->conn));
+ throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to open large object with oid=%u with mode '%s': %s", loid, php_pq_strmode(mode), PHP_PQerrorMessage(obj->intern->conn->intern->conn));
} else {
php_pqlob_t *lob = ecalloc(1, sizeof(*lob));
static PHP_METHOD(pqtxn, unlinkLOB) {
zend_error_handling zeh;
long loid;
- 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, "l", &loid);
char *path_str;
int path_len;
long oid = InvalidOid;
- 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, "p|l", &path_str, &path_len, &oid);
char *path_str;
int path_len;
long oid;
- 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, "lp", &oid, &path_str, &path_len);
{0}
};
+PHP_MSHUTDOWN_FUNCTION(pqtxn)
+{
+ zend_hash_destroy(&php_pqtxn_object_prophandlers);
+ return SUCCESS;
+}
+
PHP_MINIT_FUNCTION(pqtxn)
{
zend_class_entry ce = {0};
php_pqtxn_object_handlers.write_property = php_pq_object_write_prop;
php_pqtxn_object_handlers.clone_obj = NULL;
php_pqtxn_object_handlers.get_property_ptr_ptr = NULL;
+ php_pqtxn_object_handlers.get_gc = NULL;
php_pqtxn_object_handlers.get_properties = php_pq_object_properties;
php_pqtxn_object_handlers.get_debug_info = php_pq_object_debug_info;