mbeccati                                 Fri, 25 Dec 2009 20:56:00 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=292633

Log:
- Updated ext/pgsql tests to work w/ PostgreSQL 8.5
# tested w/ 8.5alpha3

Changed paths:
    U   php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert.phpt
    A + php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert_85.phpt
        (from 
php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert.phpt:r292601)
    U   php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert.phpt
    A + php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert_85.phpt
        (from 
php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert.phpt:r292601)
    U   php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select.phpt
    A + php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select_85.phpt
        (from 
php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select.phpt:r292601)
    U   php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update.phpt
    A + php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update_85.phpt
        (from 
php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update.phpt:r292601)
    U   php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100.phpt
    A + php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100_85.phpt
        (from 
php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100.phpt:r292601)
    U   php/php-src/branches/PHP_5_2/ext/pgsql/tests/skipif.inc
    U   php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert.phpt
    A + php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert_85.phpt
        (from 
php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert.phpt:r292601)
    U   php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert.phpt
    A + php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert_85.phpt
        (from 
php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert.phpt:r292601)
    U   php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select.phpt
    A + php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select_85.phpt
        (from 
php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select.phpt:r292601)
    U   php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update.phpt
    A + php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update_85.phpt
        (from 
php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update.phpt:r292601)
    U   php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100.phpt
    A + php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100_85.phpt
        (from 
php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100.phpt:r292601)
    U   php/php-src/branches/PHP_5_3/ext/pgsql/tests/skipif.inc
    U   php/php-src/trunk/ext/pgsql/tests/08escape.phpt
    A + php/php-src/trunk/ext/pgsql/tests/08escape_85.phpt
        (from php/php-src/trunk/ext/pgsql/tests/08escape.phpt:r292622)
    U   php/php-src/trunk/ext/pgsql/tests/10pg_convert.phpt
    A + php/php-src/trunk/ext/pgsql/tests/10pg_convert_85.phpt
        (from php/php-src/trunk/ext/pgsql/tests/10pg_convert.phpt:r292622)
    U   php/php-src/trunk/ext/pgsql/tests/12pg_insert.phpt
    A + php/php-src/trunk/ext/pgsql/tests/12pg_insert_85.phpt
        (from php/php-src/trunk/ext/pgsql/tests/12pg_insert.phpt:r292622)
    U   php/php-src/trunk/ext/pgsql/tests/13pg_select.phpt
    A + php/php-src/trunk/ext/pgsql/tests/13pg_select_85.phpt
        (from php/php-src/trunk/ext/pgsql/tests/13pg_select.phpt:r292622)
    U   php/php-src/trunk/ext/pgsql/tests/14pg_update.phpt
    A + php/php-src/trunk/ext/pgsql/tests/14pg_update_85.phpt
        (from php/php-src/trunk/ext/pgsql/tests/14pg_update.phpt:r292622)
    U   php/php-src/trunk/ext/pgsql/tests/bug37100.phpt
    A + php/php-src/trunk/ext/pgsql/tests/bug37100_85.phpt
        (from php/php-src/trunk/ext/pgsql/tests/bug37100.phpt:r292622)
    U   php/php-src/trunk/ext/pgsql/tests/skipif.inc

Modified: php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_convert()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert_85.phpt (from rev 292601, php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert.phpt)
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/10pg_convert_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,29 @@
+--TEST--
+PostgreSQL pg_convert() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+$converted = pg_convert($db, $table_name, $fields);
+
+var_dump($converted);
+?>
+--EXPECT--
+array(3) {
+  ["num"]=>
+  string(4) "1234"
+  ["str"]=>
+  string(5) "'AAA'"
+  ["bin"]=>
+  string(11) "'\\x424242'"
+}

Modified: php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_insert()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert_85.phpt (from rev 292601, php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert.phpt)
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/12pg_insert_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,24 @@
+--TEST--
+PostgreSQL pg_insert() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+
+pg_insert($db, $table_name, $fields) or print "Error in test 1\n";
+echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
+?>
+--EXPECT--
+INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','\\x424242');
+Ok

