diff options
Diffstat (limited to 'ext/pgsql')
-rw-r--r-- | ext/pgsql/pgsql.c | 16 | ||||
-rwxr-xr-x | ext/pgsql/tests/30nb_async_query_params.phpt | 156 |
2 files changed, 79 insertions, 93 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 6da01d448b..1f88bf4205 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -1510,20 +1510,6 @@ err: } /* }}} */ -#if 0 -/* {{{ php_pgsql_get_default_link - */ -static int php_pgsql_get_default_link(INTERNAL_FUNCTION_PARAMETERS) -{ - if (PGG(default_link)==-1) { /* no link opened yet, implicitly open one */ - ht = 0; - php_pgsql_do_connect(INTERNAL_FUNCTION_PARAM_PASSTHRU,0); - } - return PGG(default_link); -} -/* }}} */ -#endif - /* {{{ proto resource pg_connect(string connection_string[, int connect_type] | [string host, string port [, string options [, string tty,]]] string database) Open a PostgreSQL connection */ PHP_FUNCTION(pg_connect) @@ -7052,7 +7038,7 @@ PHP_PGSQL_API int php_pgsql_result2array(PGresult *pg_result, zval *ret_array, l char *field_name; size_t num_fields; int pg_numrows, pg_row; - uint i; + uint32_t i; assert(Z_TYPE_P(ret_array) == IS_ARRAY); if ((pg_numrows = PQntuples(pg_result)) <= 0) { diff --git a/ext/pgsql/tests/30nb_async_query_params.phpt b/ext/pgsql/tests/30nb_async_query_params.phpt index a88769b038..1c8a1eed8f 100755 --- a/ext/pgsql/tests/30nb_async_query_params.phpt +++ b/ext/pgsql/tests/30nb_async_query_params.phpt @@ -1,78 +1,78 @@ ---TEST--
-PostgreSQL non-blocking async query params
---SKIPIF--
-<?php
-include("skipif.inc");
-if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
-?>
---FILE--
-<?php
-
-include('config.inc');
-include('nonblocking.inc');
-
-$db = pg_connect($conn_str);
-
-$version = pg_version($db);
-if ($version['protocol'] < 3) {
- echo "OK";
- exit(0);
-}
-
-$db_socket = pg_socket($db);
-stream_set_blocking($db_socket, false);
-
-$sent = pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100));
-if ($sent === FALSE) {
- echo "pg_send_query_params() error\n";
-} elseif ($sent === 0) {
- nb_flush($db, $db_socket);
-}
-
-nb_consume($db, $db_socket);
-
-if (!($result = pg_get_result($db))) {
- echo "pg_get_result() error\n";
-}
-if (!($rows = pg_num_rows($result))) {
- echo "pg_num_rows() error\n";
-}
-for ($i=0; $i < $rows; $i++) {
- pg_fetch_array($result, $i, PGSQL_NUM);
-}
-for ($i=0; $i < $rows; $i++) {
- pg_fetch_object($result);
-}
-for ($i=0; $i < $rows; $i++) {
- pg_fetch_row($result, $i);
-}
-for ($i=0; $i < $rows; $i++) {
- pg_fetch_result($result, $i, 0);
-}
-
-pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
-pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)));
-pg_field_name($result, 0);
-pg_field_num($result, $field_name);
-pg_field_size($result, 0);
-pg_field_type($result, 0);
-pg_field_prtlen($result, 0);
-pg_field_is_null($result, 0);
-
-$sent = pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"));
-
-if ($sent === FALSE) {
- echo "pg_send_query_params() error\n";
-} elseif ($sent === 0) {
- nb_flush($db, $db_socket);
-}
-
-pg_last_oid($result);
-pg_free_result($result);
-
-pg_close($db);
-
-echo "OK";
-?>
---EXPECT--
-OK
+--TEST-- +PostgreSQL non-blocking async query params +--SKIPIF-- +<?php +include("skipif.inc"); +if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist'); +?> +--FILE-- +<?php + +include('config.inc'); +include('nonblocking.inc'); + +$db = pg_connect($conn_str); + +$version = pg_version($db); +if ($version['protocol'] < 3) { + echo "OK"; + exit(0); +} + +$db_socket = pg_socket($db); +stream_set_blocking($db_socket, false); + +$sent = pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100)); +if ($sent === FALSE) { + echo "pg_send_query_params() error\n"; +} elseif ($sent === 0) { + nb_flush($db, $db_socket); +} + +nb_consume($db, $db_socket); + +if (!($result = pg_get_result($db))) { + echo "pg_get_result() error\n"; +} +if (!($rows = pg_num_rows($result))) { + echo "pg_num_rows() error\n"; +} +for ($i=0; $i < $rows; $i++) { + pg_fetch_array($result, $i, PGSQL_NUM); +} +for ($i=0; $i < $rows; $i++) { + pg_fetch_object($result); +} +for ($i=0; $i < $rows; $i++) { + pg_fetch_row($result, $i); +} +for ($i=0; $i < $rows; $i++) { + pg_fetch_result($result, $i, 0); +} + +pg_num_rows(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); +pg_num_fields(pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))); +pg_field_name($result, 0); +pg_field_num($result, $field_name); +pg_field_size($result, 0); +pg_field_type($result, 0); +pg_field_prtlen($result, 0); +pg_field_is_null($result, 0); + +$sent = pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")); + +if ($sent === FALSE) { + echo "pg_send_query_params() error\n"; +} elseif ($sent === 0) { + nb_flush($db, $db_socket); +} + +pg_last_oid($result); +pg_free_result($result); + +pg_close($db); + +echo "OK"; +?> +--EXPECT-- +OK |