Browse Source

- Ensure that ext/pgsql tests work when linked against 7.2 or lower libpq

PHP-5.1
Christopher Kings-Lynne 22 years ago
parent
commit
63ed4a1996
  1. 8
      ext/pgsql/tests/02connection.phpt
  2. 36
      ext/pgsql/tests/03sync_query.phpt
  3. 74
      ext/pgsql/tests/23sync_query_params.phpt
  4. 81
      ext/pgsql/tests/24sync_query_prepared.phpt
  5. 97
      ext/pgsql/tests/25async_query_params.phpt
  6. 158
      ext/pgsql/tests/26async_query_prepared.phpt

8
ext/pgsql/tests/02connection.phpt

@ -23,9 +23,11 @@ if (pg_connection_busy($db))
{
echo "pg_connection_busy() error\n";
}
if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE)
{
echo "pg_transaction_status() error\n";
if (function_exists('pg_transaction_status')) {
if (pg_transaction_status($db) != PGSQL_TRANSACTION_IDLE)
{
echo "pg_transaction_status() error\n";
}
}
if (!pg_host($db))
{

36
ext/pgsql/tests/03sync_query.phpt

@ -32,24 +32,26 @@ for ($i=0; $i < $rows; $i++)
}
pg_result_error($result);
pg_result_error_field($result, PGSQL_DIAG_SEVERITY);
pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
{
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
}
if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
{
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
if (function_exists('pg_result_error_field')) {
pg_result_error_field($result, PGSQL_DIAG_SEVERITY);
pg_result_error_field($result, PGSQL_DIAG_SQLSTATE);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_PRIMARY);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_DETAIL);
pg_result_error_field($result, PGSQL_DIAG_MESSAGE_HINT);
pg_result_error_field($result, PGSQL_DIAG_STATEMENT_POSITION);
if (defined('PGSQL_DIAG_INTERNAL_POSITION'))
{
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_POSITION);
}
if (defined('PGSQL_DIAG_INTERNAL_QUERY'))
{
pg_result_error_field($result, PGSQL_DIAG_INTERNAL_QUERY);
}
pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION);
}
pg_result_error_field($result, PGSQL_DIAG_CONTEXT);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FILE);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_LINE);
pg_result_error_field($result, PGSQL_DIAG_SOURCE_FUNCTION);
pg_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
pg_field_name($result, 0);

74
ext/pgsql/tests/23sync_query_params.phpt

@ -1,7 +1,10 @@
--TEST--
PostgreSQL sync query params
--SKIPIF--
<?php include("skipif.inc"); ?>
<?php
include("skipif.inc");
if (!function_exists('pg_query_params')) die('skip function pg_query_params() does not exist');
?>
--FILE--
<?php
@ -9,42 +12,45 @@ include('config.inc');
$db = pg_connect($conn_str);
$result = pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100));
if (!($rows = pg_num_rows($result)))
{
echo "pg_num_row() 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);
}
$version = pg_version($db);
if ($version['protocol'] >= 3) {
$result = pg_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100));
if (!($rows = pg_num_rows($result)))
{
echo "pg_num_row() 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_result_error($result);
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);
pg_result_error($result);
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);
$result = pg_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"));
pg_last_oid($result);
$result = pg_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC"));
pg_last_oid($result);
pg_free_result($result);
pg_free_result($result);
}
pg_close($db);
echo "OK";

81
ext/pgsql/tests/24sync_query_prepared.phpt

