diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index c9205485f224b93f54b912611552b9d0dfe75dc5..d4dda3c412a049d03c2e0c0e4530bcf09311ecc2 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -1,4 +1,4 @@ -<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.63 2001/07/03 02:42:18 momjian Exp $ --> +<!-- $Header: /cvsroot/pgsql/doc/src/sgml/func.sgml,v 1.64 2001/07/11 22:14:01 momjian Exp $ --> <chapter id="functions"> <title>Functions and Operators</title> @@ -1051,6 +1051,34 @@ <entry>translate('12345', '14', 'ax')</entry> <entry>a23x5</entry> </row> + + <row> + <entry> + encode(<parameter>data</parameter> <type>bytea</type>, + <parameter>type</parameter> <type>text</type>) + </entry> + <entry><type>text</type></entry> + <entry> + Encodes binary data to ascii-only representation. Supported + types are: 'base64', 'hex'. + </entry> + <entry>encode('123\\000\\001', 'base64')</entry> + <entry>MTIzAAE=</entry> + </row> + + <row> + <entry> + decode(<parameter>string</parameter> <type>text</type>, + <parameter>type</parameter> <type>text</type>) + </entry> + <entry><type>bytea</type></entry> + <entry> + Decodes binary data from <parameter>string</parameter> previously + encoded with encode(). Parameter type is same as in encode(). + </entry> + <entry>decode('MTIzAAE=', 'base64')</entry> + <entry>123\000\001</entry> + </row> </tbody> </tgroup> diff --git a/src/backend/utils/adt/Makefile b/src/backend/utils/adt/Makefile index 0f8bdfe0b2454d518bac7fc431dd1b99dc0c14e5..d6b0bf75ce4916be8f0024e304425d9493941556 100644 --- a/src/backend/utils/adt/Makefile +++ b/src/backend/utils/adt/Makefile @@ -1,7 +1,7 @@ # # Makefile for utils/adt # -# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.49 2001/06/22 19:16:23 wieck Exp $ +# $Header: /cvsroot/pgsql/src/backend/utils/adt/Makefile,v 1.50 2001/07/11 22:14:02 momjian Exp $ # subdir = src/backend/utils/adt @@ -24,7 +24,7 @@ OBJS = acl.o arrayfuncs.o arrayutils.o bool.o cash.o char.o \ tid.o timestamp.o varbit.o varchar.o varlena.o version.o \ network.o mac.o inet_net_ntop.o inet_net_pton.o \ ri_triggers.o pg_lzcompress.o pg_locale.o formatting.o \ - ascii.o quote.o pgstatfuncs.o + ascii.o quote.o pgstatfuncs.o encode.o all: SUBSYS.o diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index fdff7f7f176374c6a17c2e4bd7039ac2fb4c2467..506e2b28009167bb583239b8715118ea26a1ba11 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.195 2001/06/22 19:16:24 wieck Exp $ + * $Id: pg_proc.h,v 1.196 2001/07/11 22:14:02 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -2684,6 +2684,11 @@ DESCR("Statistics: Blocks fetched for database"); DATA(insert OID = 1945 ( pg_stat_get_db_blocks_hit PGUID 12 f t t t 1 f 20 "26" 100 0 0 100 pg_stat_get_db_blocks_hit - )); DESCR("Statistics: Block found in cache for database"); +DATA(insert OID = 1946 ( encode PGUID 12 f t t t 2 f 25 "17 25" 100 0 0 100 binary_encode - )); +DESCR("Convert bytea value into some ascii-only text string"); +DATA(insert OID = 1947 ( decode PGUID 12 f t t t 2 f 17 "25 25" 100 0 0 100 binary_decode - )); +DESCR("Convert ascii-encoded text string into bytea value"); + /* * prototypes for functions pg_proc.c */ diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index d26794625503d85bee6b6312c7aa14ead6891b0e..efb5c3dcb22cc1a9d81fed646efb8cb52eeefaa6 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.156 2001/06/25 21:11:45 tgl Exp $ + * $Id: builtins.h,v 1.157 2001/07/11 22:14:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -409,6 +409,8 @@ extern Datum byteaGetByte(PG_FUNCTION_ARGS); extern Datum byteaGetBit(PG_FUNCTION_ARGS); extern Datum byteaSetByte(PG_FUNCTION_ARGS); extern Datum byteaSetBit(PG_FUNCTION_ARGS); +extern Datum binary_encode(PG_FUNCTION_ARGS); +extern Datum binary_decode(PG_FUNCTION_ARGS); /* version.c */ extern Datum pgsql_version(PG_FUNCTION_ARGS);