Bug #53127 [Opn->Wfx]: pg_escape_bytea returns a format different from the expectation
Edit report at http://bugs.php.net/bug.php?id=53127&edit=1
ID: 53127
Updated by: aharvey@php.net
Reported by: nakamura at nepsys dot ddo dot jp
Summary: pg_escape_bytea returns a format different from the
expectation
-Status: Open
+Status: Wont fix
Type: Bug
Package: PostgreSQL related
Operating System: Linux kernel 2.6.27
PHP Version: 5.3.3
Block user comment: N
New Comment:
There's no way in the PQ API to choose the old escaping behaviour --
which behaviour is used depends on the PostgreSQL server version, if
the connection is active.
Previous Comments:
------------------------------------------------------------------------
[2010-10-21 13:26:21] nakamura at nepsys dot ddo dot jp
Description:
------------
Using PostgreSQL 9.0.1, pg_escape_bytea function returns new "hex"
format.
By defaults, PostgreSQL outputs new "hex" format for bytea data.
It is possible to change to "escape" format by modifying the
postgresql.conf file.
I expecting the test script displays "AAA" always.
However, pg_escape_bytea actually returns a different ("hex") format
while the database is connected.
After disconnected, pg_escape_bytea returns correct ("escape") format.
Test script:
---------------
<?php
$link = pg_connect('dbname=template1 user=postgres');
$version = pg_version($link);
print "PostgreSQL version information\n";
var_dump($version);
$result = pg_query($link,"show bytea_output");
$col = pg_fetch_row($result,0);
pg_free_result($result);
print "environment variable: bytea_output\n";
var_dump($col);
print "pg_escape_bytea('AAA') before database connection closing\n";
print pg_escape_bytea('AAA')."\n";
pg_close($link);
print "pg_escape_bytea('AAA') after database connection closing\n";
print pg_escape_bytea('AAA')."\n";
Expected result:
----------------
PostgreSQL version information
array(3) {
["client"]=>
string(5) "9.0.1"
["protocol"]=>
int(3)
["server"]=>
string(5) "9.0.1"
}
environment variable: bytea_output
array(1) {
[0]=>
string(6) "escape"
}
pg_escape_bytea('AAA') before database connection closing
AAA
pg_escape_bytea('AAA') after database connection closing
AAA
Actual result:
--------------
PostgreSQL version information
array(3) {
["client"]=>
string(5) "9.0.1"
["protocol"]=>
int(3)
["server"]=>
string(5) "9.0.1"
}
environment variable: bytea_output
array(1) {
[0]=>
string(6) "escape"
}
pg_escape_bytea('AAA') before database connection closing
\\x414141
pg_escape_bytea('AAA') after database connection closing
AAA
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53127&edit=1
Thread (3 messages)