]> granicus.if.org Git - php/commitdiff
- Updated ext/pgsql tests to work w/ PostgreSQL 8.5
authorMatteo Beccati <mbeccati@php.net>
Fri, 25 Dec 2009 20:56:00 +0000 (20:56 +0000)
committerMatteo Beccati <mbeccati@php.net>
Fri, 25 Dec 2009 20:56:00 +0000 (20:56 +0000)
# tested w/ 8.5alpha3

ext/pgsql/tests/10pg_convert.phpt
ext/pgsql/tests/10pg_convert_85.phpt [new file with mode: 0644]
ext/pgsql/tests/12pg_insert.phpt
ext/pgsql/tests/12pg_insert_85.phpt [new file with mode: 0644]
ext/pgsql/tests/13pg_select.phpt
ext/pgsql/tests/13pg_select_85.phpt [new file with mode: 0644]
ext/pgsql/tests/14pg_update.phpt
ext/pgsql/tests/14pg_update_85.phpt [new file with mode: 0644]
ext/pgsql/tests/bug37100.phpt
ext/pgsql/tests/bug37100_85.phpt [new file with mode: 0644]
ext/pgsql/tests/skipif.inc

index b88b8e5798f37c6c69dea5fd56ea4a1be38bc659..73bf2b64e8b90e362e2bd8f8b153e80827473928 100644 (file)
@@ -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);
diff --git a/ext/pgsql/tests/10pg_convert_85.phpt b/ext/pgsql/tests/10pg_convert_85.phpt
new file mode 100644 (file)
index 0000000..4f1c92b
--- /dev/null
@@ -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'"
+}
index 8d98f220fdfb64b69debaa6f63bb04b6c909c3ec..f5cd868f81ca5b3de51bada4f866624ad548f00b 100644 (file)
@@ -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);
diff --git a/ext/pgsql/tests/12pg_insert_85.phpt b/ext/pgsql/tests/12pg_insert_85.phpt
new file mode 100644 (file)
index 0000000..a85dea0
--- /dev/null
@@ -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
index 55e88db731c9b047f34f01cbbabb282b0c4c14be..f1504a8b17996ef0dac15202834649edf1ca56b2 100644 (file)
@@ -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);
diff --git a/ext/pgsql/tests/13pg_select_85.phpt b/ext/pgsql/tests/13pg_select_85.phpt
new file mode 100644 (file)
index 0000000..cd9c935
--- /dev/null
@@ -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
index ef8d7e49bd2399ecd1337135b426db555c8cd927..b41dd1af84c368428609ffb286b2b785c60b7b67 100644 (file)
@@ -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);
diff --git a/ext/pgsql/tests/14pg_update_85.phpt b/ext/pgsql/tests/14pg_update_85.phpt
new file mode 100644 (file)
index 0000000..f1c77ea
--- /dev/null
@@ -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
index b66149e4a5f6287de5a4410591c7200478def02d..fa6b9ba9e0ef92fb8e86bacac3299b972e87b15d 100644 (file)
@@ -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
 
diff --git a/ext/pgsql/tests/bug37100_85.phpt b/ext/pgsql/tests/bug37100_85.phpt
new file mode 100644 (file)
index 0000000..aa24776
--- /dev/null
@@ -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"
index 043a0bd8d20315549f16bc2a9bddab7d319ad294..74b27b3ad8e9bd0a05f6046471999fc57a37b06f 100644 (file)
@@ -15,4 +15,17 @@ $conn = @pg_connect($conn_str);
 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");
+       }
+}
+
+?>