Octal to hex transition - WTF

From: Craig Ringer <craig(at)postnewspapers(dot)com(dot)au>
To: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Octal to hex transition - WTF
Date: 2011-02-25 03:21:37
Message-ID: 4D672041.7030604@postnewspapers.com.au
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi all

I just found out that PHP 5.3's PostgreSQL PDO driver (as used by
Drupal) is broken by the Postgresql 8.0 transition from octal to hex
encoding for bytea. It passes the raw hex through to the app, including
the leading x , causing PHP's unserialize() function to choke.

I'm using Drupal with Apache and PostgreSQL on Windows (sigh) because
I'm writing up a step-by-step hand-holding guide for someone who needs
to do some testing against our Drupal database.

Drupal doesn't check that bytea_output is set to 'escape' as a
workaround or do a sanity test to detect this fault, so the results are
... interesting:

Notice: unserialize(): Error at offset 0 of 27 bytes in
variable_initialize() (line 749 of C:\Program Files\Apache Software
Foundation\Apache2.2\htdocs\drupal-7.0\includes\bootstrap.inc).

If anybody else lands up whacking their head against this for a while: just

ALTER DATABASE drupal SET bytea_output = 'escape'

to have your sanity restored.

The amount of breakage being seen in drivers really makes me wonder if
the the octal->hex transition should've been done with an opt-in from
drivers during negotiation or an explicit SET, rather than just making
it globally default. But, hey, hindsight.

--
Craig Ringer

Tech-related writing at http://soapyfrogs.blogspot.com/

Browse pgsql-general by date

  From Date Subject
Next Message John R Pierce 2011-02-25 04:22:03 Re: pg_dump makes our system unusable - any way to pg_dump in the middle of the day? (postgres 8.4.4)
Previous Message Adam Bruss 2011-02-25 03:09:40 Re: pg_dump makes our system unusable - any way to pg_dump in the middle of the day? (postgres 8.4.4)