From 470a1048ec145fe16b5baea56b9aef93f9878747 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 1 Sep 2002 16:28:06 +0000 Subject: plpgsql functions can return RECORD, per Neil Conway. --- doc/src/sgml/plpgsql.sgml | 4 +--- doc/src/sgml/xfunc.sgml | 23 ++++++++++++++++++++++- 2 files changed, 23 insertions(+), 4 deletions(-) (limited to 'doc/src') 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 @@ @@ -538,8 +538,6 @@ END; Note that RECORD is not a true data type, only a placeholder. - Thus, for example, one cannot declare a function returning - RECORD. 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 @@ @@ -2119,6 +2119,27 @@ SELECT * FROM vw_getfoo; are all valid statements. + + + 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 + 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: + +SELECT * +FROM dblink('dbname=template1', 'select proname, prosrc from pg_proc') + AS t1(proname name, prosrc text) +WHERE proname LIKE 'bytea%'; + + The dblink function executes a remote query (see + contrib/dblink). It is declared to return 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 * should expand to. + + -- cgit v1.2.3