[Database] Set bytea_output to match pg_unescape_bytea().
authorAaron Schulz <aschulz@wikimedia.org>
Sun, 3 Feb 2013 11:10:34 +0000 (03:10 -0800)
committerGerrit Code Review <gerrit@wikimedia.org>
Fri, 15 Feb 2013 04:01:50 +0000 (04:01 +0000)
* In newer versions of PG, a "hex" escaping format is used, which
  totally breaks things like SqlBagOStuff since the pg_unescape_bytea
  function still works the old way (it does not use a DB handle).
  Setting the format to the old way via SET fixes this.

Change-Id: I9f5a64922acd2d954880790f42ba4efafaed314e

includes/db/DatabasePostgres.php

index 5049ecf..2cbcc4b 100644 (file)
@@ -393,6 +393,9 @@ class DatabasePostgres extends DatabaseBase {
                $this->query( "SET datestyle = 'ISO, YMD'", __METHOD__ );
                $this->query( "SET timezone = 'GMT'", __METHOD__ );
                $this->query( "SET standard_conforming_strings = on", __METHOD__ );
+               if ( $this->getServerVersion() >= 9.0 ) {
+                       $this->query( "SET bytea_output = 'escape'", __METHOD__ ); // PHP bug 53127
+               }
 
                global $wgDBmwschema;
                $this->determineCoreSchema( $wgDBmwschema );