chriskl Tue Mar 22 22:24:41 2005 EDT
Modified files:
/php-src/ext/pgsql/tests 02connection.phpt 03sync_query.phpt
23sync_query_params.phpt
24sync_query_prepared.phpt
25async_query_params.phpt
26async_query_prepared.phpt
Log:
- Ensure that ext/pgsql tests work when linked against 7.2 or lower libpq
http://cvs.php.net/diff.php/php-src/ext/pgsql/tests/02connection.phpt?r1=1.4&r2=1.5&ty=u
Index: php-src/ext/pgsql/tests/02connection.phpt
diff -u php-src/ext/pgsql/tests/02connection.phpt:1.4
php-src/ext/pgsql/tests/02connection.phpt:1.5
--- php-src/ext/pgsql/tests/02connection.phpt:1.4 Sat Mar 19 04:20:52 2005
+++ php-src/ext/pgsql/tests/02connection.phpt Tue Mar 22 22:24:41 2005
@@ -23,9 +23,11 @@
{
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))
{
http://cvs.php.net/diff.php/php-src/ext/pgsql/tests/03sync_query.phpt?r1=1.5&r2=1.6&ty=u
Index: php-src/ext/pgsql/tests/03sync_query.phpt
diff -u php-src/ext/pgsql/tests/03sync_query.phpt:1.5
php-src/ext/pgsql/tests/03sync_query.phpt:1.6
--- php-src/ext/pgsql/tests/03sync_query.phpt:1.5 Sat Mar 19 21:46:02 2005
+++ php-src/ext/pgsql/tests/03sync_query.phpt Tue Mar 22 22:24:41 2005
@@ -32,24 +32,26 @@
}
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 (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);
}
-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_num_rows(pg_query($db, "SELECT * FROM ".$table_name.";"));
pg_num_fields(pg_query($db, "SELECT * FROM ".$table_name.";"));
pg_field_name($result, 0);
http://cvs.php.net/diff.php/php-src/ext/pgsql/tests/23sync_query_params.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/pgsql/tests/23sync_query_params.phpt
diff -u php-src/ext/pgsql/tests/23sync_query_params.phpt:1.1
php-src/ext/pgsql/tests/23sync_query_params.phpt:1.2
--- php-src/ext/pgsql/tests/23sync_query_params.phpt:1.1 Sat Mar 19
03:46:56 2005
+++ php-src/ext/pgsql/tests/23sync_query_params.phpt Tue Mar 22 22:24:41 2005
@@ -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 @@
$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);
-}
-
-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);
+$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);
-$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";
http://cvs.php.net/diff.php/php-src/ext/pgsql/tests/24sync_query_prepared.phpt?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/pgsql/tests/24sync_query_prepared.phpt
diff -u php-src/ext/pgsql/tests/24sync_query_prepared.phpt:1.2
php-src/ext/pgsql/tests/24sync_query_prepared.phpt:1.3
--- php-src/ext/pgsql/tests/24sync_query_prepared.phpt:1.2 Sat Mar 19
05:58:44 2005
+++ php-src/ext/pgsql/tests/24sync_query_prepared.phpt Tue Mar 22 22:24:41 2005
@@ -12,48 +12,51 @@
$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";
http://cvs.php.net/diff.php/php-src/ext/pgsql/tests/25async_query_params.phpt?r1=1.1&r2=1.2&ty=u
Index: php-src/ext/pgsql/tests/25async_query_params.phpt
diff -u php-src/ext/pgsql/tests/25async_query_params.phpt:1.1
php-src/ext/pgsql/tests/25async_query_params.phpt:1.2
--- php-src/ext/pgsql/tests/25async_query_params.phpt:1.1 Sat Mar 19
03:46:56 2005
+++ php-src/ext/pgsql/tests/25async_query_params.phpt Tue Mar 22 22:24:41 2005
@@ -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 @@
$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);
+
+ 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_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";
+ pg_last_oid($result);
+ pg_free_result($result);
}
-
-pg_last_oid($result);
-pg_free_result($result);
+pg_close($db)
echo "OK";
?>
http://cvs.php.net/diff.php/php-src/ext/pgsql/tests/26async_query_prepared.phpt?r1=1.2&r2=1.3&ty=u
Index: php-src/ext/pgsql/tests/26async_query_prepared.phpt
diff -u php-src/ext/pgsql/tests/26async_query_prepared.phpt:1.2
php-src/ext/pgsql/tests/26async_query_prepared.phpt:1.3
--- php-src/ext/pgsql/tests/26async_query_prepared.phpt:1.2 Sat Mar 19
05:58:44 2005
+++ php-src/ext/pgsql/tests/26async_query_prepared.phpt Tue Mar 22 22:24:41 2005
@@ -12,89 +12,93 @@
$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);
-
-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);
-}
-
-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);
+$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 (!($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);
+
+ 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";
+ pg_last_oid($result);
+ pg_free_result($result);
}
-if (!($result = pg_get_result($db)))
-{
- echo "pg_get_result() error\n";
-}
-
-pg_last_oid($result);
-pg_free_result($result);
+pg_close($db);
echo "OK";
?>
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php