Edit report at https://bugs.php.net/bug.php?id=53127&edit=1

 ID:                 53127
 Comment by:         zlobnynigga at yandex dot ru
 Reported by:        nakamura at nepsys dot ddo dot jp
 Summary:            pg_escape_bytea returns a format different from the
                     expectation
 Status:             Wont fix
 Type:               Bug
 Package:            PostgreSQL related
 Operating System:   Linux kernel 2.6.27
 PHP Version:        5.3.3
 Block user comment: N
 Private report:     N

 New Comment:

I have experienced the same issue with PHP 5.3.5 (PHP 
5.3.5-1ubuntu7.2ppa1~lucid with Suhosin-Patch). Under Ubuntu Lucid 2.6.32. But 
with PHP 5.3.5 under CentOS 2.6.18 there is no such problem. Important thing: 
both Ubuntu and CentOS hosts are connected to the same PostgreSQL 9.0.3 with 
'bytea_output' set to 'escape' (in postgresql.conf). Therefore, I think that 
which behaviour is used DOES NOT depend on the PostgreSQL server version. It 
depends on pgsql or pdo_pgsql extensions version (or PHP versions, I have 5.3.5 
on both hosts, but they are not the same at least because of some dist specific 
things). Unfortunately, PHP under ubuntu can not start with pgsql.so from 
CentOS, so I can't make tests I want. But it looks clear: two different PHPs 
connect to single PostgreSQL and it results in different behaviour.


Previous Comments:
------------------------------------------------------------------------
[2010-10-22 09:07:17] ahar...@php.net

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.

------------------------------------------------------------------------
[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 https://bugs.php.net/bug.php?id=53127&edit=1

Reply via email to