"Markus Wollny" <Markus(dot)Wollny(at)computec(dot)de> writes:
> ... I'am using the following function as workaround for a bytea-to-text-cast:
> create or replace function bytea2text(bytea) returns text as '
> begin
> return $1;
> end;
> ' language plpgsql;
That looks like your problem right there.
Possibly a binary cast (WITHOUT FUNCTION) would solve your problem,
though I doubt it will work well on bytea values containing \0.
regards, tom lane