<?xml version="1.0" encoding="UTF-8"?> 
<?xml-stylesheet href="https://dev.horde.org/themes/horde//default/feed-rss.xsl" type="text/xsl"?> 
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> 
 <channel> 
  <title>Postgresql 9.0 bytea output is hex and should be escape</title> 
  <pubDate>Thu, 09 Apr 2026 17:42:22 +0000</pubDate> 
  <link>https://bugs.horde.org/ticket/10919</link> 
  <atom:link rel="self" type="application/rss+xml" title="Postgresql 9.0 bytea output is hex and should be escape" href="https://bugs.horde.org/ticket/10919/rss" /> 
  <description>Postgresql 9.0 bytea output is hex and should be escape</description> 
 
   
   
  <item> 
   <title>In PostgreSQL 9.xx bytea values have hex as default output, </title> 
   <description>In PostgreSQL 9.xx bytea values have hex as default output, but horde expects escape. (http://www.postgresql.org/docs/9.0/static/release-9-0.html)

With &quot;ALTER DATABASE horde SET bytea_output = &#039;escape&#039;; &quot; you can change the output postgresql uses.

If this isn&#039;t done. all pref_values in horde_prefs are corrupted. I had the problem when updating horde groupware webmail edition from 4.0.3 to 4.0.4 and 4.0.5.

If I got this correctly the following happened:

4.0.3 -&gt; 4.0.4

horde changed from using plaintext values in pref_value to using binary values, without changing the type of pref_value (it had still the type text). This wasn&#039;t that big a problem. the values looked somehow weird, but it worked quite a while.

4.0.4 -&gt; 4.0.5

pref_value was changed from type text to type binary, also converting all the values. This lead to corrupted values. The pref_value field had the correct information in it, but also a lot of completely useless information (mostly long sequences of the number 3, some other numbers mixed in from time to time. A single pref_value had more than 1 million signs alltough only a name and an e-mail address were stored). This happened because postgresql sent the bytea values as hex instead of escape format.

Changing the bytea_output from hex to bytea solves the problem. So the following line should be in the update scripts and in the create database script for postgresql 9.0

ALTER DATABASE horde SET bytea_output = &#039;escape&#039;; </description> 
   <pubDate>Thu, 12 Jan 2012 14:01:53 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10919#t69794</link> 
  </item> 
   
  <item> 
   <title>&gt; In PostgreSQL 9.xx bytea values have hex as default output</title> 
   <description>&gt; In PostgreSQL 9.xx bytea values have hex as default output, but horde 
&gt; expects escape. 
&gt; (http://www.postgresql.org/docs/9.0/static/release-9-0.html)

No.  We don&#039;t expect anything.  PDO handles result parsing.

We have unit tests that test exactly this and they work fine.

&gt; With &quot;ALTER DATABASE horde SET bytea_output = &#039;escape&#039;; &quot; you can 
&gt; change the output postgresql uses.

No.  We don&#039;t care what the output is - that is for PDO to worry about.  The only thing we care about is how to insert data into the DB.  And as is clearly discussed from that above page:

The bytea type always accepts both formats on input, regardless of this setting.

You are going to have to come up with a failing unit test to prove otherwise.</description> 
   <pubDate>Fri, 27 Jan 2012 08:26:14 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10919#t69955</link> 
  </item> 
   
  <item> 
   <title>&gt;&gt; In PostgreSQL 9.xx bytea values have hex as default outpu</title> 
   <description>&gt;&gt; In PostgreSQL 9.xx bytea values have hex as default output, but horde
&gt;&gt; expects escape.
&gt;&gt; (http://www.postgresql.org/docs/9.0/static/release-9-0.html)
&gt;
&gt; No.  We don&#039;t expect anything.  PDO handles result parsing.

This is not true, at least not in current code. 

&gt; We have unit tests that test exactly this and they work fine.
&gt;
&gt;&gt; With &quot;ALTER DATABASE horde SET bytea_output = &#039;escape&#039;; &quot; you can
&gt;&gt; change the output postgresql uses.
&gt;
&gt; No.  We don&#039;t care what the output is - that is for PDO to worry 
&gt; about.  The only thing we care about is how to insert data into the 
&gt; DB.  And as is clearly discussed from that above page:

Not true.  The database returns the data either as hex data, or escaped octal depending on the server&#039;s bytea_ouput setting. We expect the later. See Horde_Db_Adapter_Postgres_Column::binaryToString(). In Postgres 9.x, with bytea_output set to &#039;hex&#039; (the default in Postgres 9) the regexp will NOT match. PDO doesn&#039;t care what the value of this setting is, it returns it as -is.

&gt; The bytea type always accepts both formats on input, regardless of 
&gt; this setting.

Yes. It accepts the data for WRITING regardless of the setting, but it will presented back to client code differently depending on the setting. Using an ALTER database statement is one way to fix, but another is to provide &quot;options: --bytea_output=escape&quot; in the connection string.
</description> 
   <pubDate>Mon, 21 Oct 2013 17:56:34 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10919#t81159</link> 
  </item> 
   
  <item> 
   <title>Turns out this error s due to the version of the libpg not b</title> 
   <description>Turns out this error s due to the version of the libpg not being recent enough to work with the new 9.x default of returning bytea data as hex.

I.e, If you uppgrade pgsql to 9.x you MUST make sure you recompile or update pdo_pgsql with version libpg &gt;= 9.2 (9.1.x was tested and is broken in this regard).</description> 
   <pubDate>Mon, 21 Oct 2013 21:32:04 +0000</pubDate> 
   <link>https://bugs.horde.org/ticket/10919#t81161</link> 
  </item> 
   
   
 
 </channel> 
</rss> 
