diff --git a/ext/pdo_pgsql/tests/bug46274.phpt b/ext/pdo_pgsql/tests/bug46274.phpt index c34839ad430..8a85c9fe0c1 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 eb675afe9e5..317160c37a8 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 90b4ed8a9f5..1bea35bf14d 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 73bf2b64e8b..fde4c67d374 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 b41dd1af84c..3260f2b73e1 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 5f52a17d973..38e5777c3e0 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 00000000000..04630bbbf8f --- /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/80_bug36625.phpt b/ext/pgsql/tests/80_bug36625.phpt index a95cea7110a..9cc8a1d4fd0 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 fa6b9ba9e0e..3faecc671c4 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 aa2477626a0..9f4160d129d 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"); } }