summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorChristopher Kings-Lynne <chriskl@php.net>2005-03-23 03:24:41 (GMT)
committerChristopher Kings-Lynne <chriskl@php.net>2005-03-23 03:24:41 (GMT)
commit63ed4a19965cbc7345acc8afd935ae5412077028 (patch)
tree16e76888a2db5cc44ef3b7060102f331d612719d /ext
parent9b1c9891fc02b400831e2e5eeee3ad66fb863239 (diff)
downloadphp-63ed4a19965cbc7345acc8afd935ae5412077028.tar.gz
- Ensure that ext/pgsql tests work when linked against 7.2 or lower libpq
Diffstat (limited to 'ext')
-rw-r--r--ext/pgsql/tests/02connection.phpt8
-rw-r--r--ext/pgsql/tests/03sync_query.phpt36
-rw-r--r--ext/pgsql/tests/23sync_query_params.phpt74
-rw-r--r--ext/pgsql/tests/24sync_query_prepared.phpt81
-rw-r--r--ext/pgsql/tests/25async_query_params.phpt97
-rw-r--r--ext/pgsql/tests/26async_query_prepared.phpt158
6 files changed, 239 insertions, 215 deletions
diff --git a/ext/pgsql/tests/02connection.phpt b/ext/pgsql/tests/02connection.phpt
index 761ddc2..6288d0e 100644
--- a/ext/pgsql/tests/02connection.phpt
+++ b/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))
{
diff --git a/ext/pgsql/tests/03sync_query.phpt b/ext/pgsql/tests/03sync_query.phpt
index 8a61496..afb6bb4 100644
--- a/ext/pgsql/tests/03sync_query.phpt
+++ b/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);
diff --git a/ext/pgsql/tests/23sync_query_params.phpt b/ext/pgsql/tests/23sync_query_params.phpt
index db1cfb2..6959cd7 100644
--- a/ext/pgsql/tests/23sync_query_params.phpt
+++ b/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";
diff --git a/ext/pgsql/tests/24sync_query_prepared.phpt b/ext/pgsql/tests/24sync_query_prepared.phpt
index ff16cb6..ea8f146 100644
--- a/ext/pgsql/tests/24sync_query_prepared.phpt
+++ b/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";
diff --git a/ext/pgsql/tests/25async_query_params.phpt b/ext/pgsql/tests/25async_query_params.phpt
index 2d0edbb..3244532 100644
--- a/ext/pgsql/tests/25async_query_params.phpt
+++ b/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";
?>
diff --git a/ext/pgsql/tests/26async_query_prepared.phpt b/ext/pgsql/tests/26async_query_prepared.phpt
index 90912ff..bda363b 100644
--- a/ext/pgsql/tests/26async_query_prepared.phpt
+++ b/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";
?>