X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=blobdiff_plain;f=src%2Fphp_pqlob.c;h=f70ed3aafdb3461f911622a58fcefad965d53476;hp=1188907c9ff1a40b4869b87f0f25c0e63110361e;hb=7d954192543192f2ef9b0db27f22b7807de31749;hpb=5aa292d5bc46cd8fe266d682397dba19dc1e1d36 diff --git a/src/php_pqlob.c b/src/php_pqlob.c index 1188907..f70ed3a 100644 --- a/src/php_pqlob.c +++ b/src/php_pqlob.c @@ -243,9 +243,12 @@ static PHP_METHOD(pqlob, __construct) { zend_restore_error_handling(&zeh TSRMLS_CC); if (SUCCESS == rv) { + php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); php_pqtxn_object_t *txn_obj = zend_object_store_get_object(ztxn TSRMLS_CC); - if (!txn_obj->intern) { + if (obj->intern) { + throw_exce(EX_BAD_METHODCALL TSRMLS_CC, "pq\\LOB already initialized"); + } else if (!txn_obj->intern) { throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Transaction not initialized"); } else if (!txn_obj->intern->open) { throw_exce(EX_RUNTIME TSRMLS_CC, "pq\\Transation already closed"); @@ -255,15 +258,13 @@ static PHP_METHOD(pqlob, __construct) { } if (loid == InvalidOid) { - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to create large object with mode '%s' (%s)", strmode(mode), PHP_PQerrorMessage(txn_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(txn_obj->intern->conn->intern->conn)); } else { int lofd = lo_open(txn_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(txn_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(txn_obj->intern->conn->intern->conn)); } else { - php_pqlob_object_t *obj = zend_object_store_get_object(getThis() TSRMLS_CC); - obj->intern = ecalloc(1, sizeof(*obj->intern)); obj->intern->lofd = lofd; obj->intern->loid = loid; @@ -449,6 +450,12 @@ static zend_function_entry php_pqlob_methods[] = { {0} }; +PHP_MSHUTDOWN_FUNCTION(pqlob) +{ + zend_hash_destroy(&php_pqlob_object_prophandlers); + return SUCCESS; +} + PHP_MINIT_FUNCTION(pqlob) { zend_class_entry ce = {0};