Re: Speeding up loops in pl/pgsql function - Mailing list pgsql-performance

From Alex Hunsaker
Subject Re: Speeding up loops in pl/pgsql function
Date
Msg-id BANLkTinuiR=Txtn_dUeSbvvgcWZj9c2+iw@mail.gmail.com
Whole thread Raw
In response to Speeding up loops in pl/pgsql function  ("Reuven M. Lerner" <reuven@lerner.co.il>)
List pgsql-performance
On Wed, May 25, 2011 at 10:59, Reuven M. Lerner <reuven@lerner.co.il> wrote:
> Hi, everyone.  I'm working on a project that's using PostgreSQL 8.3, that
> requires me to translate strings of octal digits into strings of characters
> -- so '141142143' should become 'abc', although the database column
> containing this data (both before and after) is a bytea.

Have you tried something like:
SELECT  encode(regexp_replace('141142143', '(\d{3})', '\\\1',
'g')::bytea, 'escape');

> ...
> Of course, any suggestions for how to deal with octal digits in PostgreSQL
> 8.3, such as an octal equivalent to the x'ff' syntax, would be more than
> welcome.

I think select E'\XXX' is what you are looking for (per the fine
manual: http://www.postgresql.org/docs/current/static/datatype-binary.html)

pgsql-performance by date:

Previous
From: Pavel Stehule
Date:
Subject: Re: Speeding up loops in pl/pgsql function
Next
From: "Kevin Grittner"
Date:
Subject: Re: "error with invalid page header" while vacuuming pgbench data