From: | Robert Treat <xzilla(at)users(dot)sourceforge(dot)net> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Cc: | Andrew Dunstan <andrew(at)dunslane(dot)net>, Florian Weimer <fweimer(at)bfk(dot)de> |
Subject: | Re: plperl: Documentation on BYTEA decoding is wrong |
Date: | 2008-01-26 17:07:25 |
Message-ID: | 200801261207.26308.xzilla@users.sourceforge.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Friday 25 January 2008 10:11, Andrew Dunstan wrote:
> Florian Weimer wrote:
> > This doesn't work because '\' is turned into '\\' by PostgreSQL, and
> > not '\134':
> >
> > my $arg = shift;
> > $arg =~ s!\\(\d{3})!chr(oct($1))!ge;
> >
> > Something like this might be better:
> >
> > my $arg = shift;
> > $arg =~ s!\\(?:\\|(\d{3}))!$1 ? chr(oct($1)) : "\\"!ge;
> >
> > You need to do this in one go because pre-escaped backslashes like
> > like '\\101' cause problems otherwise.
> >
> > (All ''-delimited strings in this posting use strict SQL syntax,
> > i.e. no escaped backslashes.)
>
> I think you're right, although that's rather ugly ;-) I'll commit this
> change for now, but if anyone comes up with a simpler recipe I'll be happy.
>
Note we've been using Theo's plperl bytea patch on one of our production
servers for some time; if anyone wants access to that lmk.
--
Robert Treat
Build A Brighter LAMP :: Linux Apache {middleware} PostgreSQL
From | Date | Subject | |
---|---|---|---|
Next Message | Pavel Stehule | 2008-01-26 17:49:26 | Re: Simple row serialization? |
Previous Message | Martijn van Oosterhout | 2008-01-26 16:57:09 | Re: Truncate Triggers |