[HACKERS] bytea_ouput = escape vs encode(byte, 'escape')
I'm wondering why bytes_output = escape produces different output than encode(byte, 'escape') does. Is this intentional? If so, why? cnuapp_prod@postgres=# select e'\r'::bytea AS cr, e'\n'::bytea AS lf; cr | lf --+-- \x0d | \x0a (1 row) cnuapp_prod@postgres=# set bytea_output = escape; SET cnuapp_prod@postgres=# select e'\r'::bytea AS cr, e'\n'::bytea AS lf; cr | lf --+-- \015 | \012 (1 row) cnuapp_prod@postgres=# select encode(e'\r'::bytea,'escape') AS cr, encode(e'\n'::bytea, 'escape') AS lf; cr | lf + \r | + | (1 row) cnuapp_prod@postgres=# -- Jim C. Nasby, Data Architect j...@nasby.net 512.569.9461 (cell) http://jim.nasby.net -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers
Re: [HACKERS] bytea_ouput = escape vs encode(byte, 'escape')
Jim Nasby-2 wrote I'm wondering why bytes_output = escape produces different output than encode(byte, 'escape') does. Is this intentional? If so, why? cnuapp_prod@postgres=# select e'\r'::bytea AS cr, e'\n'::bytea AS lf; cr | lf --+-- \x0d | \x0a (1 row) cnuapp_prod@postgres=# set bytea_output = escape; SET cnuapp_prod@postgres=# select e'\r'::bytea AS cr, e'\n'::bytea AS lf; cr | lf --+-- \015 | \012 (1 row) cnuapp_prod@postgres=# select encode(e'\r'::bytea,'escape') AS cr, encode(e'\n'::bytea, 'escape') AS lf; cr | lf + \r | + | (1 row) cnuapp_prod@postgres=# encode takes a bytea and provides what it would be as a text (using the specified encoding to perform the conversion). the bytea output examples are simple output of the contents of the byte-array without an supposition as to what those bytes represent. It is strictly a serialization format and not an encoding/decoding of the contents. In this example the two functions are acting as paired input/output. I'm thinking the direction you are assuming from the word encode is confusing you - as it did me at first. David J. -- View this message in context: http://postgresql.1045698.n5.nabble.com/bytea-ouput-escape-vs-encode-byte-escape-tp5780643p5780647.html Sent from the PostgreSQL - hackers mailing list archive at Nabble.com. -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers