*** sgml.orig/func.sgml Mon Nov 19 01:05:01 2001 --- sgml/func.sgml Mon Nov 19 20:00:36 2001 *************** *** 1133,1139 **** text Encodes binary data to ASCII-only representation. Supported ! types are: 'base64', 'hex'. encode('123\\000\\001', 'base64') MTIzAAE= --- 1133,1139 ---- text Encodes binary data to ASCII-only representation. Supported ! types are: 'base64', 'hex', 'escape'. encode('123\\000\\001', 'base64') MTIzAAE= *************** *** 1164,1169 **** --- 1164,1349 ---- + + + + + This section describes functions and operators for examining and + manipulating binary string values. Strings in this context include + values of the type BYTEA. + + + + SQL defines some string functions with a special syntax where + certain keywords rather than commas are used to separate the + arguments. Details are in . + Some functions are also implemented using the regular syntax for + function invocation. (See .) + + +
+
+ +
+ + Function + Return Type + Description + Example + Result + +
+ +
+ + string || string + bytea + + string concatenation + + binary strings + concatenation + + + '\\\\Postgre'::bytea || '\\047SQL\\000'::bytea + \\Postgre'SQL\000 + + + + octet_length(string) + integer + number of bytes in binary string + octet_length('jo\\000se'::bytea) + 5 + + + + position(substring in string) + integer + location of specified substring + position('\\000om'::bytea in 'Th\\000omas'::bytea) + 3 + + + + substring(string from integer for integer) + bytea + + extract substring + + substring + + + substring('Th\\000omas'::bytea from 2 for 3) + h\000o + + + + + trim(both + characters from + string) + + bytea + + Removes the longest string containing only the + characters from the + beginning/end/both ends of the string. + + trim('\\000'::bytea from '\\000Tom\\000'::bytea) + Tom + + + + +
+ + + Additional binary string manipulation functions are available and are + listed below. Some of them are used internally to implement the + SQL-standard string functions listed above. + + +
+
+ +
+ + Function + Return Type + Description + Example + Result + +
+ +
+ + btrim(string bytea, trim bytea) + bytea + + Remove (trim) the longest string consisting only of characters + in trim from the start and end of + string. + + btrim('\\000trim\\000'::bytea,'\\000'::bytea) + trim + + + + length(string) + integer + + length of binary string + + binary strings + length + + + length + binary strings + binary strings, length + + + length('jo\\000se'::bytea) + 5 + + + + + encode(string bytea, + type text) + + text + + Encodes binary string to ASCII-only representation. Supported + types are: 'base64', 'hex', 'escape'. + + encode('123\\000456'::bytea, 'escape') + 123\000456 + + + + + decode(string text, + type text) + + bytea + + Decodes binary string from string previously + encoded with encode(). Parameter type is same as in encode(). + + decode('123\\000456', 'escape') + 123\000456 + + + + +
+ + + +
Re: bytea functions documentation
От:
Bruce Momjian <pgman@candle.pha.pa.us>
Дата:
Patch applied. Thanks.
---------------------------------------------------------------------------
> Here's my first attempt at a documentation patch :-)
>
> I've created a new section to func.sgml, "Binary String Functions and
> Operators", plagiarized shamelessly from the "String Functions and
> Operators" section. There were enough differences that it made sense (at
> least to me) to give this its own section instead of cramming it in with
> normal string functions. This way I could also make the examples
> relevant, which is particularly important for bytea.
>
> One thing I think worth mentioning: while documenting the trim()
> function I realized that I never implemented the bytea equivalent of
> rtrim and ltrim. Therefore, the 'leading' and 'trailing' forms of trim,
> available with text, are not available with bytea (I'd be happy to
> correct this, but since it would require an initdb, I guess not until
> 7.3) -- the submitted doc accurately reflects this.
>
> I will look for other areas of the docs that need mention of bytea, but
> any guidance would be much appreciated.
>
>
> regards,
>
> -- Joe
[ text/html is unsupported, treating like TEXT/PLAIN ]
> *** sgml.orig/func.sgml Mon Nov 19 01:05:01 2001
> --- sgml/func.sgml Mon Nov 19 20:00:36 2001
> ***************
> *** 1133,1139 ****
> text
>
> Encodes binary data to ASCII-only representation. Supported
> ! types are: 'base64', 'hex'.
>
> encode('123\\000\\001', 'base64')
> MTIzAAE=
> --- 1133,1139 ----
> text
>
> Encodes binary data to ASCII-only representation. Supported
> ! types are: 'base64', 'hex', 'escape'.
>
> encode('123\\000\\001', 'base64')
> MTIzAAE=
> ***************
> *** 1164,1169 ****
> --- 1164,1349 ----
>
>
>
> +
> + Binary String Functions and Operators
> +
> +
> + This section describes functions and operators for examining and
> + manipulating binary string values. Strings in this context include
> + values of the type BYTEA.
> +
> +
> +
> + SQL defines some string functions with a special syntax where
> + certain keywords rather than commas are used to separate the
> + arguments. Details are in .
> + Some functions are also implemented using the regular syntax for
> + function invocation. (See .)
> +
> +
> +
> + <acronym>SQL</acronym> Binary String Functions and Operators
> +
> +
> +
> + Function
> + Return Type
> + Description
> + Example
> + Result
> +
> +
> +
> +
> +
> + string || string
> + bytea
> +
> + string concatenation
> +
> + binary strings
> + concatenation
> +
> +
> + '\\\\Postgre'::bytea || '\\047SQL\\000'::bytea</>
> + \\Postgre'SQL\000</>
> +
> +
> +
> + octet_length(string)
> + integer
> + number of bytes in binary string
> + octet_length('jo\\000se'::bytea)
> + 5
> +
> +
> +
> + position(substring in string)
> + integer
> + location of specified substring
> + position('\\000om'::bytea in 'Th\\000omas'::bytea)
> + 3
> +
> +
> +
> + substring(string from integer for integer)
> + bytea
> +
> + extract substring
> +
> + substring
> +
> +
> + substring('Th\\000omas'::bytea from 2 for 3)
> + h\000o
> +
> +
> +
> +
> + trim(both
> + characters from
> + string)
> +
> + bytea
> +
> + Removes the longest string containing only the
> + characters from the
> + beginning/end/both ends of the string.
> +
> + trim('\\000'::bytea from '\\000Tom\\000'::bytea)
> + Tom
> +
> +
> +
> +
> +
> +
> +
> + Additional binary string manipulation functions are available and are
> + listed below. Some of them are used internally to implement the
> + SQL-standard string functions listed above.
> +
> +
> +
> + Other Binary String Functions
> +
> +
> +
> + Function
> + Return Type
> + Description
> + Example
> + Result
> +
> +
> +
> +
> +
> + btrim(string bytea, trim bytea)
> + bytea
> +
> + Remove (trim) the longest string consisting only of characters
> + in trim from the start and end of
> + string.
> +
> + btrim('\\000trim\\000'::bytea,'\\000'::bytea)
> + trim
> +
> +
> +
> + length(string)
> + integer
> +
> + length of binary string
> +
> + binary strings
> + length
> +
> +
> + length
> + binary strings
> + binary strings, length
> +
> +
> + length('jo\\000se'::bytea)</>
> + 5</>
> +
> +
> +
> +
> + encode(string bytea,
> + type text)
> +
> + text
> +
> + Encodes binary string to ASCII-only representation. Supported
> + types are: 'base64', 'hex', 'escape'.
> +
> + encode('123\\000456'::bytea, 'escape')
> + 123\000456
> +
> +
> +
> +
> + decode(string text,
> + type text)
> +
> + bytea
> +
> + Decodes binary string from string previously
> + encoded with encode(). Parameter type is same as in encode().
> +
> + decode('123\\000456', 'escape')
> + 123\000456
> +
> +
> +
> +
> +
> +
> +
> +
> +
>
> Pattern Matching
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo@postgresql.org)
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026