concatenating text and bytea

From: Vincent de Phily <vincent(dot)dephily(at)mobile-devices(dot)fr>
To: pgsql-general(at)postgresql(dot)org
Subject: concatenating text and bytea
Date: 2012-03-02 18:19:30
Message-ID: 1366684.UTYyVzsmQ2@moltowork
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I got recently bitten by this :

# select 'ascii'::text || E'\\xdeadbeef'::bytea, pg_typeof('ascii'::text ||
'\xdeadbeef'::bytea), 'ascii'::bytea || E'\\xdeadbeef'::bytea;
?column? | pg_typeof | ?column?
-----------------+-----------+----------------------
ascii\xdeadbeef | text | \x6173636969deadbeef

I would have expected a result cast as bytea or an error message telling me
about incompatible types, but the result from the first column is a nasty
gotcha. Is it the intented behaviour ?

--
Vincent de Phily

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2012-03-02 18:58:50 Re: concatenating text and bytea
Previous Message ChoonSoo Park 2012-03-02 18:12:18 Re: Opposite function of hstore each function