X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fext-pq;a=blobdiff_plain;f=src%2Fphp_pqconn.c;h=16d3f772c92ad9746bfeecfb941a0257526d937c;hp=7b1fbd926d49e7e2f32150449d4c2ccfc77f83c5;hb=18f89e2c907e17962ec4bb99d5c9b56b17678a06;hpb=a840b29b5fc3f841f39acd1ae47e957d7db29583 diff --git a/src/php_pqconn.c b/src/php_pqconn.c index 7b1fbd9..16d3f77 100644 --- a/src/php_pqconn.c +++ b/src/php_pqconn.c @@ -301,6 +301,7 @@ static void php_pqconn_object_read_port(zval *object, void *o, zval *return_valu } } +#if HAVE_PQCONNINFO static void php_pqconn_object_read_params(zval *object, void *o, zval *return_value TSRMLS_DC) { php_pqconn_object_t *obj = o; @@ -319,6 +320,7 @@ static void php_pqconn_object_read_params(zval *object, void *o, zval *return_va PQconninfoFree(params); } } +#endif static void php_pqconn_object_read_options(zval *object, void *o, zval *return_value TSRMLS_DC) { @@ -1131,8 +1133,10 @@ static PHP_METHOD(pqconn, execAsync) { throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized"); } else if (!PQsendQuery(obj->intern->conn, query_str)) { throw_exce(EX_IO TSRMLS_CC, "Failed to execute query (%s)", PHP_PQerrorMessage(obj->intern->conn)); +#if HAVE_PQSETSINGLEROWMODE } else if (obj->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn)) { throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn)); +#endif } else { php_pq_callback_recurse(&obj->intern->onevent, &resolver TSRMLS_CC); obj->intern->poller = PQconsumeInput; @@ -1220,8 +1224,10 @@ static PHP_METHOD(pqconn, execParamsAsync) { if (!rc) { throw_exce(EX_IO TSRMLS_CC, "Failed to execute query (%s)", PHP_PQerrorMessage(obj->intern->conn)); +#if HAVE_PQSETSINGLEROWMODE } else if (obj->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn)) { throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn)); +#endif } else { php_pq_callback_recurse(&obj->intern->onevent, &resolver TSRMLS_CC); obj->intern->poller = PQconsumeInput; @@ -1308,9 +1314,6 @@ STATUS php_pqconn_prepare_async(zval *object, php_pqconn_object_t *obj, const ch if (!PQsendPrepare(obj->intern->conn, name, query, params->type.count, params->type.oids)) { rv = FAILURE; throw_exce(EX_IO TSRMLS_CC, "Failed to prepare statement (%s)", PHP_PQerrorMessage(obj->intern->conn)); - } else if (obj->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn)) { - rv = FAILURE; - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn)); } else { rv = SUCCESS; obj->intern->poller = PQconsumeInput; @@ -1438,9 +1441,6 @@ STATUS php_pqconn_declare_async(zval *object, php_pqconn_object_t *obj, const ch if (!PQsendQuery(obj->intern->conn, decl)) { rv = FAILURE; throw_exce(EX_IO TSRMLS_CC, "Failed to declare cursor (%s)", PHP_PQerrorMessage(obj->intern->conn)); - } else if (obj->intern->unbuffered && !PQsetSingleRowMode(obj->intern->conn)) { - rv = FAILURE; - throw_exce(EX_RUNTIME TSRMLS_CC, "Failed to enable unbuffered mode (%s)", PHP_PQerrorMessage(obj->intern->conn)); } else { rv = SUCCESS; obj->intern->poller = PQconsumeInput; @@ -1611,7 +1611,7 @@ STATUS php_pqconn_start_transaction(zval *zconn, php_pqconn_object_t *conn_obj, } else { PGresult *res; smart_str cmd = {0}; - const char *il = isolation_level(&isolation); + const char *il = php_pq_isolation_level(&isolation); smart_str_appends(&cmd, "START TRANSACTION ISOLATION LEVEL "); smart_str_appends(&cmd, il); @@ -1650,7 +1650,7 @@ STATUS php_pqconn_start_transaction_async(zval *zconn, php_pqconn_object_t *conn throw_exce(EX_UNINITIALIZED TSRMLS_CC, "pq\\Connection not initialized"); } else { smart_str cmd = {0}; - const char *il = isolation_level(&isolation); + const char *il = php_pq_isolation_level(&isolation); smart_str_appends(&cmd, "START TRANSACTION ISOLATION LEVEL "); smart_str_appends(&cmd, il); @@ -1736,6 +1736,7 @@ static PHP_METHOD(pqconn, startTransactionAsync) { php_pq_object_addref(obj TSRMLS_CC); txn->conn = obj; + txn->open = 1; txn->isolation = isolation; txn->readonly = readonly; txn->deferrable = deferrable; @@ -2044,9 +2045,11 @@ PHP_MINIT_FUNCTION(pqconn) ph.read = php_pqconn_object_read_port; zend_hash_add(&php_pqconn_object_prophandlers, "port", sizeof("port"), (void *) &ph, sizeof(ph), NULL); +#if HAVE_PQCONNINFO zend_declare_property_null(php_pqconn_class_entry, ZEND_STRL("params"), ZEND_ACC_PUBLIC TSRMLS_CC); ph.read = php_pqconn_object_read_params; zend_hash_add(&php_pqconn_object_prophandlers, "params", sizeof("params"), (void *) &ph, sizeof(ph), NULL); +#endif zend_declare_property_null(php_pqconn_class_entry, ZEND_STRL("options"), ZEND_ACC_PUBLIC TSRMLS_CC); ph.read = php_pqconn_object_read_options;