Concatenating bytea types...

From: Marko Rihtar <rihtar(dot)marko(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Concatenating bytea types...
Date: 2013-02-28 10:21:04
Message-ID: CABSSDoFrOazsjrngAomQ4kgWgnrxbkLz8Gt_9YO6pQmTXgkEyQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi all,

i have a little problem.
I'm trying to rewrite one procedure from mysql that involves bytes
concatenation.
This is my snippet from postgres code:
...
cv1 bytea;
...
cv1 := E'\\000'::bytea;
...
cv1 := CONCAT(cv1, DECODE(TO_HEX(11), 'escape'));
...
this third line throws following error:
invalid hexadecimal digit: "\"

I run it through the debugger and saw that after assigning the zero byte
value to cv1 variable, postgres automatically converts it to \x00.
And then inside CONCAT it brakes with above error.

Inside select it works fine
select CONCAT(E'\\000'::bytea, DECODE(TO_HEX(11), 'escape'))
select CONCAT('\x00'::bytea, DECODE(TO_HEX(11), 'escape'))

Is there a way to solve this somehow?

thanks for help,

Marko

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Mark Stosberg 2013-02-28 16:37:39 Need help revoking access WHERE state = 'deleted'
Previous Message Igor Neyman 2013-02-27 16:02:06 Re: Using Ltree For Hierarchical Structures