1--TEST-- 2PostgreSQL non-blocking async queries 3--SKIPIF-- 4<?php 5include("skipif.inc"); 6if (!function_exists('pg_send_prepare')) die('skip function pg_send_prepare() does not exist'); 7?> 8--FILE-- 9<?php 10 11include('config.inc'); 12include('nonblocking.inc'); 13 14$db = pg_connect($conn_str); 15 16$version = pg_version($db); 17if ($version['protocol'] < 3) { 18 echo "OK"; 19 exit(0); 20} 21 22$db_socket = pg_socket($db); 23stream_set_blocking($db_socket, false); 24 25$nb_send = pg_send_query($db, "SELECT * FROM ".$table_name.";"); 26if ($nb_send === FALSE) { 27 echo "pg_send_query() error\n"; 28} elseif ($nb_send === 0) { 29 nb_flush($db, $db_socket); 30} 31 32nb_consume($db, $db_socket); 33 34if (!($result = pg_get_result($db))) { 35 echo "pg_get_result() error\n"; 36} 37 38if (!($rows = pg_num_rows($result))) { 39 echo "pg_num_rows() error\n"; 40} 41for ($i=0; $i < $rows; $i++) { 42 pg_fetch_array($result, $i, PGSQL_NUM); 43} 44for ($i=0; $i < $rows; $i++) { 45 pg_fetch_object($result); 46} 47for ($i=0; $i < $rows; $i++) { 48 pg_fetch_row($result, $i); 49} 50for ($i=0; $i < $rows; $i++) { 51 pg_fetch_result($result, $i, 0); 52} 53 54pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";")); 55pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";")); 56pg_field_name($result, 0); 57pg_field_num($result, $field_name); 58pg_field_size($result, 0); 59pg_field_type($result, 0); 60pg_field_prtlen($result, 0); 61pg_field_is_null($result, 0); 62 63$nb_send = pg_send_query($db, "INSERT INTO ".$table_name." VALUES (8888, 'GGG');"); 64if ($nb_send === FALSE) { 65 echo "pg_send_query() error\n"; 66} elseif ($nb_send === 0) { 67 nb_flush($db, $db_socket); 68} 69 70nb_consume($db, $db_socket); 71 72if (!($result = pg_get_result($db))) { 73 echo "pg_get_result() error\n"; 74} 75 76pg_last_oid($result); 77pg_free_result($result); 78pg_close($db); 79 80echo "OK"; 81?> 82--EXPECT-- 83OK 84 85