From: Christopher Kings-Lynne Date: Wed, 23 Mar 2005 03:24:41 +0000 (+0000) Subject: - Ensure that ext/pgsql tests work when linked against 7.2 or lower libpq X-Git-Tag: php-5.0.1b1~705 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=63ed4a19965cbc7345acc8afd935ae5412077028;p=php - Ensure that ext/pgsql tests work when linked against 7.2 or lower libpq --- diff --git a/ext/pgsql/tests/02connection.phpt b/ext/pgsql/tests/02connection.phpt index 761ddc22a3..6288d0e179 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 8a61496e00..afb6bb4475 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 db1cfb24f9..6959cd75a7 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-- - + --FILE-- \$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 ff16cb69cf..ea8f14661a 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 2d0edbb724..3244532094 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-- - + --FILE-- \$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 90912ff0b7..bda363b750 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"; ?>