@ -12,48 +12,51 @@ include('config.inc');
$db = pg_connect($conn_str);
$result = pg_prepare($db, "php_test", "SELECT * FROM ".$table_name." WHERE num > \$1;");
pg_result_error($result);
pg_free_result($result);
$result = pg_execute($db, "php_test", array(100));
if (!($rows = pg_num_rows($result)))
{
echo "pg_num_row() 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);
}
$version = pg_version($db);
if ($version['protocol'] >= 3) {
$result = pg_prepare($db, "php_test", "SELECT * FROM ".$table_name." WHERE num > \$1;");
pg_result_error($result);
pg_free_result($result);
$result = pg_execute($db, "php_test", array(100));
if (!($rows = pg_num_rows($result)))
{
echo "pg_num_row() 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_result_error($result);
pg_num_rows(pg_execute($db, "php_test", array(100)));
pg_num_fields(pg_execute($db, "php_test", 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);
pg_result_error($result);
pg_num_rows(pg_execute($db, "php_test", array(100)));
pg_num_fields(pg_execute($db, "php_test", 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);
$result = pg_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);");
pg_result_error($result);
pg_free_result($result);
$result = pg_execute($db, "php_test2", array(9999, "A'BC"));
pg_last_oid($result);
$result = pg_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);");
pg_result_error($result);
pg_free_result($result);
$result = pg_execute($db, "php_test2", array(9999, "A'BC"));
pg_last_oid($result);
pg_free_result($result);
pg_free_result($result);
}
pg_close($db);
echo "OK";

97
ext/pgsql/tests/25async_query_params.phpt

@ -1,7 +1,10 @@
--TEST--
PostgreSQL async query params
--SKIPIF--
<?php include("skipif.inc"); ?>
<?php
include("skipif.inc");
if (!function_exists('pg_send_query_params')) die('skip function pg_send_query_params() does not exist');
?>
--FILE--
<?php
@ -9,53 +12,57 @@ include('config.inc');
$db = pg_connect($conn_str);
if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) {
echo "pg_send_query_params() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
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);
}
$version = pg_version($db);
if ($version['protocol'] >= 3) {
if (!pg_send_query_params($db, "SELECT * FROM ".$table_name." WHERE num > \$1;", array(100))) {
echo "pg_send_query_params() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
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);
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);
if (!pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")))
{
echo "pg_send_query_params() error\n";
}
if (!pg_send_query_params($db, "INSERT INTO ".$table_name." VALUES (\$1, \$2);", array(9999, "A'BC")))
{
echo "pg_send_query_params() error\n";
}
pg_last_oid($result);
pg_free_result($result);
pg_last_oid($result);
pg_free_result($result);
}
pg_close($db)
echo "OK";
?>

158
ext/pgsql/tests/26async_query_prepared.phpt

@ -12,89 +12,93 @@ include('config.inc');
$db = pg_connect($conn_str);
if (!pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;")) {
echo "pg_send_prepare() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
if (!($result = pg_get_result($db)))
{
echo "pg_get_result() error\n";
}
pg_free_result($result);
$version = pg_version($db);
if ($version['protocol'] >= 3) {
if (!pg_send_prepare($db, 'php_test', "SELECT * FROM ".$table_name." WHERE num > \$1;")) {
echo "pg_send_prepare() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
if (!($result = pg_get_result($db)))
{
echo "pg_get_result() error\n";
}
pg_free_result($result);
if (!pg_send_execute($db, 'php_test', array(100))) {
echo "pg_send_execute() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
if (!($result = pg_get_result($db)))
{
echo "pg_get_result() error\n";
}
if (!pg_send_execute($db, 'php_test', array(100))) {
echo "pg_send_execute() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
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);
}
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);
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);
if (!pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"))
{
echo "pg_send_prepare() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
if (!($result = pg_get_result($db)))
{
echo "pg_get_result() error\n";
}
pg_free_result($result);
if (!pg_send_prepare($db, "php_test2", "INSERT INTO ".$table_name." VALUES (\$1, \$2);"))
{
echo "pg_send_prepare() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
if (!($result = pg_get_result($db)))
{
echo "pg_get_result() error\n";
}
pg_free_result($result);
if (!pg_send_execute($db, "php_test2", array(9999, "A'BC")))
{
echo "pg_send_execute() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
if (!($result = pg_get_result($db)))
{
echo "pg_get_result() error\n";
}
if (!pg_send_execute($db, "php_test2", array(9999, "A'BC")))
{
echo "pg_send_execute() error\n";
}
while(pg_connection_busy($db)); // busy wait: intended
if (pg_connection_status($db) === PGSQL_CONNECTION_BAD) {
echo "pg_connection_status() error\n";
}
if (!($result = pg_get_result($db)))
{
echo "pg_get_result() error\n";
}
pg_last_oid($result);
pg_free_result($result);
pg_last_oid($result);
pg_free_result($result);
}
pg_close($db);
echo "OK";
?>

Loading…
Cancel
Save