diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2002-09-01 16:28:06 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2002-09-01 16:28:06 +0000 |
commit | 470a1048ec145fe16b5baea56b9aef93f9878747 (patch) | |
tree | b437c27ddac8636efbb746852ea72b3ed7f4970e /doc/src | |
parent | 1903221517b7a5d8846d77160d9bad61721d48a1 (diff) | |
download | postgresql-470a1048ec145fe16b5baea56b9aef93f9878747.tar.gz postgresql-470a1048ec145fe16b5baea56b9aef93f9878747.zip |
plpgsql functions can return RECORD, per Neil Conway.
Diffstat (limited to 'doc/src')
-rw-r--r-- | doc/src/sgml/plpgsql.sgml | 4 | ||||
-rw-r--r-- | doc/src/sgml/xfunc.sgml | 23 |
2 files changed, 23 insertions, 4 deletions
diff --git a/doc/src/sgml/plpgsql.sgml b/doc/src/sgml/plpgsql.sgml index 4da3f3c0405..998ed72089e 100644 --- a/doc/src/sgml/plpgsql.sgml +++ b/doc/src/sgml/plpgsql.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.5 2002/08/30 00:28:40 tgl Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/plpgsql.sgml,v 1.6 2002/09/01 16:28:05 tgl Exp $ --> <chapter id="plpgsql"> @@ -538,8 +538,6 @@ END; <para> Note that <literal>RECORD</> is not a true data type, only a placeholder. - Thus, for example, one cannot declare a function returning - <literal>RECORD</>. </para> </sect2> diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml index 9a7b79f0ddd..3999bf81769 100644 --- a/doc/src/sgml/xfunc.sgml +++ b/doc/src/sgml/xfunc.sgml @@ -1,5 +1,5 @@ <!-- -$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.59 2002/08/30 00:28:40 tgl Exp $ +$Header: /cvsroot/pgsql/doc/src/sgml/xfunc.sgml,v 1.60 2002/09/01 16:28:05 tgl Exp $ --> <chapter id="xfunc"> @@ -2119,6 +2119,27 @@ SELECT * FROM vw_getfoo; </programlisting> are all valid statements. </para> + + <para> + In some cases it is useful to define table functions that can return + different column sets depending on how they are invoked. To support this, + the table function can be declared as returning the pseudo-type + <type>record</>. When such a function is used in a query, the expected + row structure must be specified in the query itself, so that the system + can know how to parse and plan the query. Consider this example: +<programlisting> +SELECT * +FROM dblink('dbname=template1', 'select proname, prosrc from pg_proc') + AS t1(proname name, prosrc text) +WHERE proname LIKE 'bytea%'; +</programlisting> + The <literal>dblink</> function executes a remote query (see + <literal>contrib/dblink</>). It is declared to return <type>record</> + since it might be used for any kind of query. The actual column set + must be specified in the calling query so that the parser knows, for + example, what <literal>*</> should expand to. + </para> + </sect1> <sect1 id="xfunc-plhandler"> |