From 3e80d0d2e5a0f6a7a971ddcb6e38cc8f0079aed7 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Thu, 7 Jul 2011 19:34:24 -0400 Subject: [PATCH] Update examples for string-related functions. In the example for decode(), show the bytea result in hex format, since that's now the default. Use an E'' string in the example for quote_literal(), so that it works regardless of the standard_conforming_strings setting. On the functions-for-binary-strings page, leave the examples as-is for readability, but add a note pointing out that they are shown in escape format. Per comments from Thom Brown. Also, improve the description for encode() and decode() a tad. Backpatch to 9.0, where bytea_output was introduced. --- doc/src/sgml/func.sgml | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index 8f223d6891..0b6a9d9542 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1482,15 +1482,15 @@ decode decode(string text, - type text) + format text) bytea - Decode binary data from string previously - encoded with encode. Parameter type is same as in encode. + Decode binary data from textual representation in string. + Options for format are same as in encode. decode('MTIzAAE=', 'base64') - 123\000\001 + \x3132330001 @@ -1499,13 +1499,13 @@ encode encode(data bytea, - type text) + format text) text - Encode binary data to different representation. Supported - types are: base64, hex, escape. - Escape merely outputs null bytes as \000 and + Encode binary data into a textual representation. Supported + formats are: base64, hex, escape. + escape merely outputs null bytes as \000 and doubles backslashes. encode(E'123\\000\\001', 'base64') @@ -1707,7 +1707,7 @@ quote_nullable is often more suitable. See also . - quote_literal('O\'Reilly') + quote_literal(E'O\'Reilly') 'O''Reilly' @@ -2859,6 +2859,14 @@ (see ). + + + The sample results shown on this page assume that the server parameter + bytea_output is set + to escape (the traditional PostgreSQL format). + + + <acronym>SQL</acronym> Binary String Functions and Operators -- 2.40.0