From c666239265048abd3cc0b2c48493a5db1eacc28e Mon Sep 17 00:00:00 2001 From: Matteo Beccati Date: Wed, 19 Jun 2013 11:46:11 +0200 Subject: [PATCH] Fixed bug #65047 (Test skip on client / server version) --- ext/pdo_pgsql/tests/bug46274.phpt | 5 +++ ext/pdo_pgsql/tests/bug46274_2.phpt | 5 +++ ext/pgsql/tests/08escape.phpt | 27 ++++++++++----- ext/pgsql/tests/10pg_convert.phpt | 2 +- ...pg_convert_85.phpt => 10pg_convert_9.phpt} | 4 +-- ext/pgsql/tests/12pg_insert.phpt | 2 +- ...12pg_insert_85.phpt => 12pg_insert_9.phpt} | 4 +-- ...13pg_select_85.phpt => 13pg_select_9.phpt} | 6 ++-- ext/pgsql/tests/14pg_update.phpt | 2 +- ...14pg_update_85.phpt => 14pg_update_9.phpt} | 4 +-- ext/pgsql/tests/18pg_escape_bytea_before.phpt | 30 +++++++++++++++++ ..._bytea.phpt => 18pg_escape_bytea_esc.phpt} | 3 +- ext/pgsql/tests/18pg_escape_bytea_hex.phpt | 33 +++++++++++++++++++ ext/pgsql/tests/bug37100.phpt | 3 +- .../{bug37100_85.phpt => bug37100_9.phpt} | 4 +-- ext/pgsql/tests/skipif.inc | 17 ++++++++++ 16 files changed, 127 insertions(+), 24 deletions(-) rename ext/pgsql/tests/{10pg_convert_85.phpt => 10pg_convert_9.phpt} (87%) rename ext/pgsql/tests/{12pg_insert_85.phpt => 12pg_insert_9.phpt} (88%) rename ext/pgsql/tests/{13pg_select_85.phpt => 13pg_select_9.phpt} (85%) rename ext/pgsql/tests/{14pg_update_85.phpt => 14pg_update_9.phpt} (89%) create mode 100644 ext/pgsql/tests/18pg_escape_bytea_before.phpt rename ext/pgsql/tests/{18pg_escape_bytea.phpt => 18pg_escape_bytea_esc.phpt} (84%) create mode 100644 ext/pgsql/tests/18pg_escape_bytea_hex.phpt rename ext/pgsql/tests/{bug37100_85.phpt => bug37100_9.phpt} (89%) 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-- ='); +skip_bytea_not_escape(); ?> --FILE-- --FILE-- ='); +skip_bytea_not_escape(); ?> --FILE-- --FILE-- --FILE-- '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-- ='); +skip_bytea_not_escape(); ?> --FILE-- --FILE-- +--FILE-- + +--EXPECT-- +OK diff --git a/ext/pgsql/tests/18pg_escape_bytea.phpt b/ext/pgsql/tests/18pg_escape_bytea_esc.phpt similarity index 84% rename from ext/pgsql/tests/18pg_escape_bytea.phpt rename to 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-- --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-- + +--FILE-- + +--EXPECT-- +OK 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-- ='); +skip_bytea_not_escape(); ?> --FILE-- ='); 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 similarity index 89% rename from ext/pgsql/tests/bug37100_85.phpt rename to 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-- --FILE-- = 9.0\n"); + } } ?> -- 2.40.0