Update examples for string-related functions.
authorTom Lane
Thu, 7 Jul 2011 23:34:19 +0000 (19:34 -0400)
committerTom Lane
Thu, 7 Jul 2011 23:34:19 +0000 (19:34 -0400)
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

index 628fbef001799df2c0a68a161db589e0f5d58b40..16240f7e39543f766688f53da63a43af403ecc9f 100644 (file)
          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
       
 
       
          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')
         quote_nullable is often more suitable.
         See also .
        
-       quote_literal('O\'Reilly')
+       quote_literal(E'O\'Reilly')
        'O''Reilly'
       
 
     (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