mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00
Merge branch 'PHP-5.5'
* PHP-5.5: Fixed bug #65047 (Test skip on client / server version) Remove broken client version checking Clean up leftover file after the test
This commit is contained in:
commit
77032bcd9c
17 changed files with 132 additions and 31 deletions
|
@ -14,6 +14,11 @@ $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
|
||||||
|
|
||||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
|
$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)');
|
$db->query('CREATE TABLE test_one_blob (id SERIAL NOT NULL, blob1 BYTEA)');
|
||||||
|
|
||||||
$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)");
|
$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)");
|
||||||
|
|
|
@ -14,6 +14,11 @@ $db = PDOTest::test_factory(dirname(__FILE__) . '/common.phpt');
|
||||||
|
|
||||||
$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, false);
|
$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)');
|
$db->query('CREATE TABLE test_one_blob (id SERIAL NOT NULL, blob1 BYTEA)');
|
||||||
|
|
||||||
$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)");
|
$stmt = $db->prepare("INSERT INTO test_one_blob (blob1) VALUES (:foo)");
|
||||||
|
|
|
@ -48,15 +48,24 @@ $sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-9999, CAST ('".$escaped_
|
||||||
pg_query($db, $sql);
|
pg_query($db, $sql);
|
||||||
|
|
||||||
// Retrieve binary from DB
|
// Retrieve binary from DB
|
||||||
$sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = -9999";
|
for ($i = 0; $i < 2; $i++) {
|
||||||
$result = pg_query($db, $sql);
|
$sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = -9999";
|
||||||
$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
|
$result = pg_query($db, $sql);
|
||||||
|
$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
|
||||||
|
|
||||||
if ($data === pg_unescape_bytea($row['bin'])) {
|
if ($data === pg_unescape_bytea($row['bin'])) {
|
||||||
echo "pg_escape_bytea() actually works with database\n";
|
echo "pg_escape_bytea() actually works with database\n";
|
||||||
}
|
break;
|
||||||
else {
|
}
|
||||||
|
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";
|
echo "pg_escape_bytea() is broken\n";
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// pg_escape_literal/pg_escape_identifier
|
// pg_escape_literal/pg_escape_identifier
|
||||||
|
|
|
@ -3,7 +3,7 @@ PostgreSQL pg_convert()
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '>=');
|
skip_bytea_not_escape();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
PostgreSQL pg_convert() (8.5+)
|
PostgreSQL pg_convert() (9.0+)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '<');
|
skip_bytea_not_hex();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
|
@ -3,7 +3,7 @@ PostgreSQL pg_insert()
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '>=');
|
skip_bytea_not_escape();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
PostgreSQL pg_insert() (8.5+)
|
PostgreSQL pg_insert() (9.0+)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '<');
|
skip_bytea_not_hex();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
|
@ -1,9 +1,9 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
PostgreSQL pg_select() (8.5+)
|
PostgreSQL pg_select() (9.0+)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '<');
|
skip_server_version('9.0', '<');
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -12,6 +12,8 @@ error_reporting(E_ALL);
|
||||||
include 'config.inc';
|
include 'config.inc';
|
||||||
|
|
||||||
$db = pg_connect($conn_str);
|
$db = pg_connect($conn_str);
|
||||||
|
pg_query("SET bytea_output = 'hex'");
|
||||||
|
|
||||||
$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
|
$fields = array('num'=>'1234', 'str'=>'ABC', 'bin'=>'XYZ');
|
||||||
$ids = array('num'=>'1234');
|
$ids = array('num'=>'1234');
|
||||||
|
|
|
@ -3,7 +3,7 @@ PostgreSQL pg_update()
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '>=');
|
skip_bytea_not_escape();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
PostgreSQL pg_update() (8.5+)
|
PostgreSQL pg_update() (9.0)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '<');
|
skip_bytea_not_hex();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
30
ext/pgsql/tests/18pg_escape_bytea_before.phpt
Normal file
30
ext/pgsql/tests/18pg_escape_bytea_before.phpt
Normal file
|
@ -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
|
|
@ -1,5 +1,5 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
PostgreSQL pg_escape_bytea() functions
|
PostgreSQL pg_escape_bytea() functions (escape format)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php include("skipif.inc"); ?>
|
<?php include("skipif.inc"); ?>
|
||||||
--FILE--
|
--FILE--
|
||||||
|
@ -9,6 +9,7 @@ PostgreSQL pg_escape_bytea() functions
|
||||||
include('config.inc');
|
include('config.inc');
|
||||||
|
|
||||||
$db = pg_connect($conn_str);
|
$db = pg_connect($conn_str);
|
||||||
|
@pg_query($db, "SET bytea_output = 'escape'");
|
||||||
|
|
||||||
$image = file_get_contents(dirname(__FILE__) . '/php.gif');
|
$image = file_get_contents(dirname(__FILE__) . '/php.gif');
|
||||||
$esc_image = pg_escape_bytea($image);
|
$esc_image = pg_escape_bytea($image);
|
33
ext/pgsql/tests/18pg_escape_bytea_hex.phpt
Normal file
33
ext/pgsql/tests/18pg_escape_bytea_hex.phpt
Normal file
|
@ -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
|
|
@ -37,6 +37,8 @@ array_walk($trace, 'search_trace_file');
|
||||||
var_dump($found > 0);
|
var_dump($found > 0);
|
||||||
var_dump(file_exists($tracefile));
|
var_dump(file_exists($tracefile));
|
||||||
|
|
||||||
|
@unlink($tracefile);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
===DONE===
|
===DONE===
|
||||||
--CLEAN--
|
--CLEAN--
|
||||||
|
|
|
@ -3,7 +3,7 @@ Bug #37100 (data is returned truncated with BINARY CURSOR)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '>=');
|
skip_bytea_not_escape();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
||||||
|
@ -11,6 +11,7 @@ skip_server_version('8.5dev', '>=');
|
||||||
include 'config.inc';
|
include 'config.inc';
|
||||||
|
|
||||||
$db = pg_connect($conn_str);
|
$db = pg_connect($conn_str);
|
||||||
|
@pg_query("SET bytea_output = 'escape'");
|
||||||
|
|
||||||
@pg_query('DROP TABLE test_bug');
|
@pg_query('DROP TABLE test_bug');
|
||||||
|
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
--TEST--
|
--TEST--
|
||||||
Bug #37100 (data is returned truncated with BINARY CURSOR) (8.5+)
|
Bug #37100 (data is returned truncated with BINARY CURSOR) (9.0+)
|
||||||
--SKIPIF--
|
--SKIPIF--
|
||||||
<?php
|
<?php
|
||||||
include("skipif.inc");
|
include("skipif.inc");
|
||||||
skip_server_version('8.5dev', '<');
|
skip_bytea_not_hex();
|
||||||
?>
|
?>
|
||||||
--FILE--
|
--FILE--
|
||||||
<?php
|
<?php
|
|
@ -17,15 +17,28 @@ if (!is_resource($conn)) {
|
||||||
die("skip could not connect\n");
|
die("skip could not connect\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
function skip_server_version($version, $op = '<') { _skip_version('server', $version, $op); }
|
function skip_server_version($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');
|
$pg = pg_parameter_status('server_version');
|
||||||
if (version_compare($pg, $version, $op)) {
|
if (version_compare($pg, $version, $op)) {
|
||||||
die("skip {$type} version {$pg} is {$op} {$version}\n");
|
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_bytea_not_escape()
|
||||||
|
{
|
||||||
|
$out = pg_escape_bytea("\xFF");
|
||||||
|
if (strpos($out, '377') === false) {
|
||||||
|
die("skip libpq or backend >= 9.0\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue