summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatteo Beccati <mbeccati@php.net>2013-06-19 11:53:05 +0200
committerMatteo Beccati <mbeccati@php.net>2013-06-19 11:53:05 +0200
commit9b8259cdfa0f6b54984bb3268b17e7a36fa448d8 (patch)
treebcc2bda63664427a6ed6b23741a5bdb9f0d04754
parent7b08c7f4e7ed03fff98b6ece0df2be7ff079ffa0 (diff)
parentc666239265048abd3cc0b2c48493a5db1eacc28e (diff)
downloadphp-git-9b8259cdfa0f6b54984bb3268b17e7a36fa448d8.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Fixed bug #65047 (Test skip on client / server version) Remove broken client version checking Clean up leftover file after the test
-rw-r--r--ext/pdo_pgsql/tests/bug46274.phpt5
-rw-r--r--ext/pdo_pgsql/tests/bug46274_2.phpt5
-rw-r--r--ext/pgsql/tests/08escape.phpt27
-rw-r--r--ext/pgsql/tests/10pg_convert.phpt2
-rw-r--r--ext/pgsql/tests/10pg_convert_9.phpt (renamed from ext/pgsql/tests/10pg_convert_85.phpt)4
-rw-r--r--ext/pgsql/tests/12pg_insert.phpt2
-rw-r--r--ext/pgsql/tests/12pg_insert_9.phpt (renamed from ext/pgsql/tests/12pg_insert_85.phpt)4
-rw-r--r--ext/pgsql/tests/13pg_select_9.phpt (renamed from ext/pgsql/tests/13pg_select_85.phpt)6
-rw-r--r--ext/pgsql/tests/14pg_update.phpt2
-rw-r--r--ext/pgsql/tests/14pg_update_9.phpt (renamed from ext/pgsql/tests/14pg_update_85.phpt)4
-rw-r--r--ext/pgsql/tests/18pg_escape_bytea_before.phpt30
-rw-r--r--ext/pgsql/tests/18pg_escape_bytea_esc.phpt (renamed from ext/pgsql/tests/18pg_escape_bytea.phpt)3
-rw-r--r--ext/pgsql/tests/18pg_escape_bytea_hex.phpt33
-rw-r--r--ext/pgsql/tests/80_bug36625.phpt2
-rw-r--r--ext/pgsql/tests/bug37100.phpt3
-rw-r--r--ext/pgsql/tests/bug37100_9.phpt (renamed from ext/pgsql/tests/bug37100_85.phpt)4
-rw-r--r--ext/pgsql/tests/skipif.inc25
17 files changed, 131 insertions, 30 deletions
diff --git a/ext/pdo_pgsql/tests/bug46274.phpt b/ext/pdo_pgsql/tests/bug46274.phpt
index c34839ad43..8a85c9fe0c 100644
--- a/ext/pdo_pgsql/tests/bug46274.phpt
+++ b/ext/pdo_pgsql/tests/bug46274.phpt
@@ -14,6 +14,11 @@ $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
+try {
+ $db->query("SET bytea_output = 'escape'");
+} catch (Exception $e) {
+}
+
$db->query('CREATE TABLE test_one_blob (id SERIAL NOT NULL, blob1 BYTEA)');
$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)");
diff --git a/ext/pdo_pgsql/tests/bug46274_2.phpt b/ext/pdo_pgsql/tests/bug46274_2.phpt
index eb675afe9e..317160c37a 100644
--- a/ext/pdo_pgsql/tests/bug46274_2.phpt
+++ b/ext/pdo_pgsql/tests/bug46274_2.phpt
@@ -14,6 +14,11 @@ $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
+try {
+ $db->query("SET bytea_output = 'escape'");
+} catch (Exception $e) {
+}
+
$db->query('CREATE TABLE test_one_blob (id SERIAL NOT NULL, blob1 BYTEA)');
$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)");
diff --git a/ext/pgsql/tests/08escape.phpt b/ext/pgsql/tests/08escape.phpt
index 90b4ed8a9f..1bea35bf14 100644
--- a/ext/pgsql/tests/08escape.phpt
+++ b/ext/pgsql/tests/08escape.phpt
@@ -48,15 +48,24 @@ $sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-9999, CAST ('".$escaped_
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);
+for ($i = 0; $i < 2; $i++) {
+ $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";
+ if ($data === pg_unescape_bytea($row['bin'])) {
+ echo "pg_escape_bytea() actually works with database\n";
+ break;
+ }
+ elseif (!$i) {
+ // Force bytea escaping and retry
+ @pg_query($db, "SET bytea_output = 'escape'");
+ }
+ else {
+ $result = pg_query($db, $sql);
+ echo "pg_escape_bytea() is broken\n";
+ break;
+ }
}
// pg_escape_literal/pg_escape_identifier
@@ -92,4 +101,4 @@ pg_escape_string() is Ok
pg_escape_bytea() is Ok
pg_escape_bytea() actually works with database
pg_escape_literal() is Ok
-pg_escape_identifier() is Ok \ No newline at end of file
+pg_escape_identifier() is Ok
diff --git a/ext/pgsql/tests/10pg_convert.phpt b/ext/pgsql/tests/10pg_convert.phpt
index 73bf2b64e8..fde4c67d37 100644
--- a/ext/pgsql/tests/10pg_convert.phpt
+++ b/ext/pgsql/tests/10pg_convert.phpt
@@ -3,7 +3,7 @@ PostgreSQL pg_convert()
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '>=');
+skip_bytea_not_escape();
?>
--FILE--
<?php
diff --git a/ext/pgsql/tests/10pg_convert_85.phpt b/ext/pgsql/tests/10pg_convert_9.phpt
index 8b1cc8f538..bb2e7e6d2a 100644
--- a/ext/pgsql/tests/10pg_convert_85.phpt
+++ b/ext/pgsql/tests/10pg_convert_9.phpt
@@ -1,9 +1,9 @@
--TEST--
-PostgreSQL pg_convert() (8.5+)
+PostgreSQL pg_convert() (9.0+)
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '<');
+skip_bytea_not_hex();
?>
--FILE--
<?php
diff --git a/ext/pgsql/tests/12pg_insert.phpt b/ext/pgsql/tests/12pg_insert.phpt
index f5cd868f81..66304944b0 100644
--- a/ext/pgsql/tests/12pg_insert.phpt
+++ b/ext/pgsql/tests/12pg_insert.phpt
@@ -3,7 +3,7 @@ PostgreSQL pg_insert()
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '>=');
+skip_bytea_not_escape();
?>
--FILE--
<?php
diff --git a/ext/pgsql/tests/12pg_insert_85.phpt b/ext/pgsql/tests/12pg_insert_9.phpt
index 5fbbe4b7af..8afae0df91 100644
--- a/ext/pgsql/tests/12pg_insert_85.phpt
+++ b/ext/pgsql/tests/12pg_insert_9.phpt
@@ -1,9 +1,9 @@
--TEST--
-PostgreSQL pg_insert() (8.5+)
+PostgreSQL pg_insert() (9.0+)
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '<');
+skip_bytea_not_hex();
?>
--FILE--
<?php
diff --git a/ext/pgsql/tests/13pg_select_85.phpt b/ext/pgsql/tests/13pg_select_9.phpt
index e6d86bd6f8..422c461b60 100644
--- a/ext/pgsql/tests/13pg_select_85.phpt
+++ b/ext/pgsql/tests/13pg_select_9.phpt
@@ -1,9 +1,9 @@
--TEST--
-PostgreSQL pg_select() (8.5+)
+PostgreSQL pg_select() (9.0+)
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '<');
+skip_server_version('9.0', '<');
?>
--FILE--
<?php
@@ -12,6 +12,8 @@ error_reporting(E_ALL);
include 'config.inc';
$db = pg_connect($conn_str);
+pg_query("SET bytea_output = 'hex'");
+
$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
$ids = array('num'=>'1234');
diff --git a/ext/pgsql/tests/14pg_update.phpt b/ext/pgsql/tests/14pg_update.phpt
index b41dd1af84..3260f2b73e 100644
--- a/ext/pgsql/tests/14pg_update.phpt
+++ b/ext/pgsql/tests/14pg_update.phpt
@@ -3,7 +3,7 @@ PostgreSQL pg_update()
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '>=');
+skip_bytea_not_escape();
?>
--FILE--
<?php
diff --git a/ext/pgsql/tests/14pg_update_85.phpt b/ext/pgsql/tests/14pg_update_9.phpt
index 06ca8c3de9..bc5cf673e3 100644
--- a/ext/pgsql/tests/14pg_update_85.phpt
+++ b/ext/pgsql/tests/14pg_update_9.phpt
@@ -1,9 +1,9 @@
--TEST--
-PostgreSQL pg_update() (8.5+)
+PostgreSQL pg_update() (9.0)
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '<');
+skip_bytea_not_hex();
?>
--FILE--
<?php
diff --git a/ext/pgsql/tests/18pg_escape_bytea_before.phpt b/ext/pgsql/tests/18pg_escape_bytea_before.phpt
new file mode 100644
index 0000000000..492517733f
--- /dev/null
+++ b/ext/pgsql/tests/18pg_escape_bytea_before.phpt
@@ -0,0 +1,30 @@
+--TEST--
+PostgreSQL pg_escape_bytea() functions (before connection)
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+// optional functions
+
+include('config.inc');
+
+$image = file_get_contents(dirname(__FILE__) . '/php.gif');
+$esc_image = pg_escape_bytea($image);
+
+$db = pg_connect($conn_str);
+@pg_query($db, "SET bytea_output = 'escape'");
+
+pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, E\''.$esc_image.'\');');
+$result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876');
+$rows = pg_fetch_all($result);
+$unesc_image = pg_unescape_bytea($rows[0]['bin']);
+
+if ($unesc_image !== $image) {
+ echo "NG";
+}
+else {
+ echo "OK";
+}
+?>
+--EXPECT--
+OK
diff --git a/ext/pgsql/tests/18pg_escape_bytea.phpt b/ext/pgsql/tests/18pg_escape_bytea_esc.phpt
index 5f52a17d97..38e5777c3e 100644
--- a/ext/pgsql/tests/18pg_escape_bytea.phpt
+++ b/ext/pgsql/tests/18pg_escape_bytea_esc.phpt
@@ -1,5 +1,5 @@
--TEST--
-PostgreSQL pg_escape_bytea() functions
+PostgreSQL pg_escape_bytea() functions (escape format)
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
@@ -9,6 +9,7 @@ PostgreSQL pg_escape_bytea() functions
include('config.inc');
$db = pg_connect($conn_str);
+@pg_query($db, "SET bytea_output = 'escape'");
$image = file_get_contents(dirname(__FILE__) . '/php.gif');
$esc_image = pg_escape_bytea($image);
diff --git a/ext/pgsql/tests/18pg_escape_bytea_hex.phpt b/ext/pgsql/tests/18pg_escape_bytea_hex.phpt
new file mode 100644
index 0000000000..04630bbbf8
--- /dev/null
+++ b/ext/pgsql/tests/18pg_escape_bytea_hex.phpt
@@ -0,0 +1,33 @@
+--TEST--
+PostgreSQL pg_escape_bytea() functions (hex format)
+--SKIPIF--
+<?php
+include("skipif.inc");
+skip_bytea_not_hex();
+?>
+--FILE--
+<?php
+// optional functions
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+@pg_query($db, "SET bytea_output = 'hex'");
+
+$image = file_get_contents(dirname(__FILE__) . '/php.gif');
+$esc_image = pg_escape_bytea($image);
+
+pg_query($db, 'INSERT INTO '.$table_name.' (num, bin) VALUES (9876, \''.$esc_image.'\');');
+$result = pg_query($db, 'SELECT * FROM '.$table_name.' WHERE num = 9876');
+$rows = pg_fetch_all($result);
+$unesc_image = pg_unescape_bytea($rows[0]['bin']);
+
+if ($unesc_image !== $image) {
+ echo "NG";
+}
+else {
+ echo "OK";
+}
+?>
+--EXPECT--
+OK
diff --git a/ext/pgsql/tests/80_bug36625.phpt b/ext/pgsql/tests/80_bug36625.phpt
index a95cea7110..9cc8a1d4fd 100644
--- a/ext/pgsql/tests/80_bug36625.phpt
+++ b/ext/pgsql/tests/80_bug36625.phpt
@@ -37,6 +37,8 @@ array_walk($trace, 'search_trace_file');
var_dump($found > 0);
var_dump(file_exists($tracefile));
+@unlink($tracefile);
+
?>
===DONE===
--CLEAN--
diff --git a/ext/pgsql/tests/bug37100.phpt b/ext/pgsql/tests/bug37100.phpt
index fa6b9ba9e0..3faecc671c 100644
--- a/ext/pgsql/tests/bug37100.phpt
+++ b/ext/pgsql/tests/bug37100.phpt
@@ -3,7 +3,7 @@ Bug #37100 (data is returned truncated with BINARY CURSOR)
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '>=');
+skip_bytea_not_escape();
?>
--FILE--
<?php
@@ -11,6 +11,7 @@ skip_server_version('8.5dev', '>=');
include 'config.inc';
$db = pg_connect($conn_str);
+@pg_query("SET bytea_output = 'escape'");
@pg_query('DROP TABLE test_bug');
diff --git a/ext/pgsql/tests/bug37100_85.phpt b/ext/pgsql/tests/bug37100_9.phpt
index aa2477626a..9f4160d129 100644
--- a/ext/pgsql/tests/bug37100_85.phpt
+++ b/ext/pgsql/tests/bug37100_9.phpt
@@ -1,9 +1,9 @@
--TEST--
-Bug #37100 (data is returned truncated with BINARY CURSOR) (8.5+)
+Bug #37100 (data is returned truncated with BINARY CURSOR) (9.0+)
--SKIPIF--
<?php
include("skipif.inc");
-skip_server_version('8.5dev', '<');
+skip_bytea_not_hex();
?>
--FILE--
<?php
diff --git a/ext/pgsql/tests/skipif.inc b/ext/pgsql/tests/skipif.inc
index 7c5153e6f0..83904af4f3 100644
--- a/ext/pgsql/tests/skipif.inc
+++ b/ext/pgsql/tests/skipif.inc
@@ -17,15 +17,28 @@ if (!is_resource($conn)) {
die("skip could not connect\n");
}
-function skip_server_version($version, $op = '<') { _skip_version('server', $version, $op); }
-function skip_client_version($version, $op = '<') { _skip_version('client', $version, $op); }
+function skip_server_version($version, $op = '<')
+{
+ $pg = pg_parameter_status('server_version');
+ if (version_compare($pg, $version, $op)) {
+ die("skip Server version {$pg} is {$op} {$version}\n");
+ }
+ return $pg;
+}
+function skip_bytea_not_hex()
+{
+ $out = pg_escape_bytea("\xFF");
+ if (strpos($out, '377') !== false) {
+ die("skip libpq or backend < 9.0\n");
+ }
+}
-function _skip_version($type, $version, $op)
+function skip_bytea_not_escape()
{
- $pg = pg_parameter_status($type.'_version');
- if (version_compare($pg, $version, $op)) {
- die("skip {$type} version {$pg} is {$op} {$version}\n");
+ $out = pg_escape_bytea("\xFF");
+ if (strpos($out, '377') === false) {
+ die("skip libpq or backend >= 9.0\n");
}
}