Modified: php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_select()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select_85.phpt (from rev 292601, php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select.phpt)
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/13pg_select_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,37 @@
+--TEST--
+PostgreSQL pg_select() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+$res = pg_select($db, $table_name, $ids) or print "Error\n";
+var_dump($res);
+echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
+echo "Ok\n";
+
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  array(3) {
+    ["num"]=>
+    string(4) "1234"
+    ["str"]=>
+    string(3) "AAA"
+    ["bin"]=>
+    string(8) "\x424242"
+  }
+}
+SELECT * FROM php_pgsql_test WHERE num=1234;
+Ok

Modified: php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_update()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update_85.phpt (from rev 292601, php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update.phpt)
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/14pg_update_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,25 @@
+--TEST--
+PostgreSQL pg_update() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
+echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
+?>
+--EXPECT--
+UPDATE php_pgsql_test SET num=1234,str='ABC',bin='\\x58595a' WHERE num=1234;
+Ok

Modified: php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 Bug #37100 (data is returned truncated with BINARY CURSOR)
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php


Copied: php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100_85.phpt (from rev 292601, php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100.phpt)
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/bug37100_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,46 @@
+--TEST--
+Bug #37100 (data is returned truncated with BINARY CURSOR) (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+...@pg_query('DROP TABLE test_bug');
+
+pg_query('CREATE TABLE test_bug (binfield byteA) ;');
+pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
+
+
+$data = pg_query("SELECT binfield FROM test_bug");
+$res = pg_fetch_result($data,0);
+var_dump($res);
+var_dump(bin2hex(pg_unescape_bytea($res)));
+
+$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test_bug; FETCH ALL IN mycursor;";
+
+$data = pg_query($sql);
+$res = pg_fetch_result($data,0);
+
+var_dump(strlen($res));
+var_dump(bin2hex($res));
+
+pg_close($db);
+
+$db = pg_connect($conn_str);
+pg_query('DROP TABLE test_bug');
+pg_close($db);
+
+
+?>
+--EXPECT--
+string(14) "\x0103aa000812"
+string(12) "0103aa000812"
+int(6)
+string(12) "0103aa000812"

Modified: php/php-src/branches/PHP_5_2/ext/pgsql/tests/skipif.inc
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/tests/skipif.inc	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/tests/skipif.inc	2009-12-25 20:56:00 UTC (rev 292633)
@@ -15,4 +15,17 @@
 if (!is_resource($conn)) {
     die("skip could not connect\n");
 }
-?>
\ No newline at end of file
+
+function skip_server_version($version, $op = '<') { _skip_version('server', $version, $op); }
+function skip_client_version($version, $op = '<') { _skip_version('client', $version, $op); }
+
+
+function _skip_version($type, $version, $op)
+{
+	$pg = pg_parameter_status($type.'_version');
+	if (version_compare($pg, $version, $op)) {
+		die("skip {$type} version {$pg} is {$op} {$version}\n");
+	}
+}
+
+?>

