Permalink
Browse files

ADOdb/pgsql: fix output of bytea fields for PostgreSQL >= 9.0

The new default 'hex' prevents Mantis from displaying the contents of
attachments.

Fixes #16341
  • Loading branch information...
dregad committed Aug 30, 2013
1 parent 9b9c2cc commit 49e413b436dd7aa1627710aa0c7376d7b354675d
Showing with 9 additions and 0 deletions.
  1. +9 −0 library/adodb/drivers/adodb-postgres64.inc.php
@@ -699,6 +699,15 @@ function _connect($str,$user='',$pwd='',$db='',$ctype=0)
if ($this->pgVersion >= 7.1) { // good till version 999
$this->_nestedSQL = true;
}
+
+ # PostgreSQL 9.0 changed the default output for bytea from 'escape' to 'hex'
+ # PHP does not handle 'hex' properly ('x74657374' is returned as 't657374')
+ # https://bugs.php.net/bug.php?id=59831 states this is in fact not a bug,
+ # so we manually set bytea_output
+ if (version_compare($info['version'], '9.0', '>=')) {
+ $this->Execute('set bytea_output=escape');
+ }
+
return true;
}

0 comments on commit 49e413b

Please sign in to comment.