bytea_ouput = escape vs encode(byte, 'escape')

From: Jim Nasby <jim(at)nasby(dot)net>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: bytea_ouput = escape vs encode(byte, 'escape')
Date: 2013-11-27 20:54:37
Message-ID: 6C8528E8-CF24-48BB-85E0-41D72C20B1AC@nasby.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I'm wondering why bytes_output = escape produces different output than encode(byte, 'escape') does. Is this intentional? If so, why?

cnuapp_prod(at)postgres=# select e'\r'::bytea AS cr, e'\n'::bytea AS lf;
cr | lf
------+------
\x0d | \x0a
(1 row)

cnuapp_prod(at)postgres=# set bytea_output = escape;
SET
cnuapp_prod(at)postgres=# select e'\r'::bytea AS cr, e'\n'::bytea AS lf;
cr | lf
------+------
\015 | \012
(1 row)

cnuapp_prod(at)postgres=# select encode(e'\r'::bytea,'escape') AS cr, encode(e'\n'::bytea, 'escape') AS lf;
cr | lf
----+----
\r | +
|
(1 row)

cnuapp_prod(at)postgres=#
--
Jim C. Nasby, Data Architect jim(at)nasby(dot)net
512.569.9461 (cell) http://jim.nasby.net

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2013-11-27 20:59:31 Re: Suggestion: Issue warning when calling SET TRANSACTION outside transaction block
Previous Message Tom Lane 2013-11-27 20:47:13 Re: Modify the DECLARE CURSOR command tag depending on the scrollable flag