Modified: php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_convert()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert_85.phpt (from rev 292601, php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/10pg_convert_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,29 @@
+--TEST--
+PostgreSQL pg_convert() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+$converted = pg_convert($db, $table_name, $fields);
+
+var_dump($converted);
+?>
+--EXPECT--
+array(3) {
+  ["num"]=>
+  string(4) "1234"
+  ["str"]=>
+  string(5) "'AAA'"
+  ["bin"]=>
+  string(11) "'\\x424242'"
+}

Modified: php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_insert()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert_85.phpt (from rev 292601, php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/12pg_insert_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,24 @@
+--TEST--
+PostgreSQL pg_insert() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+
+pg_insert($db, $table_name, $fields) or print "Error in test 1\n";
+echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
+?>
+--EXPECT--
+INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','\\x424242');
+Ok

Modified: php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_select()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select_85.phpt (from rev 292601, php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/13pg_select_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,37 @@
+--TEST--
+PostgreSQL pg_select() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+$res = pg_select($db, $table_name, $ids) or print "Error\n";
+var_dump($res);
+echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
+echo "Ok\n";
+
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  array(3) {
+    ["num"]=>
+    string(4) "1234"
+    ["str"]=>
+    string(3) "AAA"
+    ["bin"]=>
+    string(8) "\x424242"
+  }
+}
+SELECT * FROM php_pgsql_test WHERE num=1234;
+Ok

Modified: php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_update()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update_85.phpt (from rev 292601, php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/14pg_update_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,25 @@
+--TEST--
+PostgreSQL pg_update() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
+echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
+?>
+--EXPECT--
+UPDATE php_pgsql_test SET num=1234,str='ABC',bin='\\x58595a' WHERE num=1234;
+Ok

Modified: php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 Bug #37100 (data is returned truncated with BINARY CURSOR)
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php


Copied: php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100_85.phpt (from rev 292601, php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100.phpt)
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100_85.phpt	                        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/bug37100_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,46 @@
+--TEST--
+Bug #37100 (data is returned truncated with BINARY CURSOR) (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+...@pg_query('DROP TABLE test_bug');
+
+pg_query('CREATE TABLE test_bug (binfield byteA) ;');
+pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
+
+
+$data = pg_query("SELECT binfield FROM test_bug");
+$res = pg_fetch_result($data,0);
+var_dump($res);
+var_dump(bin2hex(pg_unescape_bytea($res)));
+
+$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test_bug; FETCH ALL IN mycursor;";
+
+$data = pg_query($sql);
+$res = pg_fetch_result($data,0);
+
+var_dump(strlen($res));
+var_dump(bin2hex($res));
+
+pg_close($db);
+
+$db = pg_connect($conn_str);
+pg_query('DROP TABLE test_bug');
+pg_close($db);
+
+
+?>
+--EXPECT--
+string(14) "\x0103aa000812"
+string(12) "0103aa000812"
+int(6)
+string(12) "0103aa000812"

Modified: php/php-src/branches/PHP_5_3/ext/pgsql/tests/skipif.inc
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/tests/skipif.inc	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/tests/skipif.inc	2009-12-25 20:56:00 UTC (rev 292633)
@@ -15,4 +15,17 @@
 if (!is_resource($conn)) {
     die("skip could not connect\n");
 }
-?>
\ No newline at end of file
+
+function skip_server_version($version, $op = '<') { _skip_version('server', $version, $op); }
+function skip_client_version($version, $op = '<') { _skip_version('client', $version, $op); }
+
+
+function _skip_version($type, $version, $op)
+{
+	$pg = pg_parameter_status($type.'_version');
+	if (version_compare($pg, $version, $op)) {
+		die("skip {$type} version {$pg} is {$op} {$version}\n");
+	}
+}
+
+?>

Modified: php/php-src/trunk/ext/pgsql/tests/08escape.phpt
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/08escape.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/trunk/ext/pgsql/tests/08escape.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL escape functions
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php

@@ -30,7 +33,7 @@
 	echo "pg_escape_bytea() is Ok\n";
 }
 else {
-	echo "pg_escape_byte() is NOT Ok\n";
+	echo "pg_escape_bytea() is NOT Ok\n";
 	var_dump($before);
 	var_dump($after);
 	var_dump($expect);

Copied: php/php-src/trunk/ext/pgsql/tests/08escape_85.phpt (from rev 292622, php/php-src/trunk/ext/pgsql/tests/08escape.phpt)
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/08escape_85.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/pgsql/tests/08escape_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,71 @@
+--TEST--
+PostgreSQL escape functions (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+
+include 'config.inc';
+define('FILE_NAME', dirname(__FILE__) . '/php.gif');
+
+// pg_escape_string() test
+$before = "ABC\\ABC\'";
+$expect  = "ABC\\\\ABC\\'";
+$after = pg_escape_string($before);
+if ($expect === $after) {
+	echo "pg_escape_string() is Ok\n";
+}
+else {
+	echo "pg_escape_string() is NOT Ok\n";
+	var_dump($before);
+	var_dump($after);
+	var_dump($expect);
+}
+
+// pg_escape_bytea() test
+$before = "ABC\\ABC";
+$expect  = "\\x4142435c414243";
+$after  = pg_escape_bytea($before);
+if ($expect === $after) {
+	echo "pg_escape_bytea() is Ok\n";
+}
+else {
+	echo "pg_escape_bytea() is NOT Ok\n";
+	var_dump($before);
+	var_dump($after);
+	var_dump($expect);
+}
+
+// Test using database
+$data = file_get_contents(FILE_NAME);
+$db   = pg_connect($conn_str);
+
+// Insert binary to DB
+$escaped_data = pg_escape_bytea($data);
+pg_query("DELETE FROM ".$table_name." WHERE num = -9999;");
+$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-9999, CAST ('".$escaped_data."' AS BYTEA));";
+pg_query($db, $sql);
+
+// Retrieve binary from DB
+$sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = -9999";
+$result = pg_query($db, $sql);
+$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
+
+if ($data === pg_unescape_bytea($row['bin'])) {
+	echo "pg_escape_bytea() actually works with database\n";
+}
+else {
+	echo "pg_escape_bytea() is broken\n";
+}
+
+?>
+--EXPECT--
+pg_escape_string() is NOT Ok
+unicode(9) "ABC\ABC\'"
+unicode(12) "ABC\\ABC\\''"
+unicode(10) "ABC\\ABC\'"
+pg_escape_bytea() is Ok
+pg_escape_bytea() actually works with database

Modified: php/php-src/trunk/ext/pgsql/tests/10pg_convert.phpt
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/10pg_convert.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/trunk/ext/pgsql/tests/10pg_convert.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_convert()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/trunk/ext/pgsql/tests/10pg_convert_85.phpt (from rev 292622, php/php-src/trunk/ext/pgsql/tests/10pg_convert.phpt)
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/10pg_convert_85.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/pgsql/tests/10pg_convert_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,29 @@
+--TEST--
+PostgreSQL pg_convert() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+$converted = pg_convert($db, $table_name, $fields);
+
+var_dump($converted);
+?>
+--EXPECT--
+array(3) {
+  ["num"]=>
+  string(4) "1234"
+  ["str"]=>
+  string(5) "'AAA'"
+  ["bin"]=>
+  string(11) "'\\x424242'"
+}

Modified: php/php-src/trunk/ext/pgsql/tests/12pg_insert.phpt
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/12pg_insert.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/trunk/ext/pgsql/tests/12pg_insert.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_insert()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/trunk/ext/pgsql/tests/12pg_insert_85.phpt (from rev 292622, php/php-src/trunk/ext/pgsql/tests/12pg_insert.phpt)
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/12pg_insert_85.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/pgsql/tests/12pg_insert_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,24 @@
+--TEST--
+PostgreSQL pg_insert() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'AAA', 'bin'=>'BBB');
+
+pg_insert($db, $table_name, $fields) or print "Error in test 1\n";
+echo pg_insert($db, $table_name, $fields, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
+?>
+--EXPECT--
+INSERT INTO php_pgsql_test (num,str,bin) VALUES (1234,'AAA','\\x424242');
+Ok

Modified: php/php-src/trunk/ext/pgsql/tests/13pg_select.phpt
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/13pg_select.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/trunk/ext/pgsql/tests/13pg_select.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_select()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/trunk/ext/pgsql/tests/13pg_select_85.phpt (from rev 292622, php/php-src/trunk/ext/pgsql/tests/13pg_select.phpt)
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/13pg_select_85.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/pgsql/tests/13pg_select_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,37 @@
+--TEST--
+PostgreSQL pg_select() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+$res = pg_select($db, $table_name, $ids) or print "Error\n";
+var_dump($res);
+echo pg_select($db, $table_name, $ids, PGSQL_DML_STRING)."\n";
+echo "Ok\n";
+
+?>
+--EXPECT--
+array(1) {
+  [0]=>
+  array(3) {
+    ["num"]=>
+    string(4) "1234"
+    ["str"]=>
+    string(3) "AAA"
+    ["bin"]=>
+    string(8) "\x424242"
+  }
+}
+SELECT * FROM php_pgsql_test WHERE num=1234;
+Ok

Modified: php/php-src/trunk/ext/pgsql/tests/14pg_update.phpt
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/14pg_update.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/trunk/ext/pgsql/tests/14pg_update.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 PostgreSQL pg_update()
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php
 error_reporting(E_ALL);

Copied: php/php-src/trunk/ext/pgsql/tests/14pg_update_85.phpt (from rev 292622, php/php-src/trunk/ext/pgsql/tests/14pg_update.phpt)
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/14pg_update_85.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/pgsql/tests/14pg_update_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,25 @@
+--TEST--
+PostgreSQL pg_update() (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+error_reporting(E_ALL);
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
+$ids = array('num'=>'1234');
+
+pg_update($db, $table_name, $fields, $ids) or print "Error in test 1\n";
+echo pg_update($db, $table_name, $fields, $ids, PGSQL_DML_STRING)."\n";
+
+echo "Ok\n";
+?>
+--EXPECT--
+UPDATE php_pgsql_test SET num=1234,str='ABC',bin='\\x58595a' WHERE num=1234;
+Ok

Modified: php/php-src/trunk/ext/pgsql/tests/bug37100.phpt
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/bug37100.phpt	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/trunk/ext/pgsql/tests/bug37100.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -1,7 +1,10 @@
 --TEST--
 Bug #37100 (data is returned truncated with BINARY CURSOR)
 --SKIPIF--
-<?php include("skipif.inc"); ?>
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '>=');
+?>
 --FILE--
 <?php


Copied: php/php-src/trunk/ext/pgsql/tests/bug37100_85.phpt (from rev 292622, php/php-src/trunk/ext/pgsql/tests/bug37100.phpt)
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/bug37100_85.phpt	                        (rev 0)
+++ php/php-src/trunk/ext/pgsql/tests/bug37100_85.phpt	2009-12-25 20:56:00 UTC (rev 292633)
@@ -0,0 +1,46 @@
+--TEST--
+Bug #37100 (data is returned truncated with BINARY CURSOR) (8.5+)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_server_version('8.5dev', '<');
+?>
+--FILE--
+<?php
+
+include 'config.inc';
+
+$db = pg_connect($conn_str);
+
+...@pg_query('DROP TABLE test_bug');
+
+pg_query('CREATE TABLE test_bug (binfield byteA) ;');
+pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");
+
+
+$data = pg_query("SELECT binfield FROM test_bug");
+$res = pg_fetch_result($data,0);
+var_dump($res);
+var_dump(bin2hex(pg_unescape_bytea($res)));
+
+$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM test_bug; FETCH ALL IN mycursor;";
+
+$data = pg_query($sql);
+$res = pg_fetch_result($data,0);
+
+var_dump(strlen($res));
+var_dump(bin2hex($res));
+
+pg_close($db);
+
+$db = pg_connect($conn_str);
+pg_query('DROP TABLE test_bug');
+pg_close($db);
+
+
+?>
+--EXPECT--
+string(14) "\x0103aa000812"
+string(12) "0103aa000812"
+int(6)
+string(12) "0103aa000812"

Modified: php/php-src/trunk/ext/pgsql/tests/skipif.inc
===================================================================
--- php/php-src/trunk/ext/pgsql/tests/skipif.inc	2009-12-25 20:34:59 UTC (rev 292632)
+++ php/php-src/trunk/ext/pgsql/tests/skipif.inc	2009-12-25 20:56:00 UTC (rev 292633)
@@ -15,4 +15,17 @@
 if (!is_resource($conn)) {
     die("skip could not connect\n");
 }
-?>
\ No newline at end of file
+
+function skip_server_version($version, $op = '<') { _skip_version('server', $version, $op); }
+function skip_client_version($version, $op = '<') { _skip_version('client', $version, $op); }
+
+
+function _skip_version($type, $version, $op)
+{
+	$pg = pg_parameter_status($type.'_version');
+	if (version_compare($pg, $version, $op)) {
+		die("skip {$type} version {$pg} is {$op} {$version}\n");
+	}
+}
+
+?>
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to